aboutsummaryrefslogtreecommitdiff
path: root/src/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/documents/Documents.ts')
-rw-r--r--src/documents/Documents.ts37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/documents/Documents.ts b/src/documents/Documents.ts
index 60fa79eea..318a6d7a3 100644
--- a/src/documents/Documents.ts
+++ b/src/documents/Documents.ts
@@ -3,12 +3,15 @@ import { KeyStore } from "../fields/Key";
import { TextField } from "../fields/TextField";
import { NumberField } from "../fields/NumberField";
import { ListField } from "../fields/ListField";
+import { FieldTextBox } from "../views/nodes/FieldTextBox";
+import { CollectionDockingView } from "../views/collections/CollectionDockingView";
interface DocumentOptions {
x?: number;
y?: number;
width?: number;
height?: number;
+ title?: string;
}
export namespace Documents {
@@ -25,6 +28,9 @@ export namespace Documents {
if (options.height) {
doc.SetFieldValue(KeyStore.Height, options.height, NumberField);
}
+ if (options.title) {
+ doc.SetFieldValue(KeyStore.Title, options.title, TextField);
+ }
doc.SetFieldValue(KeyStore.Scale, 1, NumberField);
doc.SetFieldValue(KeyStore.PanX, 0, NumberField);
doc.SetFieldValue(KeyStore.PanY, 0, NumberField);
@@ -38,8 +44,8 @@ export namespace Documents {
textProto.SetField(KeyStore.Y, new NumberField(0));
textProto.SetField(KeyStore.Width, new NumberField(300));
textProto.SetField(KeyStore.Height, new NumberField(150));
- textProto.SetField(KeyStore.Layout, new TextField("<FieldTextBox doc={Document} fieldKey={DataKey} />"));
- textProto.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.Data]));
+ textProto.SetField(KeyStore.Layout, new TextField(FieldTextBox.LayoutString()));
+ textProto.SetField(KeyStore.LayoutKeys, new ListField([ KeyStore.Data ]));
}
return textProto;
}
@@ -51,6 +57,29 @@ export namespace Documents {
return doc;
}
+
+ let dockProto: Document;
+ function GetDockPrototype(): Document {
+ if (!dockProto) {
+ dockProto = new Document();
+ dockProto.SetField(KeyStore.X, new NumberField(0));
+ dockProto.SetField(KeyStore.Y, new NumberField(0));
+ dockProto.SetField(KeyStore.Width, new NumberField(300));
+ dockProto.SetField(KeyStore.Height, new NumberField(150));
+ dockProto.SetField(KeyStore.Layout, new TextField(CollectionDockingView.LayoutString()));
+ dockProto.SetField(KeyStore.LayoutKeys, new ListField([ KeyStore.Data ]));
+ }
+ return dockProto;
+ }
+
+ export function DockDocument(documents: Array<Document>, options: DocumentOptions = {}): Document {
+ let doc = GetDockPrototype().MakeDelegate();
+ setupOptions(doc, options);
+ doc.SetField(KeyStore.Data, new ListField(documents));
+ return doc;
+ }
+
+
let imageProto: Document;
function GetImagePrototype(): Document {
if (!imageProto) {
@@ -61,7 +90,7 @@ export namespace Documents {
imageProto.SetField(KeyStore.Height, new NumberField(300));
imageProto.SetField(KeyStore.Layout, new TextField('<img src={Data} draggable="false" width="100%" alt="Image not found"/>'));
// imageProto.SetField(KeyStore.Layout, new TextField('<div style={"background-image: " + {Data}} />'));
- imageProto.SetField(KeyStore.LayoutFields, new ListField([KeyStore.Data]));
+ imageProto.SetField(KeyStore.LayoutFields, new ListField([ KeyStore.Data ]));
}
return imageProto;
}
@@ -85,7 +114,7 @@ export namespace Documents {
collectionProto.SetField(KeyStore.Width, new NumberField(300));
collectionProto.SetField(KeyStore.Height, new NumberField(300));
collectionProto.SetField(KeyStore.Layout, new TextField('<CollectionFreeFormView Document={Document} fieldKey={DataKey} ContainingDocumentView={ContainingDocumentView}/>'));
- collectionProto.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.Data]));
+ collectionProto.SetField(KeyStore.LayoutKeys, new ListField([ KeyStore.Data ]));
}
return collectionProto;
}