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.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index bb463b36f..4cab53030 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -59,14 +59,14 @@ export namespace Documents {
const videoProtoId = "videoProto"
const audioProtoId = "audioProto";
- export function initProtos(mainDocId: string, callback: (mainDoc?: Document) => void) {
- Server.GetFields([collProtoId, textProtoId, imageProtoId, mainDocId], (fields) => {
+ export function initProtos(callback: () => void) {
+ Server.GetFields([collProtoId, textProtoId, imageProtoId], (fields) => {
collProto = fields[collProtoId] as Document;
imageProto = fields[imageProtoId] as Document;
textProto = fields[textProtoId] as Document;
webProto = fields[webProtoId] as Document;
kvpProto = fields[kvpProtoId] as Document;
- callback(fields[mainDocId] as Document)
+ callback();
});
}
function assignOptions(doc: Document, options: DocumentOptions): Document {
@@ -89,9 +89,11 @@ export namespace Documents {
function setupPrototypeOptions(protoId: string, title: string, layout: string, options: DocumentOptions): Document {
return assignOptions(new Document(protoId), { ...options, title: title, layout: layout });
}
- function SetInstanceOptions<T, U extends Field & { Data: T }>(doc: Document, options: DocumentOptions, value: T, ctor: { new(): U }, id?: string) {
+ function SetInstanceOptions<T, U extends Field & { Data: T }>(doc: Document, options: DocumentOptions, value: T | undefined, ctor: { new(): U } | undefined, id?: string) {
var deleg = doc.MakeDelegate(id);
- deleg.SetData(KeyStore.Data, value, ctor);
+ if (value !== undefined && ctor !== undefined) {
+ deleg.SetData(KeyStore.Data, value, ctor);
+ }
return assignOptions(deleg, options);
}
@@ -160,7 +162,7 @@ export namespace Documents {
return SetInstanceOptions(GetAudioPrototype(), options, new URL(url), AudioField);
}
export function TextDocument(options: DocumentOptions = {}) {
- return SetInstanceOptions(GetTextPrototype(), options, "", RichTextField);
+ return SetInstanceOptions(GetTextPrototype(), options, undefined, undefined);
}
export function PdfDocument(url: string, options: DocumentOptions = {}) {
return SetInstanceOptions(GetPdfPrototype(), options, new URL(url), PDFField);