aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 6ec5aa711..d8e1db0b0 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -9,6 +9,8 @@ import { ImageField } from "../../fields/ImageField";
import { ImageBox } from "../views/nodes/ImageBox";
import { CollectionView, CollectionViewType } from "../views/collections/CollectionView";
import { FieldView } from "../views/nodes/FieldView";
+import { HtmlField } from "../../fields/HtmlField";
+import { WebView } from "../views/nodes/WebView";
export interface DocumentOptions {
x?: number;
@@ -79,6 +81,28 @@ export namespace Documents {
return doc;
}
+ let htmlProto: Document;
+ const htmlProtoId = "htmlProto";
+ function GetHtmlPrototype(): Document {
+ if (!htmlProto) {
+ htmlProto = new Document(htmlProtoId);
+ htmlProto.Set(KeyStore.X, new NumberField(0));
+ htmlProto.Set(KeyStore.Y, new NumberField(0));
+ htmlProto.Set(KeyStore.Width, new NumberField(300));
+ htmlProto.Set(KeyStore.Height, new NumberField(150));
+ htmlProto.Set(KeyStore.Layout, new TextField(WebView.LayoutString()));
+ htmlProto.Set(KeyStore.LayoutKeys, new ListField([KeyStore.Data]));
+ }
+ return htmlProto;
+ }
+
+ export function HtmlDocument(html: string, options: DocumentOptions = {}): Document {
+ let doc = GetHtmlPrototype().MakeDelegate();
+ setupOptions(doc, options);
+ doc.Set(KeyStore.Data, new HtmlField(html));
+ return doc;
+ }
+
let imageProto: Document;
const imageProtoId = "imageProto";
function GetImagePrototype(): Document {