From 55bd063852ffa432a51ed0a3101f4c939ffaee62 Mon Sep 17 00:00:00 2001 From: Andrew Kim Date: Tue, 5 Mar 2019 19:00:55 -0500 Subject: pdf --- src/client/views/Main.tsx | 5 +++++ src/fields/PDFField.ts | 6 +++--- src/server/ServerUtil.ts | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index d845fa7a3..bbf315052 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -51,11 +51,13 @@ Documents.initProtos(mainDocId, (res?: Document) => { } let imgurl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"; + let pdfurl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg" let weburl = "https://cs.brown.edu/courses/cs166/"; let clearDatabase = action(() => Utils.Emit(Server.Socket, MessageStore.DeleteAll, {})) let addTextNode = action(() => Documents.TextDocument({ width: 200, height: 200, title: "a text note" })) let addColNode = action(() => Documents.FreeformDocument([], { width: 200, height: 200, title: "a freeform collection" })); let addSchemaNode = action(() => Documents.SchemaDocument([Documents.TextDocument()], { width: 200, height: 200, title: "a schema collection" })); + let addPDFNode = action(() => Documents.PdfDocument(pdfurl, { width: 200, height: 200, title: "a schema collection" })); let addImageNode = action(() => Documents.ImageDocument(imgurl, { width: 200, height: 200, title: "an image of a cat" })); let addWebNode = action(() => Documents.WebDocument(weburl, { width: 200, height: 200, title: "a sample web page" })); @@ -64,6 +66,7 @@ Documents.initProtos(mainDocId, (res?: Document) => { ); let imgRef = React.createRef(); + let pdfRef = React.createRef(); let webRef = React.createRef(); let textRef = React.createRef(); let schemaRef = React.createRef(); @@ -94,6 +97,8 @@ Documents.initProtos(mainDocId, (res?: Document) => {
+
+
), diff --git a/src/fields/PDFField.ts b/src/fields/PDFField.ts index 0db47a884..f3a009001 100644 --- a/src/fields/PDFField.ts +++ b/src/fields/PDFField.ts @@ -1,13 +1,13 @@ import { BasicField } from "./BasicField"; -import { Field } from "./Field"; +import { Field, FieldId } from "./Field"; import { observable } from "mobx" import { Types } from "../server/Message"; export class PDFField extends BasicField { - constructor(data: URL | undefined = undefined, save: boolean = true) { - super(data || new URL("http://cs.brown.edu/~bcz/face.gif"), save); + constructor(data: URL | undefined = undefined, id?: FieldId, save: boolean = true) { + super(data == undefined ? new URL("http://cs.brown.edu/~bcz/bob_fettucine.jpg") : data, save, id); } toString(): string { diff --git a/src/server/ServerUtil.ts b/src/server/ServerUtil.ts index a53fb5d2b..98ec99372 100644 --- a/src/server/ServerUtil.ts +++ b/src/server/ServerUtil.ts @@ -11,6 +11,7 @@ import { Types } from './Message'; import { Utils } from '../Utils'; import { HtmlField } from '../fields/HtmlField'; import { WebField } from '../fields/WebField'; +import { PDFField } from '../fields/PDFField'; export class ServerUtils { public static FromJson(json: any): Field { @@ -39,6 +40,8 @@ export class ServerUtils { return new Key(data, id, false) case Types.Image: return new ImageField(new URL(data), id, false) + case Types.PDF: + return new PDFField(new URL(data), id, false) case Types.List: return ListField.FromJson(id, data) case Types.Document: -- cgit v1.2.3-70-g09d2