aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocComponent.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/DocComponent.tsx')
-rw-r--r--src/client/views/DocComponent.tsx40
1 files changed, 11 insertions, 29 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 280ca8a8c..9fc1487a0 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -3,11 +3,11 @@ import { DateField } from '../../fields/DateField';
import { AclAdmin, AclAugment, AclEdit, AclPrivate, AclReadonly, AclSym, DataSym, Doc, DocListCast, Opt } from '../../fields/Doc';
import { InkTool } from '../../fields/InkField';
import { List } from '../../fields/List';
-import { ScriptField } from '../../fields/ScriptField';
import { Cast, ScriptCast } from '../../fields/Types';
import { denormalizeEmail, distributeAcls, GetEffectiveAcl, inheritParentAcls, SharingPermissions } from '../../fields/util';
import { returnFalse } from '../../Utils';
import { DocUtils } from '../documents/Documents';
+import { DocumentType } from '../documents/DocumentTypes';
import { InteractionUtils } from '../util/InteractionUtils';
import { UndoManager } from '../util/UndoManager';
import { DocumentView } from './nodes/DocumentView';
@@ -16,6 +16,7 @@ import { Touchable } from './Touchable';
/// DocComponent returns a generic React base class used by views that don't have 'fieldKey' props (e.g.,CollectionFreeFormDocumentView, DocumentView)
export interface DocComponentProps {
Document: Doc;
+ fieldKey?: string;
LayoutTemplate?: () => Opt<Doc>;
LayoutTemplateString?: string;
}
@@ -37,6 +38,10 @@ export function DocComponent<P extends DocComponentProps>() {
@computed get dataDoc() {
return this.props.Document[DataSym] as Doc;
}
+ // key where data is stored
+ @computed get fieldKey() {
+ return this.props.fieldKey;
+ }
protected _multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
}
@@ -77,12 +82,6 @@ export function ViewBoxBaseComponent<P extends ViewBoxBaseProps>() {
return this.props.fieldKey;
}
- isContentActive = (outsideReaction?: boolean) =>
- this.props.isContentActive?.() === false
- ? false
- : Doc.ActiveTool !== InkTool.None || this.props.isContentActive?.() || this.props.Document.forceActive || this.props.isSelected(outsideReaction) || this.props.rootSelected(outsideReaction)
- ? true
- : undefined;
protected _multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
}
return Component;
@@ -132,20 +131,6 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
lookupField = (field: string) => ScriptCast((this.layoutDoc as any).lookupField)?.script.run({ self: this.layoutDoc, data: this.rootDoc, field: field }).result;
- styleFromLayoutString = (scale: number) => {
- const style: { [key: string]: any } = {};
- const divKeys = ['width', 'height', 'fontSize', 'transform', 'left', 'background', '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: this.rootDoc, this: this.layoutDoc, scale }).result?.toString() ?? '';
- };
- divKeys.map((prop: string) => {
- const p = (this.props as any)[prop];
- typeof p === 'string' && (style[prop] = p?.replace(/{([^.'][^}']+)}/g, replacer));
- });
- return style;
- };
-
protected _multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
@computed public get annotationKey() {
@@ -158,13 +143,10 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
const indocs = doc instanceof Doc ? [doc] : doc;
const docs = indocs.filter(doc => [AclEdit, AclAdmin].includes(effectiveAcl) || GetEffectiveAcl(doc) === AclAdmin);
if (docs.length) {
- setTimeout(() =>
- docs.map(doc => {
- // this allows 'addDocument' to see the annotationOn field in order to create a pushin
- Doc.SetInPlace(doc, 'isPushpin', undefined, true);
- doc.annotationOn === this.props.Document && Doc.SetInPlace(doc, 'annotationOn', undefined, true);
- })
- );
+ docs.map(doc => {
+ Doc.SetInPlace(doc, 'followLinkToggle', undefined, true);
+ doc.annotationOn === this.props.Document && Doc.SetInPlace(doc, 'annotationOn', undefined, true);
+ });
const targetDataDoc = this.dataDoc;
const value = DocListCast(targetDataDoc[annotationKey ?? this.annotationKey]);
const toRemove = value.filter(v => docs.includes(v));
@@ -177,7 +159,7 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
doc.context = undefined;
if (recent) {
Doc.RemoveDocFromList(recent, 'data', doc);
- Doc.AddDocToList(recent, 'data', doc, undefined, true, true);
+ doc.type !== DocumentType.LOADING && Doc.AddDocToList(recent, 'data', doc, undefined, true, true);
}
});
this.isAnyChildContentActive() && this.props.select(false);