aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/Doc.ts20
-rw-r--r--src/fields/Schema.ts7
-rw-r--r--src/fields/ScriptField.ts4
-rw-r--r--src/fields/documentSchemas.ts3
-rw-r--r--src/fields/util.ts28
5 files changed, 34 insertions, 28 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 69d51e545..05baacf80 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -496,12 +496,10 @@ export namespace Doc {
Doc.SetLayout(alias, Doc.MakeAlias(layout));
}
alias.aliasOf = doc;
- if (doc !== Doc.GetProto(doc)) {
- alias.title = ComputedField.MakeFunction(`renameAlias(this, ${Doc.GetProto(doc).aliasNumber = NumCast(Doc.GetProto(doc).aliasNumber) + 1})`);
- }
+ alias.title = ComputedField.MakeFunction(`renameAlias(this, ${Doc.GetProto(doc).aliasNumber = NumCast(Doc.GetProto(doc).aliasNumber) + 1})`);
alias.author = Doc.CurrentUserEmail;
- Doc.AddDocToList(doc[DataSym], "aliases", alias);
+ Doc.AddDocToList(Doc.GetProto(doc)[DataSym], "aliases", alias);
return alias;
}
@@ -762,6 +760,13 @@ export namespace Doc {
}
});
copy.author = Doc.CurrentUserEmail;
+ if (copyProto) {
+ Doc.GetProto(copy).context = undefined;
+ Doc.GetProto(copy).aliases = new List<Doc>([copy]);
+ } else {
+ Doc.AddDocToList(Doc.GetProto(copy)[DataSym], "aliases", copy);
+ }
+ copy.context = undefined;
Doc.UserDoc().defaultAclPrivate && (copy["acl-Public"] = "Not Shared");
return copy;
}
@@ -774,6 +779,7 @@ export namespace Doc {
const delegate = new Doc(id, true);
delegate.proto = doc;
delegate.author = Doc.CurrentUserEmail;
+ if (!Doc.IsSystem(doc)) Doc.AddDocToList(doc[DataSym], "aliases", delegate);
title && (delegate.title = title);
return delegate;
}
@@ -1114,14 +1120,12 @@ export namespace Doc {
export function isDocPinned(doc: Doc) {
//add this new doc to props.Document
const curPres = Cast(Doc.UserDoc().activePresentation, Doc) as Doc;
- if (curPres) {
- return DocListCast(curPres.data).findIndex((val) => Doc.AreProtosEqual(val, doc)) !== -1;
- }
- return false;
+ return !curPres ? false : DocListCast(curPres.data).findIndex((val) => Doc.AreProtosEqual(val, doc)) !== -1;
}
export function copyDragFactory(dragFactory: Doc) {
const ndoc = dragFactory.isTemplateDoc ? Doc.ApplyTemplate(dragFactory) : Doc.MakeCopy(dragFactory, true);
+ ndoc && Doc.AddDocToList(Cast(Doc.UserDoc().myFileOrphans, Doc, null), "data", Doc.GetProto(ndoc));
if (ndoc && dragFactory["dragFactory-count"] !== undefined) {
dragFactory["dragFactory-count"] = NumCast(dragFactory["dragFactory-count"]) + 1;
Doc.SetInPlace(ndoc, "title", ndoc.title + " " + NumCast(dragFactory["dragFactory-count"]).toString(), true);
diff --git a/src/fields/Schema.ts b/src/fields/Schema.ts
index e0fc5902b..78f8a6bfb 100644
--- a/src/fields/Schema.ts
+++ b/src/fields/Schema.ts
@@ -3,6 +3,7 @@ import { Doc, Field } from "./Doc";
import { ObjectField } from "./ObjectField";
import { RefField } from "./RefField";
import { SelfProxy } from "./FieldSymbols";
+import { List } from "./List";
type AllToInterface<T extends Interface[]> = {
1: ToInterface<Head<T>> & AllToInterface<Tail<T>>,
@@ -67,9 +68,9 @@ export function makeInterface<T extends Interface[]>(...schemas: T): InterfaceFu
return function (doc?: Doc | Doc[]) {
if (doc instanceof Doc || doc === undefined) {
return fn(doc || new Doc);
- } else {
- if (!doc instanceof Promise) return doc.map(fn);
- }
+ } else if (doc instanceof List) {
+ return doc.map(fn);
+ } else return {};
};
}
diff --git a/src/fields/ScriptField.ts b/src/fields/ScriptField.ts
index c949e0791..9345ecde5 100644
--- a/src/fields/ScriptField.ts
+++ b/src/fields/ScriptField.ts
@@ -55,8 +55,8 @@ async function deserializeScript(script: ScriptField) {
if (script.script.originalScript === 'convertToButtons(dragData)') {
return (script as any).script = (ScriptField.ConvertToButtons ?? (ScriptField.ConvertToButtons = ComputedField.MakeFunction('convertToButtons(dragData)', { dragData: "DocumentDragData" })))?.script;
}
- if (script.script.originalScript === 'self.userDoc.noviceMode') {
- return (script as any).script = (ScriptField.NoviceMode ?? (ScriptField.NoviceMode = ComputedField.MakeFunction('self.userDoc.noviceMode')))?.script;
+ if (script.script.originalScript === 'IsNoviceMode()') {
+ return (script as any).script = (ScriptField.NoviceMode ?? (ScriptField.NoviceMode = ComputedField.MakeFunction('IsNoviceMode()')))?.script;
}
if (script.script.originalScript === `selectMainMenu(self)`) {
return (script as any).script = (ScriptField.SelectMenu ?? (ScriptField.SelectMenu = ComputedField.MakeFunction('selectMainMenu(self)')))?.script;
diff --git a/src/fields/documentSchemas.ts b/src/fields/documentSchemas.ts
index 6973079b0..4d8b6b55c 100644
--- a/src/fields/documentSchemas.ts
+++ b/src/fields/documentSchemas.ts
@@ -21,7 +21,6 @@ export const documentSchema = createSchema({
_currentTimecode: "number", // current play back time of a temporal document (video / audio)
_timecodeToShow: "number", // the time that a document should be displayed (e.g., time an annotation should be displayed on a video)
_timecodeToHIde: "number", // the time that a document should be hidden
- isLabel: "boolean", // whether the document is a label or not (video / audio)
markers: listSpec(Doc), // list of markers for audio / video
x: "number", // x coordinate when in a freeform view
y: "number", // y coordinate when in a freeform view
@@ -96,7 +95,7 @@ export const documentSchema = createSchema({
isInPlaceContainer: "boolean",// whether the marked object will display addDocTab() calls that target "inPlace" destinations
isLinkButton: "boolean", // whether document functions as a link follow button to follow the first link on the document when clicked
layers: listSpec("string"), // which layers the document is part of
- lockedPosition: "boolean", // whether the document can be moved (dragged)
+ _lockedPosition: "boolean", // whether the document can be moved (dragged)
_lockedTransform: "boolean",// whether a freeformview can pan/zoom
// drag drop properties
diff --git a/src/fields/util.ts b/src/fields/util.ts
index b9c5a13c1..36c765dd0 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -280,16 +280,16 @@ export function setter(target: any, in_prop: string | symbol | number, value: an
let prop = in_prop;
const effectiveAcl = getPropAcl(target, prop);
if (effectiveAcl !== AclEdit && effectiveAcl !== AclAdmin) return true;
-
// if you're trying to change an acl but don't have Admin access / you're trying to change it to something that isn't an acceptable acl, you can't
if (typeof prop === "string" && prop.startsWith("acl") && (effectiveAcl !== AclAdmin || ![...Object.values(SharingPermissions), undefined, "None"].includes(value))) return true;
// if (typeof prop === "string" && prop.startsWith("acl") && !["Can Edit", "Can Augment", "Can View", "Not Shared", undefined].includes(value)) return true;
- if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && (prop.startsWith("_") || layoutProps.includes(prop))) {
- if (!prop.startsWith("_")) {
- console.log(prop + " is deprecated - switch to _" + prop);
- prop = "_" + prop;
- }
+ if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && prop.startsWith("_")) {
+ // if (!prop.startsWith("_")) {
+ // console.log(prop + " is deprecated - switch to _" + prop);
+ // prop = "_" + prop;
+ // }
+ if (!prop.startsWith("__")) prop = prop.substring(1);
if (target.__LAYOUT__) {
target.__LAYOUT__[prop] = value;
return true;
@@ -308,12 +308,14 @@ export function getter(target: any, in_prop: string | symbol | number, receiver:
if (in_prop === "toString" || (in_prop !== HeightSym && in_prop !== WidthSym && in_prop !== LayoutSym && typeof prop === "symbol")) return target.__fields[prop] || target[prop];
if (GetEffectiveAcl(target) === AclPrivate) return prop === HeightSym || prop === WidthSym ? returnZero : undefined;
if (prop === LayoutSym) return target.__LAYOUT__;
- if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && (prop.startsWith("_") || layoutProps.includes(prop))) {
- if (!prop.startsWith("_")) {
- console.log(prop + " is deprecated - switch to _" + prop);
- prop = "_" + prop;
- }
- if (target.__LAYOUT__) return target.__LAYOUT__[prop];
+ let search = false;
+ if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && prop.startsWith("_")) {
+ // if (!prop.startsWith("_")) {
+ // console.log(prop + " is deprecated - switch to _" + prop);
+ // prop = "_" + prop;
+ // }
+ if (!prop.startsWith("__")) search = true;
+ if (target.__LAYOUT__) return target.__LAYOUT__[prop] ?? (search ? target.__LAYOUT__[prop.substring(1)] : undefined);
}
if (prop === "then") {//If we're being awaited
return undefined;
@@ -324,7 +326,7 @@ export function getter(target: any, in_prop: string | symbol | number, receiver:
if (SerializationHelper.IsSerializing()) {
return target[prop];
}
- return getFieldImpl(target, prop, receiver);
+ return (search ? getFieldImpl(target, (prop as any as string).substring(1), receiver) : undefined) ?? getFieldImpl(target, prop, receiver);
}
function getFieldImpl(target: any, prop: string | number, receiver: any, ignoreProto: boolean = false): any {