aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Doc.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-11-29 10:02:34 -0500
committerbobzel <zzzman@gmail.com>2023-11-29 10:02:34 -0500
commitba3b3f6f261074bd3f35012bde8730f5d4a36905 (patch)
tree6f6c7b141f8bc5881113378801d4b2940cfde36a /src/fields/Doc.ts
parentac360607bee82f0fef769eada99dc0b3f85ae70a (diff)
numerous changes to fix bugs and to fix/remove old or hacky code. fixed doc dec resizing. moving this.rootDoc => this.Document . fixing template artifacts.
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r--src/fields/Doc.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index e2746091e..993715e6f 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -537,7 +537,7 @@ export namespace Doc {
embedding.title = ComputedField.MakeFunction(`renameEmbedding(this)`);
embedding.author = Doc.CurrentUserEmail;
- Doc.AddDocToList(Doc.GetProto(doc)[DocData], 'proto_embeddings', embedding);
+ Doc.AddDocToList(doc[DocData], 'proto_embeddings', embedding);
return embedding;
}
@@ -788,8 +788,9 @@ export namespace Doc {
const dataDoc = Doc.GetProto(targetDoc);
newLayoutDoc.resolvedDataDoc = dataDoc;
newLayoutDoc['acl-Guest'] = SharingPermissions.Edit;
- if (dataDoc[templateField] === undefined && templateLayoutDoc[templateField] instanceof List && (templateLayoutDoc[templateField] as any).length) {
- dataDoc[templateField] = ComputedField.MakeFunction(`ObjectField.MakeCopy(templateLayoutDoc["${templateField}"] as List)`, { templateLayoutDoc: Doc.name }, { templateLayoutDoc });
+ if (dataDoc[templateField] === undefined && (templateLayoutDoc[templateField] as any)?.length) {
+ dataDoc[templateField] = ObjectField.MakeCopy(templateLayoutDoc[templateField] as List<Doc>);
+ // ComputedField.MakeFunction(`ObjectField.MakeCopy(templateLayoutDoc["${templateField}"])`, { templateLayoutDoc: Doc.name }, { templateLayoutDoc });
}
targetDoc[expandedLayoutFieldKey] = newLayoutDoc;
@@ -867,7 +868,7 @@ export namespace Doc {
}
export function MakeCopy(doc: Doc, copyProto: boolean = false, copyProtoId?: string, retitle = false): Doc {
- const copy = new Doc(copyProtoId, true);
+ const copy = runInAction(() => new Doc(copyProtoId, true));
updateCachedAcls(copy);
const exclude = [...StrListCast(doc.cloneFieldFilter), 'dragFactory_count', 'cloneFieldFilter'];
Object.keys(doc)
@@ -900,7 +901,7 @@ export namespace Doc {
Doc.GetProto(copy).embedContainer = undefined;
Doc.GetProto(copy).proto_embeddings = new List<Doc>([copy]);
} else {
- Doc.AddDocToList(Doc.GetProto(copy)[DocData], 'proto_embeddings', copy);
+ Doc.AddDocToList(copy[DocData], 'proto_embeddings', copy);
}
copy.embedContainer = undefined;
if (retitle) {
@@ -1305,12 +1306,12 @@ export namespace Doc {
});
}
- export function styleFromLayoutString(rootDoc: Doc, layoutDoc: Doc, props: any, scale: number) {
+ export function styleFromLayoutString(doc: Doc, props: any, scale: number) {
const style: { [key: string]: any } = {};
const divKeys = ['width', 'height', 'fontSize', 'transform', 'left', 'backgroundColor', 'left', 'right', 'top', 'bottom', 'pointerEvents', 'position'];
const replacer = (match: any, expr: string, offset: any, string: any) => {
// bcz: this executes a script to convert a property expression string: { script } into a value
- return ScriptField.MakeFunction(expr, { self: Doc.name, this: Doc.name, scale: 'number' })?.script.run({ self: rootDoc, this: layoutDoc, scale }).result?.toString() ?? '';
+ return ScriptField.MakeFunction(expr, { self: Doc.name, this: Doc.name, scale: 'number' })?.script.run({ this: doc, self: doc, scale }).result?.toString() ?? '';
};
divKeys.map((prop: string) => {
const p = props[prop];