aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/Doc.ts37
-rw-r--r--src/fields/InkField.ts6
-rw-r--r--src/fields/List.ts1
-rw-r--r--src/fields/documentSchemas.ts1
-rw-r--r--src/fields/util.ts8
5 files changed, 40 insertions, 13 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 50e5fcbc4..6abc27b23 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -821,6 +821,7 @@ export namespace Doc {
delegate[Initializing] = true;
delegate.proto = doc;
delegate.author = Doc.CurrentUserEmail;
+ Object.keys(doc).filter(key => key.startsWith("acl")).forEach(key => delegate[key] = doc[key]);
if (!Doc.IsSystem(doc)) Doc.AddDocToList(doc[DataSym], "aliases", delegate);
title && (delegate.title = title);
delegate[Initializing] = false;
@@ -1016,12 +1017,28 @@ export namespace Doc {
unbrushed = 0,
protoBrushed = 1,
selfBrushed = 2,
- highlighted = 3
+ highlighted = 3,
+ linkHighlighted = 4,
}
// don't bother memoizing (caching) the result if called from a non-reactive context. (plus this avoids a warning message)
export function IsBrushedDegreeUnmemoized(doc: Doc) {
if (!doc || GetEffectiveAcl(doc) === AclPrivate || GetEffectiveAcl(Doc.GetProto(doc)) === AclPrivate) return DocBrushStatus.unbrushed;
- return brushManager.BrushedDoc.has(doc) ? DocBrushStatus.selfBrushed : brushManager.BrushedDoc.has(Doc.GetProto(doc)) ? DocBrushStatus.protoBrushed : DocBrushStatus.unbrushed;
+ const status = brushManager.BrushedDoc.has(doc) ? DocBrushStatus.selfBrushed : brushManager.BrushedDoc.has(Doc.GetProto(doc)) ? DocBrushStatus.protoBrushed : DocBrushStatus.unbrushed;
+ if (status === DocBrushStatus.unbrushed) {
+ const lastBrushed = Array.from(brushManager.BrushedDoc.keys()).lastElement();
+ if (lastBrushed) {
+ for (const link of LinkManager.Instance.getAllDirectLinks(lastBrushed)) {
+ const a1 = Cast(link.anchor1, Doc, null);
+ const a2 = Cast(link.anchor2, Doc, null);
+ if (Doc.AreProtosEqual(a1, doc) || Doc.AreProtosEqual(a2, doc) ||
+ (Doc.AreProtosEqual(Cast(a1.annotationOn, Doc, null), doc)) ||
+ (Doc.AreProtosEqual(Cast(a2.annotationOn, Doc, null), doc))) {
+ return DocBrushStatus.linkHighlighted;
+ }
+ }
+ }
+ }
+ return status;
}
export function IsBrushedDegree(doc: Doc) {
return computedFn(function IsBrushDegree(doc: Doc) {
@@ -1030,14 +1047,18 @@ export namespace Doc {
}
export function BrushDoc(doc: Doc) {
if (!doc || GetEffectiveAcl(doc) === AclPrivate || GetEffectiveAcl(Doc.GetProto(doc)) === AclPrivate) return doc;
- brushManager.BrushedDoc.set(doc, true);
- brushManager.BrushedDoc.set(Doc.GetProto(doc), true);
+ runInAction(() => {
+ brushManager.BrushedDoc.set(doc, true);
+ brushManager.BrushedDoc.set(Doc.GetProto(doc), true);
+ });
return doc;
}
export function UnBrushDoc(doc: Doc) {
if (!doc || GetEffectiveAcl(doc) === AclPrivate || GetEffectiveAcl(Doc.GetProto(doc)) === AclPrivate) return doc;
- brushManager.BrushedDoc.delete(doc);
- brushManager.BrushedDoc.delete(Doc.GetProto(doc));
+ runInAction(() => {
+ brushManager.BrushedDoc.delete(doc);
+ brushManager.BrushedDoc.delete(Doc.GetProto(doc));
+ });
return doc;
}
@@ -1052,9 +1073,9 @@ export namespace Doc {
}
let _lastDate = 0;
- export function linkFollowHighlight(destDoc: Doc, dataAndDisplayDocs = true) {
+ export function linkFollowHighlight(destDoc: Doc | Doc[], dataAndDisplayDocs = true) {
linkFollowUnhighlight();
- Doc.HighlightDoc(destDoc, dataAndDisplayDocs);
+ (destDoc instanceof Doc ? [destDoc] : destDoc).forEach(doc => Doc.HighlightDoc(doc, dataAndDisplayDocs));
document.removeEventListener("pointerdown", linkFollowUnhighlight);
document.addEventListener("pointerdown", linkFollowUnhighlight);
const lastDate = _lastDate = Date.now();
diff --git a/src/fields/InkField.ts b/src/fields/InkField.ts
index 31024e805..114d5fc2f 100644
--- a/src/fields/InkField.ts
+++ b/src/fields/InkField.ts
@@ -11,7 +11,9 @@ export enum InkTool {
Pen = "pen",
Highlighter = "highlighter",
Eraser = "eraser",
- Stamp = "stamp"
+ Stamp = "stamp",
+ Write = "write",
+ PresentationPin = 'presentationpin'
}
@@ -83,7 +85,7 @@ export class InkField extends ObjectField {
}
[ToScriptString]() {
- return "new InkField([" + this.inkData.map(i => `{X: ${i.X}, Y: ${i.Y}} `) + "])";
+ return "new InkField([" + this.inkData.map(i => `{X: ${i.X}, Y: ${i.Y}`) + "])";
}
[ToString]() {
return "InkField";
diff --git a/src/fields/List.ts b/src/fields/List.ts
index 60bf442d4..b15548327 100644
--- a/src/fields/List.ts
+++ b/src/fields/List.ts
@@ -32,6 +32,7 @@ const listHandlers: any = {
},
push: action(function (this: any, ...items: any[]) {
items = items.map(toObjectField);
+
const list = this[Self];
const length = list.__fields.length;
for (let i = 0; i < items.length; i++) {
diff --git a/src/fields/documentSchemas.ts b/src/fields/documentSchemas.ts
index 4d5ae1018..e532becb5 100644
--- a/src/fields/documentSchemas.ts
+++ b/src/fields/documentSchemas.ts
@@ -44,7 +44,6 @@ export const documentSchema = createSchema({
_showCaption: "string", // whether editable caption text is overlayed at the bottom of the document
_showTitle: "string", // the fieldkey(s) whose contents should be displayed at the top of the document. separate multiple keys with ";". Use :hover suffix to indicate title should be shown on hover
_showAudio: "boolean", // whether to show the audio record icon on documents
- _freeformLOD: "boolean", // whether to enable LOD switching for CollectionFreeFormViews
_pivotField: "string", // specifies which field key should be used as the timeline/pivot axis
_columnsFill: "boolean", // whether documents in a stacking view column should be sized to fill the column
_columnsSort: "string", // how a document should be sorted "ascending", "descending", undefined (none)
diff --git a/src/fields/util.ts b/src/fields/util.ts
index c708affe3..d1e565774 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -138,6 +138,7 @@ export function denormalizeEmail(email: string) {
* Copies parent's acl fields to the child
*/
export function inheritParentAcls(parent: Doc, child: Doc) {
+ return;
const dataDoc = parent[DataSym];
for (const key of Object.keys(dataDoc)) {
// if the default acl mode is private, then don't inherit the acl-Public permission, but set it to private.
@@ -175,8 +176,11 @@ const getEffectiveAclCache = computedFn(function (target: any, user?: string) {
* Calculates the effective access right to a document for the current user.
*/
export function GetEffectiveAcl(target: any, user?: string): symbol {
- return !target ? AclPrivate :
- target[UpdatingFromServer] ? AclAdmin : getEffectiveAclCache(target, user);// all changes received from the server must be processed as Admin. return this directly so that the acls aren't cached (UpdatingFromServer is not observable)
+ if (!target) return AclPrivate;
+ if (target[UpdatingFromServer]) return AclAdmin;
+ // authored documents are private until an ACL is set.
+ if (!target[AclSym] && target.author && target.author !== Doc.CurrentUserEmail) return AclPrivate;
+ return getEffectiveAclCache(target, user);// all changes received from the server must be processed as Admin. return this directly so that the acls aren't cached (UpdatingFromServer is not observable)
}
function getPropAcl(target: any, prop: string | symbol | number) {