diff options
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r-- | src/client/documents/Documents.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 1d24ff7d2..94e1cb8dd 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -15,6 +15,8 @@ import { Key } from "../../fields/Key" import { Field } from "../../fields/Field"; import { KeyValueBox } from "../views/nodes/KeyValueBox" import { KVPField } from "../../fields/KVPField"; +import { PDFField } from "../../fields/PDFField"; +import { PDFNode } from "../views/nodes/PDFNode"; export interface DocumentOptions { x?: number; @@ -39,6 +41,7 @@ export namespace Documents { let collProto: Document; let kvpProto: Document; const textProtoId = "textProto"; + const pdfProtoId = "textProto"; const imageProtoId = "imageProto"; const webProtoId = "webProto"; const collProtoId = "collectionProto"; @@ -92,6 +95,11 @@ export namespace Documents { textProto = setupPrototypeOptions(textProtoId, "TEXT_PROTO", FormattedTextBox.LayoutString(), { x: 0, y: 0, width: 300, height: 150, layoutKeys: [KeyStore.Data] }); } + function GetPdfPrototype(): Document { + return textProto ? textProto : + textProto = setupPrototypeOptions(pdfProtoId, "PDF_PROTO", PDFNode.LayoutString(), + { x: 0, y: 0, width: 300, height: 150, layoutKeys: [KeyStore.Data] }); + } function GetWebPrototype(): Document { return webProto ? webProto : webProto = setupPrototypeOptions(webProtoId, "WEB_PROTO", WebBox.LayoutString(), @@ -120,6 +128,9 @@ export namespace Documents { export function TextDocument(options: DocumentOptions = {}) { return SetInstanceOptions(GetTextPrototype(), options, "", TextField); } + export function PdfDocument(url: string, options: DocumentOptions = {}) { + return SetInstanceOptions(GetPdfPrototype(), options, new URL(url), PDFField); + } export function WebDocument(url: string, options: DocumentOptions = {}) { return SetInstanceOptions(GetWebPrototype(), options, new URL(url), WebField); } @@ -141,8 +152,6 @@ export namespace Documents { return assignOptions(deleg, options); } - - // example of custom display string for an image that shows a caption. function EmbeddedCaption() { return `<div style="height:100%"> |