();
+ dashboardDoc.$myTrails = DashboardView.SetupDashboardTrails();
+ dashboardDoc.$myCalendars = DashboardView.SetupDashboardCalendars();
// open this new dashboard
Doc.ActiveDashboard = dashboardDoc;
Doc.ActivePage = 'dashboard';
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index e351e2dec..064906530 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -5,7 +5,7 @@ import { DateField } from '../../fields/DateField';
import { Doc, DocListCast, Opt } from '../../fields/Doc';
import { AclAdmin, AclAugment, AclEdit, AclPrivate, AclReadonly, DocData } from '../../fields/DocSymbols';
import { List } from '../../fields/List';
-import { toList } from '../../fields/Types';
+import { DocCast, toList } from '../../fields/Types';
import { GetEffectiveAcl, inheritParentAcls } from '../../fields/util';
import { DocumentType } from '../documents/DocumentTypes';
import { ObservableReactComponent } from './ObservableReactComponent';
@@ -35,14 +35,14 @@ export function DocComponent() {
* Rather, it specifies the shared properties of all layouts of the document (eg, x,y,)
*/
get Document() {
- return this._props.Document;
+ return DocCast(this._props.Document.rootDocument, this._props.Document);
}
/**
* This is the document being rendered. It may be a template so it may or may no inherit from the data doc.
*/
@computed get layoutDoc() {
- return this._props.LayoutTemplateString ? this.Document : Doc.Layout(this.Document, this._props.LayoutTemplate?.());
+ return this._props.LayoutTemplateString ? this.Document : Doc.Layout(this._props.Document, this._props.LayoutTemplate?.());
}
/**
@@ -80,13 +80,13 @@ export function ViewBoxBaseComponent
() {
* Rather, it specifies the shared properties of all layouts of the document (eg, x,y,)
*/
get Document() {
- return this._props.Document;
+ return DocCast(this._props.Document.rootDocument, this._props.Document);
}
/**
* This is the document being rendered. It may be a template so it may or may no inherit from the data doc.
*/
@computed get layoutDoc() {
- return Doc.Layout(this.Document);
+ return Doc.Layout(this._props.Document);
}
/**
@@ -138,13 +138,13 @@ export function ViewBoxAnnotatableComponent
() {
* Rather, it specifies the shared properties of all layouts of the document (eg, x,y,)
*/
@computed get Document() {
- return this._props.Document;
+ return DocCast(this._props.Document.rootDocument, this._props.Document);
}
/**
* This is the document being rendered. It may be a template so it may or may no inherit from the data doc.
*/
@computed get layoutDoc() {
- return Doc.Layout(this.Document);
+ return Doc.Layout(this._props.Document);
}
/**
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 54e050f9f..92b4d6fbf 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -127,7 +127,7 @@ export class DocumentDecorations extends ObservableReactComponent#')) {
DocumentView.SelectedDocs().forEach(doc => {
- doc[DocData].onViewMounted = ScriptField.MakeScript(`updateTagsCollection(this)`);
+ doc.$onViewMounted = ScriptField.MakeScript(`updateTagsCollection(this)`);
});
}
const titleFieldKey = this._titleControlString.substring(1);
@@ -621,7 +621,7 @@ export class DocumentDecorations extends ObservableReactComponent ({ oldbds, inkPts: Cast(oldbds.doc.data, InkField)?.inkData || [] }))
.forEach(({ oldbds: { doc, x, y, width, height }, inkPts }) => {
- doc[DocData].data = new InkField(inkPts.map(
+ doc.$data = new InkField(inkPts.map(
(ipt) => ({// (new x — oldx) + newWidth * (oldxpoint /oldWidth)
X: NumCast(doc.x) - x + (NumCast(doc.width) * ipt.X) / width,
Y: NumCast(doc.y) - y + (NumCast(doc.height) * ipt.Y) / height,
diff --git a/src/client/views/FilterPanel.tsx b/src/client/views/FilterPanel.tsx
index 99738052d..4fc8d7a68 100644
--- a/src/client/views/FilterPanel.tsx
+++ b/src/client/views/FilterPanel.tsx
@@ -9,7 +9,6 @@ import { Handles, Rail, Slider, Ticks, Tracks } from 'react-compound-slider';
import { AiOutlineMinusSquare, AiOutlinePlusSquare } from 'react-icons/ai';
import { CiCircleRemove } from 'react-icons/ci';
import { Doc, DocListCast, Field, FieldType, LinkedTo, StrListCast } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { Id } from '../../fields/FieldSymbols';
import { List } from '../../fields/List';
import { RichTextField } from '../../fields/RichTextField';
@@ -89,7 +88,7 @@ const HotKeyIconButton: React.FC = observer(({ hotKey /*, sel
key={icon.toString()}
onClick={undoable(e => {
e.stopPropagation;
- hotKey[DocData].icon = icon.toString();
+ hotKey.$icon = icon.toString();
}, '')}
className="icon-panel-button">
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index 358274f0e..6854476e2 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -3,7 +3,6 @@ import * as fitCurve from 'fit-curve';
import * as _ from 'lodash';
import { action, makeObservable, observable, reaction, runInAction } from 'mobx';
import { Doc, NumListCast, Opt } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { InkData, InkField, InkTool } from '../../fields/InkField';
import { List } from '../../fields/List';
import { listSpec } from '../../fields/Schema';
@@ -509,7 +508,7 @@ export class InkStrokeProperties {
const inkStroke = inkView?.ComponentView as InkingStroke;
const polylinePoints = this.sampleBezier(inkStroke?.inkScaledData().inkData ?? [])?.map(pt => [pt.x, pt.y]);
if (polylinePoints) {
- inkDoc[DocData].stroke = new InkField(
+ inkDoc.$stroke = new InkField(
fitCurve.default(polylinePoints, tolerance)
.reduce((cpts, bez) =>
({n: cpts.push(...bez.map(cpt => ({X:cpt[0], Y:cpt[1]}))), cpts}).cpts,
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index ef8d0c197..e70f9e5ed 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -11,7 +11,6 @@ import '@dash/components/src/global/globalCssVariables.scss';
import { ClientUtils, returnEmptyFilter, returnFalse, returnTrue, returnZero, setupMoveUpEvents } from '../../ClientUtils';
import { emptyFunction } from '../../Utils';
import { Doc, DocListCast, GetDocFromUrl, Opt, returnEmptyDoclist } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { Id } from '../../fields/FieldSymbols';
import { DocCast, StrCast, toList } from '../../fields/Types';
import { DocServer } from '../DocServer';
@@ -849,7 +848,7 @@ export class MainView extends ObservableReactComponent {
@action
selectMenu = (button: Doc) => {
- const title = StrCast(button[DocData].title);
+ const title = StrCast(button.$title);
const willOpen = !this._leftMenuFlyoutWidth || this._panelContent !== title;
this.closeFlyout();
if (willOpen) {
diff --git a/src/client/views/MarqueeAnnotator.tsx b/src/client/views/MarqueeAnnotator.tsx
index 3f4200dce..e4811a902 100644
--- a/src/client/views/MarqueeAnnotator.tsx
+++ b/src/client/views/MarqueeAnnotator.tsx
@@ -97,7 +97,6 @@ export class MarqueeAnnotator extends ObservableReactComponent' + this.props.Document.title,
});
- const textRegionAnnoProto = textRegionAnno[DocData];
let minX = Number.MAX_VALUE;
let maxX = -Number.MAX_VALUE;
let minY = Number.MAX_VALUE;
@@ -118,15 +117,15 @@ export class MarqueeAnnotator extends ObservableReactComponent(annoRects);
- textRegionAnnoProto.opacity = 0;
- textRegionAnnoProto.layout_unrendered = true;
+ textRegionAnno.$text_inlineAnnotations = new List(annoRects);
+ textRegionAnno.$opacity = 0;
+ textRegionAnno.$layout_unrendered = true;
savedAnnoMap.clear();
return textRegionAnno;
};
@@ -226,9 +225,8 @@ export class MarqueeAnnotator extends ObservableReactComponent {
if (!dragEx.aborted && dragEx.linkDocument) {
- const linkDocData = dragEx.linkDocument[DocData];
- linkDocData.link_relationship = 'cropped image';
- linkDocData.title = 'crop: ' + this.props.Document.title;
+ dragEx.linkDocument.$link_relationship = 'cropped image';
+ dragEx.linkDocument.$title = 'crop: ' + this.props.Document.title;
}
},
});
diff --git a/src/client/views/PinFuncs.ts b/src/client/views/PinFuncs.ts
index ab02c2d07..1ab8575a8 100644
--- a/src/client/views/PinFuncs.ts
+++ b/src/client/views/PinFuncs.ts
@@ -1,5 +1,4 @@
import { Doc, DocListCast, Field } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { Copy, Id } from '../../fields/FieldSymbols';
import { List } from '../../fields/List';
import { ObjectField } from '../../fields/ObjectField';
@@ -78,7 +77,7 @@ export function PinDocView(pinDocIn: Doc, pinProps: PinProps, targetDoc: Doc) {
}
if (pinProps.pinData.dataannos) {
const fieldKey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.config_annotations = new List(DocListCast(targetDoc[DocData][fieldKey + '_annotations']).filter(doc => !doc.layout_unrendered));
+ pinDoc.config_annotations = new List(DocListCast(targetDoc['$' + fieldKey + '_annotations']).filter(doc => !doc.layout_unrendered));
}
if (pinProps.pinData.inkable) {
pinDoc.config_fillColor = targetDoc.fillColor;
diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx
index 606fb17ed..2b4fe478e 100644
--- a/src/client/views/PropertiesButtons.tsx
+++ b/src/client/views/PropertiesButtons.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable react/no-unused-class-component-methods */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Dropdown, DropdownType, IListItemProps, Toggle, ToggleType, Type } from '@dash/components';
import { action, computed, observable } from 'mobx';
@@ -14,7 +13,6 @@ import { RxWidth } from 'react-icons/rx';
import { TbEditCircle, TbEditCircleOff, TbHandOff, TbHandStop, TbHighlight, TbHighlightOff } from 'react-icons/tb';
import { TfiBarChart } from 'react-icons/tfi';
import { Doc, Opt } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { ScriptField } from '../../fields/ScriptField';
import { BoolCast, ScriptCast, StrCast } from '../../fields/Types';
import { ImageField } from '../../fields/URLField';
@@ -134,8 +132,8 @@ export class PropertiesButtons extends React.Component {
() => ,
(dv, doc) => {
const on = !!doc.onPaint;
- doc[DocData].onPaint = on ? undefined : ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, { documentView: 'any' });
- doc[DocData].layout_textPainted = on ? undefined : ` `;
+ doc.$onPaint = on ? undefined : ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, { documentView: 'any' });
+ doc.$layout_textPainted = on ? undefined : ` `;
}
);
}
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 11adf7435..c72f958fc 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -282,7 +282,7 @@ export class PropertiesView extends ObservableReactComponent(tags) : undefined;
+ doc.$tags = tags.length ? new List(tags) : undefined;
}
return true;
}
@@ -498,7 +498,7 @@ export class PropertiesView extends ObservableReactComponent {
let userOnDoc = true;
@@ -777,7 +777,7 @@ export class PropertiesView extends ObservableReactComponent doc.layout_isSvg);
+ return this.containsInkDoc ? DocListCast(this.selectedDoc.$data) : DocumentView.SelectedSchemaDoc() ? [DocumentView.SelectedSchemaDoc()!] : DocumentView.SelectedDocs().filter(doc => doc.layout_isSvg);
}
@computed get shapeXps() { return NumCast(this.selectedDoc?.x); } // prettier-ignore
set shapeXps(value) { this.selectedDoc && (this.selectedDoc.x = Math.round(value * 100) / 100); } // prettier-ignore
@@ -839,10 +839,10 @@ export class PropertiesView extends ObservableReactComponent {
- doc[DocData].stroke_width = Math.round(value * 100) / 100;
+ doc.$stroke_width = Math.round(value * 100) / 100;
});
}
@@ -881,20 +881,20 @@ export class PropertiesView extends ObservableReactComponent {
const inkStroke = DocumentView.getDocumentView(doc)?.ComponentView as InkingStroke;
const { inkData } = inkStroke.inkScaledData();
if (InkingStroke.IsClosed(inkData)) {
- doc[DocData].fillColor = value || undefined;
+ doc.$fillColor = value || undefined;
}
});
}
- @computed get colorStk() { return StrCast(this.selectedStrokes.lastElement()?.[DocData].color); } // prettier-ignore
+ @computed get colorStk() { return StrCast(this.selectedStrokes.lastElement()?.$olor); } // prettier-ignore
set colorStk(value) {
this.selectedStrokes.forEach(doc => {
- doc[DocData].color = value || undefined;
+ doc.$color = value || undefined;
});
}
@computed get borderColor() {
@@ -902,7 +902,7 @@ export class PropertiesView extends ObservableReactComponent void) {
return (
@@ -1034,41 +1034,41 @@ export class PropertiesView extends ObservableReactComponent {
- doc[DocData].stroke_dash = value ? this._lastDash : undefined;
+ doc.$stroke_dash = value ? this._lastDash : undefined;
});
}
@computed get widthStk() { return this.getField('stroke_width') || '1'; } // prettier-ignore
set widthStk(value) {
this.selectedStrokes.forEach(doc => {
- doc[DocData].stroke_width = Number(value);
+ doc.$stroke_width = Number(value);
});
}
@computed get markScal() { return Number(this.getField('stroke_markerScale') || '1'); } // prettier-ignore
set markScal(value) {
this.selectedStrokes.forEach(doc => {
- doc[DocData].stroke_markerScale = Number(value);
+ doc.$stroke_markerScale = Number(value);
});
}
@computed get refStrength() { return Number(this.getField('drawing_refStrength') || '50'); } // prettier-ignore
set refStrength(value) {
- this.selectedDoc[DocData].drawing_refStrength = Number(value);
+ this.selectedDoc.$drawing_refStrength = Number(value);
}
@computed get smoothAmt() { return Number(this.getField('stroke_smoothAmount') || '5'); } // prettier-ignore
set smoothAmt(value) {
this.selectedStrokes.forEach(doc => {
- doc[DocData].stroke_smoothAmount = Number(value);
+ doc.$stroke_smoothAmount = Number(value);
});
}
@computed get markHead() { return this.getField('stroke_startMarker') || ''; } // prettier-ignore
set markHead(value) {
this.selectedStrokes.forEach(doc => {
- doc[DocData].stroke_startMarker = value;
+ doc.$stroke_startMarker = value;
});
}
@computed get markTail() { return this.getField('stroke_endMarker') || ''; } // prettier-ignore
set markTail(value) {
this.selectedStrokes.forEach(doc => {
- doc[DocData].stroke_endMarker = value;
+ doc.$stroke_endMarker = value;
});
}
@@ -1356,7 +1356,7 @@ export class PropertiesView extends ObservableReactComponent {
- const childDocs: Doc[] = DocListCast(selectedDoc[DocData].data);
+ const childDocs: Doc[] = DocListCast(selectedDoc.$data);
for (let i = 0; i < childDocs.length; i++) {
if (DocumentView.getDocumentView(childDocs[i])?.layoutDoc?.layout_isSvg) {
return true;
@@ -1454,7 +1454,7 @@ export class PropertiesView extends ObservableReactComponent {
if (this.selectedLink) {
- this.selectedLink[DocData].link_description = value;
+ this.selectedLink.$link_description = value;
}
});
diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx
index d05b0a6b6..52c0227d8 100644
--- a/src/client/views/ScriptBox.tsx
+++ b/src/client/views/ScriptBox.tsx
@@ -3,7 +3,6 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { emptyFunction } from '../../Utils';
import { Doc, Opt } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { ScriptField } from '../../fields/ScriptField';
import { ScriptCast } from '../../fields/Types';
import { DragManager } from '../util/DragManager';
@@ -101,7 +100,6 @@ export class ScriptBox extends React.Component {
);
}
// let l = docList(this.source[0].data).length; if (l) { let ind = this.target[0].index !== undefined ? (this.target[0].index+1) % l : 0; this.target[0].index = ind; this.target[0].proto = getProto(docList(this.source[0].data)[ind]);}
- // eslint-disable-next-line react/sort-comp
public static EditButtonScript(title: string, doc: Doc, fieldKey: string, clientX: number, clientY: number, contextParams?: { [name: string]: string }, defaultScript?: ScriptField) {
let overlayDisposer: () => void = emptyFunction;
const script = ScriptCast(doc[fieldKey]) || defaultScript;
@@ -119,7 +117,7 @@ export class ScriptBox extends React.Component {
onCancel={overlayDisposer}
onSave={(text, onError) => {
if (!text) {
- doc[DocData][fieldKey] = undefined;
+ doc['$' + fieldKey] = undefined;
} else {
const compScript = CompileScript(text, {
params: { this: Doc.name, ...contextParams },
@@ -142,7 +140,7 @@ export class ScriptBox extends React.Component {
div.innerHTML = 'button';
params.length && DragManager.StartButtonDrag([div], text, doc.title + '-instance', {}, params, () => {}, clientX, clientY);
- doc[DocData][fieldKey] = new ScriptField(compScript);
+ doc['$' + fieldKey] = new ScriptField(compScript);
overlayDisposer();
}
}}
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index e51bc18ef..a45b37f43 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -503,9 +503,8 @@ export class CollectionDockingView extends CollectionSubView() {
});
const dashboardDoc = Docs.Create.DockDocument(newtabs, json, { title: incrementTitleCopy(StrCast(doc.title)) });
- dashboardDoc.pane_count = 1;
- dashboardDoc.myOverlayDocs = new List();
- dashboardDoc.myPublishedDocs = new List();
+ dashboardDoc.$myOverlayDocs = new List();
+ dashboardDoc.$myPublishedDocs = new List();
DashboardView.SetupDashboardTrails();
DashboardView.SetupDashboardCalendars(); // Zaul TODO: needed?
@@ -555,13 +554,13 @@ export class CollectionDockingView extends CollectionSubView() {
stack.header?.element.on('mousedown', (e: MouseEvent) => {
const dashboard = Doc.ActiveDashboard;
if (dashboard && e.target === stack.header?.element[0] && e.button === 2) {
- dashboard.pane_count = NumCast(dashboard.pane_count) + 1;
+ dashboard.$myPaneCount = NumCast(dashboard.$myPaneCount) + 1;
const docToAdd = Docs.Create.FreeformDocument([], {
_width: this._props.PanelWidth(),
_height: this._props.PanelHeight(),
_freeform_backgroundGrid: true,
_layout_fitWidth: true,
- title: `Untitled Tab ${NumCast(dashboard.pane_count)}`,
+ title: `Untitled Tab ${NumCast(dashboard.$myPaneCount)}`,
});
Doc.AddDocToList(Doc.MyHeaderBar, 'data', docToAdd, undefined, undefined, true);
inheritParentAcls(this.Document, docToAdd, false);
@@ -572,13 +571,13 @@ export class CollectionDockingView extends CollectionSubView() {
const addNewDoc = undoable(() => {
const dashboard = Doc.ActiveDashboard;
if (dashboard) {
- dashboard.pane_count = NumCast(dashboard.pane_count) + 1;
+ dashboard.$myPaneCount = NumCast(dashboard.$myPaneCount) + 1;
const docToAdd = Docs.Create.FreeformDocument([], {
_width: this._props.PanelWidth(),
_height: this._props.PanelHeight(),
_layout_fitWidth: true,
_freeform_backgroundGrid: true,
- title: `Untitled Tab ${NumCast(dashboard.pane_count)}`,
+ title: `Untitled Tab ${NumCast(dashboard.$myPaneCount)}`,
});
Doc.AddDocToList(Doc.MyHeaderBar, 'data', docToAdd, undefined, undefined, true);
inheritParentAcls(this.dataDoc, docToAdd, false);
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index cac276535..fdaf13733 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -88,7 +88,7 @@ export interface DocumentViewProps extends FieldViewSharedProps {
@observer
export class DocumentViewInternal extends DocComponent() {
// this makes mobx trace() statements more descriptive
- public get displayName() { return 'DocumentViewInternal(' + this.Document.title + ')'; } // prettier-ignore
+ public get displayName() { return 'DocumentViewInternal(' + this.Document.$title + ')'; } // prettier-ignore
public static SelectAfterContextMenu = true; // whether a document should be selected after it's contextmenu is triggered.
/**
@@ -143,10 +143,10 @@ export class DocumentViewInternal extends DocComponent 0)) stopPropagate = false;
preventDefault = false;
}
- this._singleClickFunc = undoable(clickFunc ?? sendToBack ?? selectFunc, 'click: ' + this.Document.title);
+ this._singleClickFunc = undoable(clickFunc ?? sendToBack ?? selectFunc, 'click: ' + this.Document.$title);
const waitForDblClick = this._props.waitForDoubleClickToClick?.() ?? this.Document.waitForDoubleClickToClick;
if ((clickFunc && waitForDblClick !== 'never') || waitForDblClick === 'always') {
this._doubleClickTimeout && clearTimeout(this._doubleClickTimeout);
@@ -519,7 +519,7 @@ export class DocumentViewInternal extends DocComponent {
- if (this.Document.type !== DocumentType.MAP) DocumentViewInternal.SelectAfterContextMenu && this._props.select(false); // on a mac, the context menu is triggered on mouse down, but a YouTube video becaomes interactive when selected which means that the context menu won't show up. by delaying the selection until hopefully after the pointer up, the context menu will appear.
+ if (this.Document.$type !== DocumentType.MAP) DocumentViewInternal.SelectAfterContextMenu && this._props.select(false); // on a mac, the context menu is triggered on mouse down, but a YouTube video becaomes interactive when selected which means that the context menu won't show up. by delaying the selection until hopefully after the pointer up, the context menu will appear.
setTimeout(() => simulateMouseClick(document.elementFromPoint(e.clientX, e.clientY), e.clientX, e.clientY, e.screenX, e.screenY));
};
if (navigator.userAgent.includes('Macintosh')) {
@@ -545,7 +545,7 @@ export class DocumentViewInternal extends DocComponent (item.method ? item.method() : item.script?.script.run({ this: this.Document, documentView: this, scriptContext: this._props.scriptContext })), icon: item.icon as IconProp })
);
- if (!this.Document.isFolder) {
+ if (!this.Document.$isFolder) {
const templateDoc = Cast(this.Document[StrCast(this.Document.layout_fieldKey)], Doc, null);
const appearance = cm.findByDescription('Appearance...');
const appearanceItems = appearance?.subitems ?? [];
@@ -635,7 +635,7 @@ export class DocumentViewInternal extends DocComponent= 1 ? 0 : 1 / (1 + x * (viewXfScale - 1));
- const y = NumCast(this.Document.width) / viewXfScale / 200;
+ const y = NumCast(this.Document._width) / viewXfScale / 200;
const yscale = y >= 1 ? 0 : 1 / (1 + y * viewXfScale - 1);
return Math.max(xscale, yscale, 1 / viewXfScale);
}
@@ -735,7 +735,7 @@ export class DocumentViewInternal extends DocComponent
- {this._componentView?.isUnstyledView?.() || this.Document.type === DocumentType.CONFIG || !renderDoc ? renderDoc : DocumentViewInternal.AnimationEffect(renderDoc, this.Document[Animation], this.Document)}
+ {this._componentView?.isUnstyledView?.() || this.Document.$type === DocumentType.CONFIG || !renderDoc ? renderDoc : DocumentViewInternal.AnimationEffect(renderDoc, this.Document[Animation], this.Document)}
{jsx}
);
@@ -1210,7 +1210,7 @@ export class DocumentView extends DocComponent() {
}
@computed private get nativeScaling() {
if (this.shouldNotScale) return 1;
- const minTextScale = this.Document.type === DocumentType.RTF ? 0.1 : 0;
+ const minTextScale = this.Document.$type === DocumentType.RTF ? 0.1 : 0;
const ai = this._showAIEditor && this.nativeWidth === this.layoutDoc.width ? 95 : 0;
const effNW = Math.max(this.effectiveNativeWidth - ai, 1);
const effNH = Math.max(this.effectiveNativeHeight - ai, 1);
@@ -1325,7 +1325,7 @@ export class DocumentView extends DocComponent() {
public startDragging = (x: number, y: number, dropAction: dropActionType | undefined, hideSource = false) => this._docViewInternal?.startDragging(x, y, dropAction, hideSource);
public showContextMenu = (pageX: number, pageY: number) => this._docViewInternal?.onContextMenu(undefined, pageX, pageY);
- public toggleNativeDimensions = () => this._docViewInternal && this.Document.type !== DocumentType.INK && Doc.toggleNativeDimensions(this.layoutDoc, this.NativeDimScaling() ?? 1, this._props.PanelWidth(), this._props.PanelHeight());
+ public toggleNativeDimensions = () => this._docViewInternal && this.Document.$type !== DocumentType.INK && Doc.toggleNativeDimensions(this.layoutDoc, this.NativeDimScaling() ?? 1, this._props.PanelWidth(), this._props.PanelHeight());
public iconify(finished?: () => void, animateTime?: number) {
this.ComponentView?.updateIcon?.();
diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index 40c687b7e..9795febbe 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -54,16 +54,12 @@ export class KeyValueBox extends ViewBoxBaseComponent() {
@observable private rows: KeyValuePair[] = [];
@observable _splitPercentage = 50;
- get fieldDocToLayout() {
- return DocCast(this.Document);
- }
-
@action
onEnterKey = (e: React.KeyboardEvent): void => {
if (e.key === 'Enter') {
e.stopPropagation();
- if (this._keyInput.current?.value && this._valInput.current?.value && this.fieldDocToLayout) {
- if (KeyValueBox.SetField(this.fieldDocToLayout, this._keyInput.current.value, this._valInput.current.value)) {
+ if (this._keyInput.current?.value && this._valInput.current?.value && this._props.Document) {
+ if (KeyValueBox.SetField(this._props.Document, this._keyInput.current.value, this._valInput.current.value)) {
this._keyInput.current.value = '';
this._valInput.current.value = '';
document.body.focus();
@@ -114,7 +110,7 @@ export class KeyValueBox extends ViewBoxBaseComponent() {
if (key) target[key] = script.originalScript;
return false;
}
- field === undefined && (field = res.result instanceof Array ? new List(res.result) : (typeof res.result === 'function' ? res.result.name : res.result as FieldType));
+ field === undefined && (field = res.result instanceof Array ? new List(res.result) : typeof res.result === 'function' ? res.result.name : (res.result as FieldType));
}
}
if (!key) return false;
@@ -141,7 +137,7 @@ export class KeyValueBox extends ViewBoxBaseComponent() {
rowHeight = () => 30;
@computed get createTable() {
- const doc = this.fieldDocToLayout;
+ const doc = this._props.Document;
if (!doc) {
return (
@@ -149,25 +145,35 @@ export class KeyValueBox extends ViewBoxBaseComponent() {
);
}
- const realDoc = doc;
const ids: { [key: string]: string } = {};
const protos = Doc.GetAllPrototypes(doc);
protos.forEach(proto => {
Object.keys(proto).forEach(key => {
- if (!(key in ids) && realDoc[key] !== ComputedField.undefined) {
+ if (!(key in ids) && doc[key] !== ComputedField.undefined) {
ids[key] = key;
}
});
});
+ const layoutProtos = Doc.GetAllPrototypes(this.layoutDoc);
+ layoutProtos.forEach(proto => {
+ Object.keys(proto)
+ .map(key => '_' + key)
+ .forEach(key => {
+ if (!(key.replace(/^_/, '') in ids) && doc[key] !== ComputedField.undefined) {
+ ids[key] = key;
+ }
+ });
+ });
+
const rows: JSX.Element[] = [];
let i = 0;
const keys = Object.keys(ids).slice();
// for (const key of [...keys.filter(id => id !== 'layout' && !id.includes('_')).sort(), ...keys.filter(id => id === 'layout' || id.includes('_')).sort()]) {
const sortedKeys = keys.sort((a: string, b: string) => {
- const a_ = a.split('_')[0];
- const b_ = b.split('_')[0];
+ const a_ = a.replace(/^_/, '').split('_')[0];
+ const b_ = b.replace(/^_/, '').split('_')[0];
if (a_ < b_) return -1;
if (a_ > b_) return 1;
if (a === a_) return -1;
@@ -177,7 +183,7 @@ export class KeyValueBox extends ViewBoxBaseComponent() {
sortedKeys.forEach(key => {
rows.push(
() {
openItems.push({
description: 'Default Perspective',
event: () => {
- this._props.addDocTab(this.Document, OpenWhere.close);
- this._props.addDocTab(this.fieldDocToLayout, OpenWhere.addRight);
+ this._props.addDocTab(this._props.Document, OpenWhere.close);
+ this._props.addDocTab(this._props.Document, OpenWhere.addRight);
},
icon: 'image',
});
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx
index 85aff04c3..93f5231cb 100644
--- a/src/client/views/nodes/KeyValuePair.tsx
+++ b/src/client/views/nodes/KeyValuePair.tsx
@@ -61,17 +61,18 @@ export class KeyValuePair extends ObservableReactComponent {
render() {
// let fieldKey = Object.keys(props.Document).indexOf(props.fieldKey) !== -1 ? props.fieldKey : "(" + props.fieldKey + ")";
- let protoCount = 0;
- let { doc } = this._props;
+ const layoutField = this._props.keyName.startsWith('_');
+ let doc = layoutField ? Doc.Layout(this._props.doc) : this._props.doc;
+ let protoCount = doc !== this._props.doc && !layoutField ? 1 : 0;
while (doc) {
- if (Object.keys(doc).includes(this._props.keyName)) {
+ if (Object.keys(doc).includes(this._props.keyName.replace(/^_/, ''))) {
break;
}
protoCount++;
doc = DocCast(doc.proto);
}
- const parenCount = Math.max(0, protoCount - 1);
- const keyStyle = protoCount === 0 ? 'black' : 'blue';
+ const parenCount = Math.max(0, protoCount);
+ const keyStyle = protoCount === 0 && doc === this._props.doc ? 'black' : 'blue';
const hover = { transition: '0.3s ease opacity', opacity: this.isPointerOver || this.isChecked ? 1 : 0 };
@@ -99,10 +100,9 @@ export class KeyValuePair extends ObservableReactComponent {
pair[0].replace(/^_/, '') === this._props.keyName)?.[1].description ?? ''}>
-
- {'('.repeat(parenCount)}
- {this._props.keyName}
- {')'.repeat(parenCount)}
+
+ {(layoutField ? '_' : '$').repeat(parenCount)}
+ {(keyStyle === 'blue' && !layoutField && !parenCount ? '$' : '') + this._props.keyName}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index b84575389..9078648e9 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -245,9 +245,8 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent void = emptyFunction;
- const targetData = target[DocData];
- targetData.mediaState = mediaState.Recording;
- DictationManager.recordAudioAnnotation(targetData, Doc.LayoutFieldKey(target), stop => { stopFunc = stop }); // prettier-ignore
+ target.$mediaState = mediaState.Recording;
+ DictationManager.recordAudioAnnotation(target[DocData], Doc.LayoutFieldKey(target), stop => { stopFunc = stop }); // prettier-ignore
const reactionDisposer = reaction(
() => target.mediaState,
@@ -1067,7 +1066,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent ::$/, (state, match, start, end) => {
const creator = (doc: Doc) => {
- const textDoc = this.Document[DocData];
- const numInlines = NumCast(textDoc.inlineTextCount);
- textDoc.inlineTextCount = numInlines + 1;
+ const numInlines = NumCast(this.Document.$inlineTextCount);
+ this.Document.$inlineTextCount = numInlines + 1;
const node = state.doc.resolve(start).nodeAfter;
const newNode = schema.nodes.dashComment.create({ docId: doc[Id], reflow: false });
const dashDoc = schema.nodes.dashDoc.create({ width: 75, height: 35, title: 'dashDoc', docId: doc[Id], float: 'right' });
@@ -109,16 +108,15 @@ export class RichTextRules {
}),
// Create annotation to a field on the text document
new InputRule(/>>$/, (state, match, start, end) => {
- const textDoc = this.Document[DocData];
- const numInlines = NumCast(textDoc.inlineTextCount);
- textDoc.inlineTextCount = numInlines + 1;
- const inlineFieldKey = 'inline' + numInlines; // which field on the text document this annotation will write to
- const inlineLayoutKey = 'layout_' + inlineFieldKey; // the field holding the layout string that will render the inline annotation
+ const numInlines = NumCast(this.Document.$inlineTextCount);
+ this.Document.$inlineTextCount = numInlines + 1;
+ const inlineFieldKey = '$inline' + numInlines; // which field on the text document this annotation will write to
+ const inlineLayoutKey = '$layout_' + inlineFieldKey; // the field holding the layout string that will render the inline annotation
const textDocInline = Docs.Create.TextDocument('', {
_layout_fieldKey: inlineLayoutKey,
_width: 75,
_height: 35,
- annotationOn: textDoc,
+ annotationOn: this.Document[DocData],
_layout_fitWidth: true,
_layout_autoHeight: true,
text_fontSize: '9px',
@@ -128,9 +126,9 @@ export class RichTextRules {
textDocInline.title_custom = true; // And make sure that it's 'custom' so that editing text doesn't change the title of the containing doc
textDocInline.isTemplateForField = inlineFieldKey; // this is needed in case the containing text doc is converted to a template at some point
textDocInline.isDataDoc = true;
- textDocInline.proto = textDoc; // make the annotation inherit from the outer text doc so that it can resolve any nested field references, e.g., [[field]]
- textDoc[inlineLayoutKey] = FormattedTextBox.LayoutString(inlineFieldKey); // create a layout string for the layout key that will render the annotation text
- textDoc[inlineFieldKey] = ''; // set a default value for the annotation
+ textDocInline.proto = this.Document[DocData]; // make the annotation inherit from the outer text doc so that it can resolve any nested field references, e.g., [[field]]
+ this.Document[inlineLayoutKey] = FormattedTextBox.LayoutString(inlineFieldKey); // create a layout string for the layout key that will render the annotation text
+ this.Document[inlineFieldKey] = ''; // set a default value for the annotation
const node = state.doc.resolve(start).nodeAfter;
const newNode = schema.nodes.dashComment.create({ docId: textDocInline[Id], reflow: true });
const dashDoc = schema.nodes.dashDoc.create({ width: 75, height: 35, title: 'dashDoc', docId: textDocInline[Id], float: 'right' });
@@ -334,18 +332,14 @@ export class RichTextRules {
if (value?.includes(',') && !value.startsWith('((')) {
const values = value.split(',');
const strs = values.some(v => !v.match(/^[-]?[0-9.]$/));
- this.Document[DocData][fieldKey] = strs ? new List(values) : new List(values.map(v => Number(v)));
+ this.Document['$' + fieldKey] = strs ? new List(values) : new List(values.map(v => Number(v)));
} else if (value) {
Doc.SetField(
this.Document,
fieldKey,
assign + value,
Doc.IsDataProto(this.Document) ? true : undefined,
- assign.includes(':=')
- ? undefined
- : (gptval: FieldResult) => {
- (dataDoc ? this.Document[DocData] : this.Document)[fieldKey] = gptval as string;
- }
+ assign.includes(':=') ? undefined : (gptval: FieldResult) => (this.Document[(dataDoc ? '$' : '_') + fieldKey] = gptval as string)
);
if (fieldKey === this.TextBox.fieldKey) return this.TextBox.EditorView!.state.tr;
}
@@ -399,11 +393,11 @@ export class RichTextRules {
new InputRule(/#(@?[a-zA-Z_-]+[a-zA-Z_\-0-9]*)\s$/, (state, match, start, end) => {
const tag = match[1];
if (!tag) return state.tr;
- // this.Document[DocData]['#' + tag] = '#' + tag;
- const tags = StrListCast(this.Document[DocData].tags);
+ // this.Document[['$#' + tag] = '#' + tag;
+ const tags = StrListCast(this.Document.$tags);
if (!tags.includes(tag)) {
tags.push(tag);
- this.Document[DocData].tags = new List(tags);
+ this.Document.$tags = new List(tags);
this.Document._layout_showTags = true;
}
const fieldView = state.schema.nodes.dashField.create({ fieldKey: tag.startsWith('@') ? tag.replace(/^@/, '') : '#' + tag });
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index f818c6e20..ec97e067a 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -596,11 +596,11 @@ export class PresBox extends ViewBoxBaseComponent() {
}
if (pinDataTypes?.inkable || (!pinDataTypes && (activeItem.config_fillColor !== undefined || activeItem.color !== undefined))) {
if (bestTarget.fillColor !== activeItem.config_fillColor) {
- bestTarget[DocData].fillColor = StrCast(activeItem.config_fillColor, StrCast(bestTarget.fillColor));
+ bestTarget.$fillColor = StrCast(activeItem.config_fillColor, StrCast(bestTarget.fillColor));
changed = true;
}
if (bestTarget.color !== activeItem.config_color) {
- bestTarget[DocData].color = StrCast(activeItem.config_color, StrCast(bestTarget.color));
+ bestTarget.$color = StrCast(activeItem.config_color, StrCast(bestTarget.color));
changed = true;
}
if (bestTarget.width !== activeItem.width) {
@@ -669,7 +669,7 @@ export class PresBox extends ViewBoxBaseComponent() {
return doc;
});
const newList = new List([...oldItems, ...hiddenItems, ...newItems]);
- bestTarget[DocData][fkey + '_annotations'] = newList;
+ bestTarget['$' + fkey + '_annotations'] = newList;
}
if (pinDataTypes?.poslayoutview || (!pinDataTypes && activeItem.config_pinLayoutData !== undefined)) {
changed = true;
@@ -690,8 +690,8 @@ export class PresBox extends ViewBoxBaseComponent() {
data.fill && (doc._fillColor = data.fill);
doc._width = data.w;
doc._height = data.h;
- data.data && (doc[DocData].data = field);
- data.text && (doc[DocData].text = tfield);
+ data.data && (doc.$data = field);
+ data.text && (doc.$text = tfield);
Doc.AddDocToList(bestTarget[DocData], layoutField, doc);
}
});
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index dc7524bcd..2142adac8 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -431,7 +431,7 @@ export class PDFViewer extends ObservableReactComponent {
};
addDrawingAnnotation = (drawing: Doc) => {
- // drawing[DocData].x = this._props.pdfBox.ScreenToLocalBoxXf().TranslateX
+ // drawing.x = this._props.pdfBox.ScreenToLocalBoxXf().TranslateX
// const scaleX = this._mainCont.current.offsetWidth / boundingRect.width;
drawing.y = NumCast(drawing.y) + NumCast(this._props.Document.layout_scrollTop);
this._props.addDocument?.(drawing);
diff --git a/src/client/views/search/FaceRecognitionHandler.tsx b/src/client/views/search/FaceRecognitionHandler.tsx
index 6f70e96ab..841546a04 100644
--- a/src/client/views/search/FaceRecognitionHandler.tsx
+++ b/src/client/views/search/FaceRecognitionHandler.tsx
@@ -66,7 +66,7 @@ export class FaceRecognitionHandler {
* returns a list of all face collection Docs on the current dashboard
* @returns face collection Doc list
*/
- public static UniqueFaces = () => DocListCast(Doc.ActiveDashboard?.[DocData].myUniqueFaces);
+ public static UniqueFaces = () => DocListCast(Doc.ActiveDashboard?.$myUniqueFaces);
/**
* Find a unique face from its name
@@ -87,22 +87,22 @@ export class FaceRecognitionHandler {
* @param faceDoc unique face Doc
* @returns label string
*/
- public static UniqueFaceLabel = (faceDoc: Doc) => StrCast(faceDoc[DocData].face);
+ public static UniqueFaceLabel = (faceDoc: Doc) => StrCast(faceDoc.$face);
- public static SetUniqueFaceLabel = (faceDoc: Doc, value: string) => (faceDoc[DocData].face = value);
+ public static SetUniqueFaceLabel = (faceDoc: Doc, value: string) => (faceDoc.$face = value);
/**
* Returns all the face descriptors associated with a unique face Doc
* @param faceDoc unique face Doc
* @returns face descriptors
*/
- public static UniqueFaceDescriptors = (faceDoc: Doc) => DocListCast(faceDoc[DocData].face_annos).map(face => face.faceDescriptor as List);
+ public static UniqueFaceDescriptors = (faceDoc: Doc) => DocListCast(faceDoc.$face_annos).map(face => face.faceDescriptor as List);
/**
* Returns a list of all face image Docs associated with a unique face Doc
* @param faceDoc unique face Doc
* @returns image Docs
*/
- public static UniqueFaceImages = (faceDoc: Doc) => DocListCast(faceDoc[DocData].face_annos).map(face => DocCast(face.annotationOn, face));
+ public static UniqueFaceImages = (faceDoc: Doc) => DocListCast(faceDoc.$face_annos).map(face => DocCast(face.annotationOn, face));
/**
* Adds a face image to a unique face Doc, adds the unique face Doc to the images list of reognized faces,
@@ -145,8 +145,8 @@ export class FaceRecognitionHandler {
* @returns a unique face Doc
*/
private createUniqueFaceDoc = (dashboard: Doc) => {
- const faceDocNum = NumCast(dashboard[DocData].myUniqueFaces_count) + 1;
- dashboard[DocData].myUniqueFaces_count = faceDocNum; // TODO: improve to a better name
+ const faceDocNum = NumCast(dashboard.$myUniqueFaces_count) + 1;
+ dashboard.$myUniqueFaces_count = faceDocNum; // TODO: improve to a better name
const uniqueFaceDoc = Docs.Create.UniqeFaceDocument({
title: ComputedField.MakeFunction('this.face', undefined, undefined, 'this.face = value') as unknown as string,
@@ -160,9 +160,8 @@ export class FaceRecognitionHandler {
_width: 400,
_height: 100,
});
- const uface = uniqueFaceDoc[DocData];
- uface.face = `Face${faceDocNum}`;
- uface.face_annos = new List();
+ uniqueFaceDoc.$face = `Face${faceDocNum}`;
+ uniqueFaceDoc.$face_annos = new List();
Doc.SetContainer(uniqueFaceDoc, Doc.MyFaceCollection);
Doc.ActiveDashboard && Doc.AddDocToList(Doc.ActiveDashboard[DocData], 'myUniqueFaces', uniqueFaceDoc);
@@ -241,7 +240,7 @@ export class FaceRecognitionHandler {
annos.push(faceAnno);
});
- imgDoc[DocData].data_annotations = new List(annos);
+ imgDoc.$data_annotations = new List(annos);
imgDoc._layout_showTags = annos.length > 0;
return imgDocFaceDescriptions;
})
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index af98355d1..8b7e77fba 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -465,7 +465,6 @@ export class SearchBox extends ViewBoxBaseComponent() {
}
});
- // eslint-disable-next-line react/jsx-props-no-spreading
const recommendationsJSX: JSX.Element[] = []; // this._recommendations.map(props => );
return (
diff --git a/src/client/views/smartdraw/DrawingFillHandler.tsx b/src/client/views/smartdraw/DrawingFillHandler.tsx
index c672bc718..f1d5f2cfe 100644
--- a/src/client/views/smartdraw/DrawingFillHandler.tsx
+++ b/src/client/views/smartdraw/DrawingFillHandler.tsx
@@ -1,6 +1,5 @@
import { imageUrlToBase64 } from '../../../ClientUtils';
import { Doc, StrListCast } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { List } from '../../../fields/List';
import { DocCast, ImageCast } from '../../../fields/Types';
import { ImageField } from '../../../fields/URLField';
@@ -15,8 +14,7 @@ import { AspectRatioLimits, FireflyDimensionsMap, FireflyImageDimensions, Firefl
const DashDropboxId = '2m86iveqdr9vzsa';
export class DrawingFillHandler {
static drawingToImage = async (drawing: Doc, strength: number, user_prompt: string, styleDoc?: Doc) => {
- const docData = drawing[DocData];
- const tags = StrListCast(docData.tags).map(tag => tag.slice(1));
+ const tags = StrListCast(drawing.$tags).map(tag => tag.slice(1));
const styles = tags.filter(tag => FireflyStylePresets.has(tag));
const styleDocs = !Doc.Links(drawing).length
? styleDoc && !tags.length
@@ -47,7 +45,7 @@ export class DrawingFillHandler {
Networking.PostToServer('/queryFireflyImageFromStructure', { prompt: `${newPrompt}`, width: dims.width, height: dims.height, structureUrl, strength, presets: styles, styleUrl })
.then(res => {
const genratedDocs = DocCast(drawing.ai_firefly_generatedDocs) ?? Docs.Create.MasonryDocument([], { _width: 400, _height: 400 });
- drawing[DocData].ai_firefly_generatedDocs = genratedDocs;
+ drawing.$ai_firefly_generatedDocs = genratedDocs;
(res as Upload.ImageInformation[]).map(info =>
Doc.AddDocToList(
genratedDocs,
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index fc89dcbe7..f5bd4f44c 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -320,10 +320,11 @@ export class Doc extends RefField {
UpdatingFromServer,
Width,
'__LAYOUT__',
+ '__DATA__',
];
},
getOwnPropertyDescriptor: (target, prop) => {
- if (prop.toString() === '__LAYOUT__' || !(prop in target[FieldKeys])) {
+ if (prop.toString() === '__DATA__' || prop.toString() === '__LAYOUT__' || !(prop in target[FieldKeys])) {
return Reflect.getOwnPropertyDescriptor(target, prop);
}
return {
@@ -400,6 +401,9 @@ export class Doc extends RefField {
public [ToString] = () => `Doc(${GetEffectiveAcl(this[SelfProxy]) === AclPrivate ? '-inaccessible-' : this[SelfProxy].title})`;
public get [DocLayout]() { return this[SelfProxy].__LAYOUT__; } // prettier-ignore
public get [DocData](): Doc {
+ return this[SelfProxy].__DATA__;
+ }
+ @computed get __DATA__(): Doc {
const self = this[SelfProxy];
return self.resolvedDataDoc && !self.isTemplateForField ? self : Doc.GetProto(Cast(Doc.Layout(self).resolvedDataDoc, Doc, null) || self);
}
@@ -414,7 +418,7 @@ export class Doc extends RefField {
} else {
return Cast(layoutField, Doc, null);
}
- return Cast(self[renderFieldKey + '_layout[' + templateLayoutDoc[Id] + ']'], Doc, null) || templateLayoutDoc;
+ return Cast(self['layout_' + templateLayoutDoc.title + '(' + renderFieldKey + ')'], Doc, null) || templateLayoutDoc;
}
return undefined;
}
@@ -865,7 +869,7 @@ export namespace Doc {
// If it doesn't find the expanded layout, then it makes a delegate of the template layout and
// saves it on the data doc indexed by the template layout's id.
//
- const expandedLayoutFieldKey = templateField + '_layout[' + templateLayoutDoc[Id] + ']';
+ const expandedLayoutFieldKey = 'layout_' + templateLayoutDoc.title + '(' + templateField + ')';
let expandedTemplateLayout = targetDoc?.[expandedLayoutFieldKey];
if (templateLayoutDoc.resolvedDataDoc instanceof Promise) {
@@ -1152,7 +1156,9 @@ export namespace Doc {
// the document containing the view layout information - will be the Document itself unless the Document has
// a layout field or 'layout' is given.
export function Layout(doc: Doc, layout?: Doc): Doc {
- const overrideLayout = layout && Cast(doc[`${StrCast(layout.isTemplateForField, 'data')}_layout[` + layout[Id] + ']'], Doc, null);
+ const templateField = layout && StrCast(layout.isTemplateForField, Doc.LayoutFieldKey(layout)); // the field that the template renders
+ const overrideLayout = layout && Cast(doc[layout.title + '(' + templateField + ')'], Doc, null);
+ // [`${StrCast(layout.isTemplateForField, 'data')}_layout[` + layout[Id] + ']'], Doc, null);
return overrideLayout || doc[DocLayout] || doc;
}
export function SetLayout(doc: Doc, layout: Doc | string) {
diff --git a/src/fields/util.ts b/src/fields/util.ts
index 33764aca5..abbe543e8 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -314,6 +314,13 @@ export function setter(target: ListImpl | Doc, inProp: string | symbo
// 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].includes(value as SharingPermissions))) return true;
+ if (typeof prop === 'string' && prop !== '__id' && prop !== '__fieldTuples' && prop.startsWith('$')) {
+ prop = prop.substring(1);
+ if (target.__DATA__ instanceof Doc) {
+ target.__DATA__[prop] = value as FieldResult;
+ return true;
+ }
+ }
if (typeof prop === 'string' && prop !== '__id' && prop !== '__fieldTuples' && prop.startsWith('_')) {
if (!prop.startsWith('__')) prop = prop.substring(1);
if (target.__LAYOUT__ instanceof Doc) {
@@ -351,6 +358,7 @@ export function getter(target: Doc | ListImpl, prop: string | symbol,
case DocAcl : return target[DocAcl];
case $mobx: return target.__fieldTuples[prop];
case DocLayout: return target.__LAYOUT__;
+ case DocData: return target.__DATA__;
case Height: case Width: if (GetEffectiveAcl(target) === AclPrivate) return returnZero;
// eslint-disable-next-line no-fallthrough
default :
@@ -362,6 +370,8 @@ export function getter(target: Doc | ListImpl, prop: string | symbol,
const layoutProp = prop.startsWith('_') ? prop.substring(1) : undefined;
if (layoutProp && target.__LAYOUT__) return (target.__LAYOUT__ as Doc)[layoutProp];
+ const dataProp = prop.startsWith('$') ? prop.substring(1) : undefined;
+ if (dataProp && target.__DATA__) return (target.__DATA__ as Doc)[dataProp];
return getFieldImpl(target, layoutProp ?? prop, proxy);
}
--
cgit v1.2.3-70-g09d2
From bc308b888f41e8789f1b9f522ced46e68e726862 Mon Sep 17 00:00:00 2001
From: bobzel
Date: Fri, 21 Mar 2025 19:24:06 -0400
Subject: from last
---
src/client/documents/DocUtils.ts | 4 ++--
src/client/util/CalendarManager.tsx | 5 +++--
src/client/util/CurrentUserUtils.ts | 4 ++--
src/client/views/DocComponent.tsx | 2 +-
src/client/views/PinFuncs.ts | 4 ++--
src/client/views/PropertiesButtons.tsx | 2 +-
src/client/views/PropertiesView.tsx | 2 +-
src/client/views/nodes/DocumentView.tsx | 8 ++++----
src/fields/Doc.ts | 4 +---
9 files changed, 17 insertions(+), 18 deletions(-)
(limited to 'src/client/util')
diff --git a/src/client/documents/DocUtils.ts b/src/client/documents/DocUtils.ts
index 13f6f6920..b0170a192 100644
--- a/src/client/documents/DocUtils.ts
+++ b/src/client/documents/DocUtils.ts
@@ -383,8 +383,8 @@ export namespace DocUtils {
const newDoc = DocUtils.copyDragFactory(dragDoc);
if (newDoc) {
newDoc._author = ClientUtils.CurrentUserEmail();
- newDoc._x = x;
- newDoc._y = y;
+ newDoc.x = x;
+ newDoc.y = y;
newDoc.$backgroundColor = Doc.UserDoc().textBackgroundColor;
DocumentView.SetSelectOnLoad(newDoc);
if (pivotField) {
diff --git a/src/client/util/CalendarManager.tsx b/src/client/util/CalendarManager.tsx
index a0db4e32e..3357e5d59 100644
--- a/src/client/util/CalendarManager.tsx
+++ b/src/client/util/CalendarManager.tsx
@@ -17,6 +17,7 @@ import { TaskCompletionBox } from '../views/nodes/TaskCompletedBox';
import './CalendarManager.scss';
import { SnappingManager } from './SnappingManager';
import { CalendarDate, DateValue } from '@internationalized/date';
+import { DocData } from '../../fields/DocSymbols';
// import 'react-date-range/dist/styles.css';
// import 'react-date-range/dist/theme/default.css';
@@ -118,7 +119,7 @@ export class CalendarManager extends ObservableReactComponent {
// TODO: Make undoable
private addToCalendar = () => {
const docs = DocumentView.Selected().length < 2 ? [this.targetDoc] : DocumentView.Selected().map(docView => docView.Document);
- const targetDoc = docs[0]; // doc to add to calendar
+ const targetDoc = docs[0]?.[DocData];
if (targetDoc) {
let calendar: Doc;
@@ -229,7 +230,7 @@ export class CalendarManager extends ObservableReactComponent {
@computed
get calendarInterface() {
const docs = DocumentView.Selected().length < 2 ? [this.targetDoc] : DocumentView.Selected().map(docView => docView.Document);
- const targetDoc = docs[0];
+ const targetDoc = docs[0]?.[DocData];
return (
`;
slide.$type_collection = CollectionViewType.Freeform;
- slide._onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
+ slide.onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
return slide;
}
const mermaidsApi = () => {
@@ -376,7 +376,7 @@ pie title Minerals in my tap water
slide.$text = rtfield;
slide.$layout_textPainted = `
`;
slide.$_type_collection = CollectionViewType.Freeform;
- slide._onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
+ slide.onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
return slide;
}
plotlyApi(); mermaidsApi();
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 064906530..79a0cc602 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -42,7 +42,7 @@ export function DocComponent() {
* This is the document being rendered. It may be a template so it may or may no inherit from the data doc.
*/
@computed get layoutDoc() {
- return this._props.LayoutTemplateString ? this.Document : Doc.Layout(this._props.Document, this._props.LayoutTemplate?.());
+ return this._props.LayoutTemplateString ? this._props.Document : Doc.Layout(this._props.Document, this._props.LayoutTemplate?.());
}
/**
diff --git a/src/client/views/PinFuncs.ts b/src/client/views/PinFuncs.ts
index 1ab8575a8..d756830da 100644
--- a/src/client/views/PinFuncs.ts
+++ b/src/client/views/PinFuncs.ts
@@ -76,8 +76,8 @@ export function PinDocView(pinDocIn: Doc, pinProps: PinProps, targetDoc: Doc) {
pinDoc.config_data = Field.Copy(targetDoc[fkey]);
}
if (pinProps.pinData.dataannos) {
- const fieldKey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.config_annotations = new List(DocListCast(targetDoc['$' + fieldKey + '_annotations']).filter(doc => !doc.layout_unrendered));
+ const fieldKey = '$' + Doc.LayoutFieldKey(targetDoc) + +'_annotations';
+ pinDoc.config_annotations = new List(DocListCast(targetDoc[fieldKey]).filter(doc => !doc.layout_unrendered));
}
if (pinProps.pinData.inkable) {
pinDoc.config_fillColor = targetDoc.fillColor;
diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx
index 2b4fe478e..a1e8fe7ba 100644
--- a/src/client/views/PropertiesButtons.tsx
+++ b/src/client/views/PropertiesButtons.tsx
@@ -131,7 +131,7 @@ export class PropertiesButtons extends React.Component {
on => `${on ? 'Flashcard enabled' : 'Flashcard disabled'} `,
() => ,
(dv, doc) => {
- const on = !!doc.onPaint;
+ const on = !!doc.$onPaint;
doc.$onPaint = on ? undefined : ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, { documentView: 'any' });
doc.$layout_textPainted = on ? undefined : ` `;
}
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index c72f958fc..b95553c4e 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -891,7 +891,7 @@ export class PropertiesView extends ObservableReactComponent {
doc.$color = value || undefined;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index fdaf13733..46bd076d4 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -143,10 +143,10 @@ export class DocumentViewInternal extends DocComponent
Date: Sun, 23 Mar 2025 10:27:28 -0400
Subject: updated more [DocData] to .$ things
---
src/client/util/CalendarManager.tsx | 5 +--
src/client/util/LinkManager.ts | 6 +--
src/client/views/DocComponent.tsx | 9 ++--
src/client/views/PropertiesDocContextSelector.tsx | 2 +-
src/client/views/PropertiesView.tsx | 8 +---
src/client/views/SidebarAnnos.tsx | 9 ++--
src/client/views/StyleProviderQuiz.tsx | 8 ++--
src/client/views/TagsView.tsx | 33 +++++++--------
.../views/collections/CollectionDockingView.tsx | 6 +--
.../collections/CollectionMasonryViewFieldRow.tsx | 3 +-
src/client/views/collections/CollectionMenu.tsx | 3 +-
.../views/collections/CollectionNoteTakingView.tsx | 2 +-
.../collections/CollectionNoteTakingViewColumn.tsx | 2 +-
.../collections/CollectionStackedTimeline.tsx | 8 ++--
.../views/collections/CollectionStackingView.tsx | 5 +--
src/client/views/collections/CollectionSubView.tsx | 12 +++++-
src/client/views/collections/TabDocView.tsx | 2 +-
src/client/views/collections/TreeView.tsx | 5 +--
.../CollectionFreeFormInfoUI.tsx | 11 +++--
.../collectionFreeForm/CollectionFreeFormView.tsx | 25 ++++++-----
.../collectionFreeForm/FaceCollectionBox.tsx | 4 +-
.../collectionFreeForm/ImageLabelBox.tsx | 19 ++++-----
.../collections/collectionFreeForm/MarqueeView.tsx | 19 ++++-----
src/client/views/global/globalScripts.ts | 49 +++++++++-------------
src/client/views/nodes/AudioBox.tsx | 2 +-
src/client/views/nodes/ComparisonBox.tsx | 10 ++---
.../views/nodes/DataVizBox/components/TableBox.tsx | 4 +-
src/client/views/nodes/DiagramBox.tsx | 5 +--
src/client/views/nodes/DocumentView.tsx | 14 +++----
src/client/views/nodes/ImageBox.tsx | 42 +++++++++----------
src/client/views/nodes/KeyValueBox.tsx | 2 +-
src/client/views/nodes/LinkBox.tsx | 6 +--
src/client/views/nodes/LinkDescriptionPopup.tsx | 3 +-
src/client/views/nodes/PDFBox.tsx | 17 ++++----
.../views/nodes/RecordingBox/RecordingBox.tsx | 3 +-
src/client/views/nodes/VideoBox.tsx | 48 ++++++++++-----------
src/client/views/nodes/calendarBox/CalendarBox.tsx | 2 +-
.../nodes/chatbot/chatboxcomponents/ChatBox.tsx | 6 +--
.../views/nodes/formattedText/EquationView.tsx | 5 +--
src/client/views/nodes/imageEditor/ImageEditor.tsx | 9 ++--
src/client/views/nodes/trails/PresBox.tsx | 9 ++--
src/client/views/smartdraw/SmartDrawHandler.tsx | 21 +++++-----
src/client/views/smartdraw/StickerPalette.tsx | 28 ++++++-------
src/fields/Doc.ts | 25 ++++++-----
src/fields/ScriptField.ts | 3 +-
45 files changed, 243 insertions(+), 276 deletions(-)
(limited to 'src/client/util')
diff --git a/src/client/util/CalendarManager.tsx b/src/client/util/CalendarManager.tsx
index 3357e5d59..1a5a5f889 100644
--- a/src/client/util/CalendarManager.tsx
+++ b/src/client/util/CalendarManager.tsx
@@ -17,7 +17,6 @@ import { TaskCompletionBox } from '../views/nodes/TaskCompletedBox';
import './CalendarManager.scss';
import { SnappingManager } from './SnappingManager';
import { CalendarDate, DateValue } from '@internationalized/date';
-import { DocData } from '../../fields/DocSymbols';
// import 'react-date-range/dist/styles.css';
// import 'react-date-range/dist/theme/default.css';
@@ -119,7 +118,7 @@ export class CalendarManager extends ObservableReactComponent {
// TODO: Make undoable
private addToCalendar = () => {
const docs = DocumentView.Selected().length < 2 ? [this.targetDoc] : DocumentView.Selected().map(docView => docView.Document);
- const targetDoc = docs[0]?.[DocData];
+ const targetDoc = docs[0];
if (targetDoc) {
let calendar: Doc;
@@ -230,7 +229,7 @@ export class CalendarManager extends ObservableReactComponent {
@computed
get calendarInterface() {
const docs = DocumentView.Selected().length < 2 ? [this.targetDoc] : DocumentView.Selected().map(docView => docView.Document);
- const targetDoc = docs[0]?.[DocData];
+ const targetDoc = docs[0];
return (
!Doc.IsSystem(doc));
+ // const strings = isFiltered.map(doc => StrCast(doc.title) + ' ' + (Doc.IsDataProto(doc) ? '(data)' : '(embedding)'));
//Doc.MyDockedBtns.linearView_IsOpen && strings.sort().forEach((str, i) => console.log(i.toString() + ' ' + str));
rp.post(ClientUtils.prepend('/setCacheDocumentIds'), {
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 79a0cc602..a311f6436 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -49,7 +49,7 @@ export function DocComponent
() {
* This is the unique data repository for a dcoument that stores the intrinsic document data
*/
@computed get dataDoc() {
- return this.Document[DocData];
+ return this._props.Document[DocData];
}
}
return Component;
@@ -93,7 +93,7 @@ export function ViewBoxBaseComponent
() {
* This is the unique data repository for a dcoument that stores the intrinsic document data
*/
@computed get dataDoc() {
- return this.Document.isTemplateForField || this.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this.Document[DocData]) : this.Document[DocData];
+ return this._props.Document.isTemplateForField || this._props.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._props.Document[DocData]) : this._props.Document[DocData];
}
/**
@@ -151,7 +151,7 @@ export function ViewBoxAnnotatableComponent
() {
* This is the unique data repository for a dcoument that stores the intrinsic document data
*/
@computed get dataDoc() {
- return this.Document.isTemplateForField || this.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this.Document[DocData]) : this.Document[DocData];
+ return this._props.Document.isTemplateForField || this._props.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._props.Document[DocData]) : this._props.Document[DocData];
}
/**
@@ -225,8 +225,7 @@ export function ViewBoxAnnotatableComponent
() {
if ([AclAugment, AclEdit, AclAdmin].includes(effectiveAcl)) {
added.forEach(adoc => {
adoc._dragOnlyWithinContainer = undefined;
- if (annotationKey ?? this._annotationKeySuffix()) adoc[DocData].annotationOn = this.Document;
- else adoc[DocData].annotationOn = undefined;
+ adoc.$annotationOn = (annotationKey ?? this._annotationKeySuffix()) ? this.Document : undefined;
Doc.SetContainer(adoc, this.Document);
inheritParentAcls(targetDataDoc, adoc, true);
});
diff --git a/src/client/views/PropertiesDocContextSelector.tsx b/src/client/views/PropertiesDocContextSelector.tsx
index f494ff16a..ee6486a9c 100644
--- a/src/client/views/PropertiesDocContextSelector.tsx
+++ b/src/client/views/PropertiesDocContextSelector.tsx
@@ -26,7 +26,7 @@ export class PropertiesDocContextSelector extends ObservableReactComponent embedding.embedContainer && embedding.embedContainer instanceof Doc).reduce((set, embedding) => set.add(Cast(embedding.embedContainer, Doc, null)), new Set());
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index b95553c4e..7e9cd002b 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -181,7 +181,7 @@ export class PropertiesView extends ObservableReactComponent {
const layoutDoc = this.selectedLayoutDoc;
- if (layoutDoc && this.dataDoc) {
+ if (layoutDoc) {
return Math.max(
70,
Math.min(
@@ -308,11 +308,7 @@ export class PropertiesView extends ObservableReactComponent data.split(':')[0])
.filter(data => !filterExlusions?.includes(data.split(':')[0]))
.map(data => {
- const key = data.split(':')[0];
+ const key = '$'+data.split(':')[0];
const val = Field.Copy(this.allMetadata.get(key));
- target[DocData][key] = val;
+ target[key] = val;
return {
type: 'dashField',
attrs: { fieldKey: key, docId: '', hideKey: false, hideValue: false, editable: true },
@@ -98,7 +97,7 @@ export class SidebarAnnos extends ObservableReactComponent {
- const input = StrCast(doc[DocData].title);
+ const input = StrCast(doc.$title);
if (imgQuizMode(img) == quizMode.SMART && input) {
const questionText = 'Question: What was labeled in this image?';
const rubricText = ' Rubric: ' + StrCast(doc.quiz);
@@ -275,8 +275,8 @@ export namespace styleProviderQuiz {
function redo(img: ImageBox) {
imgQuizBoxes(img).forEach(doc => {
- doc[DocData].title = '';
- doc.backgroundColor = '#e4e4e4';
+ doc.$title = '';
+ doc.$backgroundColor = '#e4e4e4';
});
}
diff --git a/src/client/views/TagsView.tsx b/src/client/views/TagsView.tsx
index 93d6fb684..7d2a6be5e 100644
--- a/src/client/views/TagsView.tsx
+++ b/src/client/views/TagsView.tsx
@@ -72,7 +72,7 @@ export class TagItem extends ObservableReactComponent {
const newTagCol = new Doc();
newTagCol.title = tag;
newTagCol.collections = new List();
- newTagCol[DocData].docs = new List();
+ newTagCol.$docs = new List();
Doc.ActiveDashboard && Doc.AddDocToList(Doc.ActiveDashboard, 'myTagCollections', newTagCol);
return newTagCol;
@@ -82,7 +82,7 @@ export class TagItem extends ObservableReactComponent {
* @param tag tag string
* @returns An array of documents that contain the tag.
*/
- public static allDocsWithTag = (tag: string) => DocListCast(TagItem.findTagCollectionDoc(tag)?.[DocData].docs);
+ public static allDocsWithTag = (tag: string) => DocListCast(TagItem.findTagCollectionDoc(tag)?.$docs);
public static docHasTag = (doc: Doc, tag: string) => StrListCast(doc?.tags).includes(tag);
/**
@@ -95,11 +95,11 @@ export class TagItem extends ObservableReactComponent {
// If the document is of type COLLECTION, make it a smart collection, otherwise, add the tag to the document.
if (doc.type === DocumentType.COL && !doc.annotationOn) {
- Doc.AddDocToList(tagCollection[DocData], 'collections', doc);
+ Doc.AddDocToList(tagCollection, 'collections', doc);
// Iterate through the tag Doc collections and add a copy of the document to each collection
- for (const cdoc of DocListCast(tagCollection[DocData].docs)) {
- if (!DocListCast(doc[DocData].data).find(d => Doc.AreProtosEqual(d, cdoc))) {
+ for (const cdoc of DocListCast(tagCollection.$docs)) {
+ if (!DocListCast(doc.$data).find(d => Doc.AreProtosEqual(d, cdoc))) {
const newEmbedding = Doc.MakeEmbedding(cdoc);
Doc.AddDocToList(doc[DocData], 'data', newEmbedding);
Doc.SetContainer(newEmbedding, doc);
@@ -111,7 +111,7 @@ export class TagItem extends ObservableReactComponent {
// Iterate through the tag document's collections and add a copy of the document to each collection
for (const collection of DocListCast(tagCollection.collections)) {
- if (!DocListCast(collection[DocData].data).find(d => Doc.AreProtosEqual(d, doc))) {
+ if (!DocListCast(collection.$data).find(d => Doc.AreProtosEqual(d, doc))) {
const newEmbedding = Doc.MakeEmbedding(doc);
Doc.AddDocToList(collection[DocData], 'data', newEmbedding);
Doc.SetContainer(newEmbedding, collection);
@@ -119,8 +119,8 @@ export class TagItem extends ObservableReactComponent {
}
}
- if (!doc[DocData].tags) doc[DocData].tags = new List();
- const tagList = doc[DocData].tags as List;
+ if (!doc.$tags) doc.$tags = new List();
+ const tagList = doc.$tags as List;
if (!tagList.includes(tag)) tagList.push(tag);
};
@@ -131,22 +131,22 @@ export class TagItem extends ObservableReactComponent {
* @param tagDoc doc that collections the Docs with the tag
*/
public static removeTagFromDoc = (doc: Doc, tag: string, tagDoc?: Doc) => {
- if (doc[DocData].tags) {
+ if (doc.$tags) {
if (doc.type === DocumentType.COL) {
tagDoc && Doc.RemoveDocFromList(tagDoc[DocData], 'collections', doc);
for (const cur_doc of TagItem.allDocsWithTag(tag)) {
- doc[DocData].data = new List(DocListCast(doc[DocData].data).filter(d => !Doc.AreProtosEqual(cur_doc, d)));
+ doc.$data = new List(DocListCast(doc.$data).filter(d => !Doc.AreProtosEqual(cur_doc, d)));
}
} else {
tagDoc && Doc.RemoveDocFromList(tagDoc[DocData], 'docs', doc);
for (const collection of DocListCast(tagDoc?.collections)) {
- collection[DocData].data = new List(DocListCast(collection[DocData].data).filter(d => !Doc.AreProtosEqual(doc, d)));
+ collection.$data = new List(DocListCast(collection.$data).filter(d => !Doc.AreProtosEqual(doc, d)));
}
}
}
- doc[DocData].tags = new List(StrListCast(doc[DocData].tags).filter(label => label !== tag));
+ doc.$tags = new List(StrListCast(doc.$tags).filter(label => label !== tag));
};
private _ref: React.RefObject;
@@ -171,11 +171,10 @@ export class TagItem extends ObservableReactComponent {
// Create a new collection and set up configurations.
const newCollection = ((doc: Doc) => {
- const docData = doc[DocData];
- docData.data = new List(newEmbeddings);
- docData.title = this._props.tag;
- docData.tags = new List([this._props.tag]);
- docData.freeform_fitContentsToBox = true;
+ doc.$data = new List(newEmbeddings);
+ doc.$title = this._props.tag;
+ doc.$tags = new List([this._props.tag]);
+ doc.$freeform_fitContentsToBox = true;
doc._freeform_panX = doc._freeform_panY = 0;
doc._width = 900;
doc._height = 900;
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index a45b37f43..12a131deb 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -5,7 +5,7 @@ import * as ReactDOM from 'react-dom/client';
import ResizeObserver from 'resize-observer-polyfill';
import { addStyleSheet, addStyleSheetRule, clearStyleSheetRules, DivHeight, DivWidth, incrementTitleCopy, returnTrue, UpdateIcon } from '../../../ClientUtils';
import { Doc, DocListCast, Field, Opt } from '../../../fields/Doc';
-import { AclAdmin, AclEdit, DocData } from '../../../fields/DocSymbols';
+import { AclAdmin, AclEdit } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { InkTool } from '../../../fields/InkField';
import { List } from '../../../fields/List';
@@ -481,7 +481,7 @@ export class CollectionDockingView extends CollectionSubView() {
Array.from(cloned.map.entries()).forEach(entry => {
json = json.replace(entry[0], entry[1][Id]);
});
- cloned.clone[DocData].dockingConfig = json;
+ cloned.clone.$dockingConfig = json;
return DashboardView.openDashboard(cloned.clone);
}
const matches = json.match(/"documentId":"[a-z0-9-]+"/g);
@@ -495,7 +495,7 @@ export class CollectionDockingView extends CollectionSubView() {
const newtab = origtabdocs.length ? Doc.MakeCopy(origtab, true, undefined, true) : Doc.MakeEmbedding(origtab);
const newtabdocs = origtabdocs.map(origtabdoc => Doc.MakeEmbedding(origtabdoc));
if (newtabdocs.length) {
- newtab[DocData].data = new List(newtabdocs);
+ newtab.$data = new List(newtabdocs);
newtabdocs.forEach(ntab => Doc.SetContainer(ntab, newtab));
}
json = json.replace(origtab[Id], newtab[Id]);
diff --git a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
index 996626575..4fe73895e 100644
--- a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
+++ b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
@@ -5,7 +5,6 @@ import * as React from 'react';
import { returnEmptyString, returnFalse, setupMoveUpEvents } from '../../../ClientUtils';
import { emptyFunction, numberRange } from '../../../Utils';
import { Doc } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { PastelSchemaPalette, SchemaHeaderField } from '../../../fields/SchemaHeaderField';
import { ScriptField } from '../../../fields/ScriptField';
import { Docs } from '../../documents/Documents';
@@ -164,7 +163,7 @@ export class CollectionMasonryViewFieldRow extends ObservableReactComponent {
- this.target[DocData].data = new List(source);
+ this.target.$data = new List(source);
}, ''),
initialize: emptyFunction,
};
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index c499bd288..4650727eb 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -441,7 +441,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
if ((e.ctrlKey || fieldProps.Document._createDocOnCR) && ['Enter'].includes(e.key)) {
e.stopPropagation?.();
const newDoc = Doc.MakeCopy(fieldProps.Document, true);
- newDoc[DocData].text = undefined;
+ newDoc.$text = undefined;
DocumentView.SetSelectOnLoad(newDoc);
return this.addDocument?.(newDoc);
}
diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index 40b3f9ef2..df9b5a1eb 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -157,7 +157,7 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent {
const colHdrData = Array.from(Cast(this._props.Document[this._props.fieldKey + '_columnHeaders'], listSpec(SchemaHeaderField), null));
if (this._props.headingObject) {
- // this._props.docList.forEach(d => (d[DocData][this._props.pivotField] = undefined));
+ // this._props.docList.forEach(d => (d['$'+this._props.pivotField] = undefined));
colHdrData.splice(colHdrData.indexOf(this._props.headingObject), 1);
this._props.resizeColumns(colHdrData);
}
diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx
index a7a9f2114..0836cce38 100644
--- a/src/client/views/collections/CollectionStackedTimeline.tsx
+++ b/src/client/views/collections/CollectionStackedTimeline.tsx
@@ -432,8 +432,8 @@ export class CollectionStackedTimeline extends CollectionSubView {
- this._props.mark[DocData].title = ComputedField.MakeFunction(
- `["${this._props.endTag}"] ? "#" + formatToTime(this["${this._props.startTag}"]) + "-" + formatToTime(this["${this._props.endTag}"]) : "#" + formatToTime(this["${this._props.startTag}"]`
- );
+ this._props.mark.$title = ComputedField.MakeFunction(`["${this._props.endTag}"] ? "#" + formatToTime(this["${this._props.startTag}"]) + "-" + formatToTime(this["${this._props.endTag}"]) : "#" + formatToTime(this["${this._props.startTag}"]`);
};
// context menu
contextMenuItems = () => {
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 392d85af3..9972fe03d 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -5,7 +5,6 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { ClientUtils, DivHeight, returnNone, returnZero, setupMoveUpEvents, smoothScroll } from '../../../ClientUtils';
import { Doc, Opt } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { List } from '../../../fields/List';
import { listSpec } from '../../../fields/Schema';
@@ -316,11 +315,11 @@ export class CollectionStackingView extends CollectionSubView([]) : undefined;
+ newDoc['$' + Doc.LayoutFieldKey(newDoc)] = dataField === undefined || Cast(dataField, listSpec(Doc), null)?.length !== undefined ? new List([]) : undefined;
if (layoutFieldKey !== 'layout' && fieldProps.Document[layoutFieldKey] instanceof Doc) {
newDoc[layoutFieldKey] = fieldProps.Document[layoutFieldKey];
}
- newDoc[DocData].text = undefined;
+ newDoc.$text = undefined;
DocumentView.SetSelectOnLoad(newDoc);
return this.addDocument?.(newDoc);
}
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 655894e40..29caead5b 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -9,7 +9,7 @@ import { Id } from '../../../fields/FieldSymbols';
import { List } from '../../../fields/List';
import { listSpec } from '../../../fields/Schema';
import { ScriptField } from '../../../fields/ScriptField';
-import { BoolCast, Cast, DateCast, NumCast, ScriptCast, StrCast, toList } from '../../../fields/Types';
+import { BoolCast, Cast, DateCast, DocCast, NumCast, ScriptCast, StrCast, toList } from '../../../fields/Types';
import { WebField } from '../../../fields/URLField';
import { GetEffectiveAcl, TraceMobx } from '../../../fields/util';
import { GestureUtils } from '../../../pen-gestures/GestureUtils';
@@ -85,6 +85,9 @@ export function CollectionSubView() {
constructor(props: X & SubCollectionViewProps) {
super(props);
makeObservable(this);
+ console.log(`propsTitle: ${this._props.Document.title} DocTitle: ${this.Document.title} LayoutTitle:${this.layoutDoc.title} DataTitle:${this.dataDoc.title}`);
+ console.log(`tempTitle: ${this._props.TemplateDataDocument?.title} LayouTResolve: ${DocCast(this.layoutDoc.resolvedDataDoc)?.title} propDocResolve: ${DocCast(this._props.Document.resolvedDataDoc)?.title}`);
+ console.log('Children:', this.childDocs, this.childLayoutPairs);
}
@observable _focusFilters: Opt = undefined; // childFilters that are overridden when previewing a link to an anchor which has childFilters set on it
@@ -108,7 +111,12 @@ export function CollectionSubView() {
}
get dataDoc() {
- return this._props.TemplateDataDocument instanceof Doc && this.Document.isTemplateForField ? Doc.GetProto(this._props.TemplateDataDocument) : this.Document.resolvedDataDoc ? this.Document : this.Document[DocData]; // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template
+ console.log(this._props.Document.title + ' isTemplate: ' + this.layoutDoc.isTemplateForField);
+ return this._props.TemplateDataDocument instanceof Doc && this.layoutDoc.isTemplateForField //
+ ? this._props.TemplateDataDocument[DocData]
+ : this.layoutDoc.resolvedDataDoc
+ ? this._props.Document
+ : this.Document[DocData]; // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template
}
get childContainerViewPath() {
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index cc56a8ff9..2d2c0fce5 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -347,7 +347,7 @@ export class TabDocView extends ObservableReactComponent {
undoable(() => {
const target = e.currentTarget as unknown as { value: string };
titleEle.size = target?.value.length + 3;
- doc[DocData].title = target?.value ?? '';
+ doc.$title = target?.value ?? '';
}, 'edit tab title')();
};
diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx
index 6208905fe..d6a19e88e 100644
--- a/src/client/views/collections/TreeView.tsx
+++ b/src/client/views/collections/TreeView.tsx
@@ -372,9 +372,8 @@ export class TreeView extends ObservableReactComponent {
_width: 1000,
_height: 10,
});
- const bulletData = bullet[DocData];
- bulletData.title = ComputedField.MakeFunction('this.text?.Text');
- bulletData.data = new List([]);
+ bullet.$title = ComputedField.MakeFunction('this.text?.Text');
+ bullet.$data = new List([]);
DocumentView.addViewRenderedCb(bullet, dv => dv.ComponentView?.setFocus?.());
return bullet;
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
index 8b9a3e0ec..35c6d30fe 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
@@ -1,16 +1,15 @@
import { makeObservable, observable, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
-import { Doc, DocListCast, FieldType, FieldResult } from '../../../../fields/Doc';
+import { Doc, DocListCast, FieldResult, FieldType } from '../../../../fields/Doc';
import { InkTool } from '../../../../fields/InkField';
import { StrCast } from '../../../../fields/Types';
import { ObservableReactComponent } from '../../ObservableReactComponent';
import { DocButtonState, DocumentLinksButton } from '../../nodes/DocumentLinksButton';
import { TopBar } from '../../topbar/TopBar';
import { CollectionFreeFormInfoState, InfoState, StateEntryFunc, infoState } from './CollectionFreeFormInfoState';
-import './CollectionFreeFormView.scss';
-import { DocData } from '../../../../fields/DocSymbols';
import { CollectionFreeFormView } from './CollectionFreeFormView';
+import './CollectionFreeFormView.scss';
export interface CollectionFreeFormInfoUIProps {
Document: Doc;
@@ -41,7 +40,7 @@ export class CollectionFreeFormInfoUI extends ObservableReactComponent {this._currState = val;}); } // prettier-ignore
componentWillUnmount(): void {
- this._props.Document[DocData].backgroundColor = this._originalbackground;
+ this._props.Document.$backgroundColor = this._originalbackground;
}
setCurrState = (state: infoState) => {
@@ -52,9 +51,9 @@ export class CollectionFreeFormInfoUI extends ObservableReactComponent {
- this._originalbackground = StrCast(this._props.Document[DocData].backgroundColor);
+ this._originalbackground = StrCast(this._props.Document.$backgroundColor);
// state entry functions
- // const setBackground = (colour: string) => () => {this._props.Document[DocData].backgroundColor = colour;} // prettier-ignore
+ // const setBackground = (colour: string) => () => {this._props.Document.$backgroundColor = colour;} // prettier-ignore
// const setOpacity = (opacity: number) => () => {this._props.LayoutDoc.opacity = opacity;} // prettier-ignore
// arc transition trigger conditions
const firstDoc = () => (this._props.childDocs().length ? this._props.childDocs()[0] : undefined);
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 89aa53c35..6030e146c 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -561,7 +561,7 @@ export class CollectionFreeFormView extends CollectionSubView {
- inkDoc[DocData][field] = stroke.dataDoc[field];
+ inkDoc['$' + field] = stroke.dataDoc[field];
});
this.addDocument(inkDoc);
});
@@ -1260,15 +1260,14 @@ export class CollectionFreeFormView extends CollectionSubView {
- const docData = doc[DocData];
- docData.title = opts.text;
- docData._width = opts.size;
- docData.ai_drawing_input = opts.text;
- docData.ai_drawing_complexity = opts.complexity;
- docData.ai_drawing_colored = opts.autoColor;
- docData.ai_drawing_size = opts.size;
- docData.ai_drawing_data = gptRes;
- docData.ai = 'gpt';
+ doc.$title = opts.text;
+ doc.$width = opts.size;
+ doc.$ai_drawing_input = opts.text;
+ doc.$ai_drawing_complexity = opts.complexity;
+ doc.$ai_drawing_colored = opts.autoColor;
+ doc.$ai_drawing_size = opts.size;
+ doc.$ai_drawing_data = gptRes;
+ doc.$ai = 'gpt';
this._drawingContainer = doc;
if (x !== undefined && y !== undefined) {
[doc.x, doc.y] = this.screenToFreeformContentsXf.transformPoint(x, y);
@@ -1493,7 +1492,7 @@ export class CollectionFreeFormView extends CollectionSubView {
const textDoc = DocCast(fieldProps.Document.rootDocument, fieldProps.Document);
const newDoc = Doc.MakeCopy(textDoc, true);
- newDoc[DocData][Doc.LayoutFieldKey(newDoc, fieldProps.LayoutTemplateString)] = undefined; // the copy should not copy the text contents of it source, just the render style
+ newDoc['$' + Doc.LayoutFieldKey(newDoc, fieldProps.LayoutTemplateString)] = undefined; // the copy should not copy the text contents of it source, just the render style
newDoc.x = NumCast(textDoc.x) + (below ? 0 : NumCast(textDoc._width) + 10);
newDoc.y = NumCast(textDoc.y) + (below ? NumCast(textDoc._height) + 10 : 0);
DocumentView.SetSelectOnLoad(newDoc);
@@ -1686,7 +1685,7 @@ export class CollectionFreeFormView extends CollectionSubView (this.Document.isTemplateDoc || this.Document.isTemplateForField ? false : !this._renderCutoffData.get(doc[Id] + '')));
+ renderCutoffProvider = computedFn((doc: Doc) => (this._props.Document.isTemplateDoc || this._props.Document.isTemplateForField ? false : !this._renderCutoffData.get(doc[Id] + '')));
doEngineLayout(
poolData: Map,
diff --git a/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx b/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
index b9f8b13a7..b40189d76 100644
--- a/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
+++ b/src/client/views/collections/collectionFreeForm/FaceCollectionBox.tsx
@@ -108,7 +108,7 @@ export class UniqueFaceBox extends ViewBoxBaseComponent() {
if (faceAnno) {
faceAnno.face && FaceRecognitionHandler.UniqueFaceRemoveFaceImage(faceAnno, DocCast(faceAnno.face));
FaceRecognitionHandler.UniqueFaceAddFaceImage(faceAnno, this.Document);
- faceAnno[DocData].face = this.Document[DocData];
+ faceAnno.$face = this.Document[DocData];
}
}
});
@@ -118,7 +118,7 @@ export class UniqueFaceBox extends ViewBoxBaseComponent() {
const imgDoc = faceAnno;
faceAnno.face && FaceRecognitionHandler.UniqueFaceRemoveFaceImage(imgDoc, DocCast(faceAnno.face));
FaceRecognitionHandler.UniqueFaceAddFaceImage(faceAnno, this.Document);
- faceAnno[DocData].face = this.Document[DocData];
+ faceAnno.$face = this.Document[DocData];
});
e.stopPropagation();
return true;
diff --git a/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx b/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx
index a3d9641da..c983d7c26 100644
--- a/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx
+++ b/src/client/views/collections/collectionFreeForm/ImageLabelBox.tsx
@@ -9,7 +9,6 @@ import React from 'react';
import { imageUrlToBase64 } from '../../../../ClientUtils';
import { Utils, numberRange } from '../../../../Utils';
import { Doc, NumListCast, Opt } from '../../../../fields/Doc';
-import { DocData } from '../../../../fields/DocSymbols';
import { List } from '../../../../fields/List';
import { ImageCast } from '../../../../fields/Types';
import { gptGetEmbedding, gptImageLabel } from '../../../apis/gpt/GPT';
@@ -165,7 +164,7 @@ export class ImageLabelBox extends ViewBoxBaseComponent() {
// Converts the images into a Base64 format, afterwhich the information is sent to GPT to label them.
const imageInfos = this._selectedImages.map(async doc => {
- if (!doc[DocData].tags_chat) {
+ if (!doc.$tags_chat) {
const [name, type] = ImageCast(doc[Doc.LayoutFieldKey(doc)]).url.href.split('.');
return imageUrlToBase64(`${name}_o.${type}`).then(hrefBase64 =>
!hrefBase64 ? undefined :
@@ -176,7 +175,7 @@ export class ImageLabelBox extends ViewBoxBaseComponent() {
(await Promise.all(imageInfos)).forEach(imageInfo => {
if (imageInfo) {
- imageInfo.doc[DocData].tags_chat = (imageInfo.doc[DocData].tags_chat as List) ?? new List();
+ imageInfo.doc.$tags_chat = (imageInfo.doc.$tags_chat as List) ?? new List();
const labels = imageInfo.labels.split('\n');
labels.forEach(label => {
@@ -186,7 +185,7 @@ export class ImageLabelBox extends ViewBoxBaseComponent() {
.replace(/^\d+\.\s*|-|f\*/, '')
.replace(/^#/, '')
.trim();
- (imageInfo.doc[DocData].tags_chat as List).push(hashLabel);
+ (imageInfo.doc.$tags_chat as List).push(hashLabel);
});
}
});
@@ -201,10 +200,10 @@ export class ImageLabelBox extends ViewBoxBaseComponent() {
this.startLoading();
for (const doc of this._selectedImages) {
- for (let index = 0; index < (doc[DocData].tags_chat as List).length; index++) {
- const label = (doc[DocData].tags_chat as List)[index];
+ for (let index = 0; index < (doc.$tags_chat as List).length; index++) {
+ const label = (doc.$tags_chat as List)[index];
const embedding = await gptGetEmbedding(label);
- doc[DocData][`tags_embedding_${index + 1}`] = new List(embedding);
+ doc[`$tags_embedding_${index + 1}`] = new List(embedding);
}
}
@@ -215,13 +214,13 @@ export class ImageLabelBox extends ViewBoxBaseComponent() {
// For each image, loop through the labels, and calculate similarity. Associate it with the
// most similar one.
this._selectedImages.forEach(doc => {
- const embedLists = numberRange((doc[DocData].tags_chat as List).length).map(n => Array.from(NumListCast(doc[DocData][`tags_embedding_${n + 1}`])));
+ const embedLists = numberRange((doc.$tags_chat as List).length).map(n => Array.from(NumListCast(doc[`$tags_embedding_${n + 1}`])));
const bestEmbedScore = (embedding: Opt) => Math.max(...embedLists.map(l => (embedding && similarity(Array.from(embedding), l)!) || 0));
const {label: mostSimilarLabelCollect} =
this._labelGroups.map(label => ({ label, similarityScore: bestEmbedScore(labelToEmbedding.get(label)) }))
.reduce((prev, cur) => cur.similarityScore < 0.3 || cur.similarityScore <= prev.similarityScore ? prev: cur,
{ label: '', similarityScore: 0, }); // prettier-ignore
- doc[DocData].data_label = mostSimilarLabelCollect; // The label most similar to the image's contents.
+ doc.$data_label = mostSimilarLabelCollect; // The label most similar to the image's contents.
});
this.endLoading();
@@ -322,7 +321,7 @@ export class ImageLabelBox extends ViewBoxBaseComponent() {
await DocumentView.showDocument(doc, { willZoomCentered: true });
}}>
this._props.addDocTab(doc, OpenWhere.addRightKeyvalue)}>
- {(doc[DocData].tags_chat as List
).map(label => {
+ {(doc.$tags_chat as List).map(label => {
return (
{label}
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index ad52db496..e3f4c6605 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -165,7 +165,7 @@ export class MarqueeView extends ObservableReactComponent
{
- this._props.Document[DocData].icon = new ImageField(returnedfilename);
+ this._props.Document.$icon = new ImageField(returnedfilename);
});
})
);
@@ -371,10 +371,9 @@ export class MarqueeView extends ObservableReactComponent {
- const docData = doc[DocData];
- docData.data = new List(selected);
- docData.isGroup = makeGroup;
- docData.title = makeGroup ? 'grouping' : 'nested freeform';
+ doc.$data = new List(selected);
+ doc.$isGroup = makeGroup;
+ doc.$title = makeGroup ? 'grouping' : 'nested freeform';
doc._freeform_panX = doc._freeform_panY = 0;
return doc;
})(Doc.MakeCopy(Doc.UserDoc().emptyCollection as Doc, true));
@@ -462,9 +461,9 @@ export class MarqueeView extends ObservableReactComponent {
- doc[DocData].borderColor = color;
- });
+ else selected.forEach(doc => (doc.$borderColor = color));
}
return '';
});
@@ -114,7 +108,7 @@ ScriptingGlobals.add(function setBorderColor(color?: string, checkResult?: boole
ScriptingGlobals.add(function setBackgroundColor(color?: string, checkResult?: boolean) {
const selectedViews = DocumentView.Selected();
const selectedDoc = selectedViews.lastElement()?.Document;
- const defaultFill = selectedDoc?._layout_isSvg ? () => StrCast(selectedDoc[DocData].fillColor) : !Doc.ActiveTool || Doc.ActiveTool === InkTool.None ? () => StrCast(Doc.UserDoc().textBackgroundColor, 'transparent') : () => ActiveInkFillColor();
+ const defaultFill = selectedDoc?._layout_isSvg ? () => StrCast(selectedDoc.$fillColor) : !Doc.ActiveTool || Doc.ActiveTool === InkTool.None ? () => StrCast(Doc.UserDoc().textBackgroundColor, 'transparent') : () => ActiveInkFillColor();
const setDefaultFill = !Doc.ActiveTool || Doc.ActiveTool === InkTool.None ? (c: string) => { Doc.UserDoc().textBackgroundColor = c; }: SetActiveInkFillColor; // prettier-ignore
if (Doc.ActiveTool !== InkTool.None && !selectedViews.lastElement()?.Document._layout_isSvg) {
if (checkResult) return defaultFill();
@@ -149,10 +143,7 @@ ScriptingGlobals.add(function setBackgroundColor(color?: string, checkResult?: b
return selected.lastElement()?._backgroundColor ?? defaultFill();
}
if (!selected.length) setDefaultFill(color ?? 'transparent');
- else
- selected.forEach(doc => {
- doc[DocData][doc._layout_isSvg ? 'fillColor' : 'backgroundColor'] = color;
- });
+ else selected.forEach(doc => (doc[doc._layout_isSvg ? '$fillColor' : '$backgroundColor'] = color));
}
return '';
});
@@ -170,7 +161,7 @@ ScriptingGlobals.add(function setHeaderColor(color?: string, checkResult?: boole
}
if (DocumentView.Selected().length) {
DocumentView.SelectedDocs().forEach(doc => {
- doc[DocData].layout_headingColor = color === 'transparent' ? undefined : color;
+ doc.$layout_headingColor = color === 'transparent' ? undefined : color;
doc.layout_showTitle = color === 'transparent' ? undefined : StrCast(doc.layout_showTitle, 'title');
});
} else {
@@ -470,23 +461,23 @@ ScriptingGlobals.add(function setInkProperty(option: InkProperty, value: string
// prettier-ignore
const map: Map number|boolean|string|undefined; setInk: (doc: Doc) => void; setMode: () => void }> = new Map([
[InkProperty.Mask, {
- checkResult: () => ((selected?._layout_isSvg ? BoolCast(selected[DocData].stroke_isInkMask) : ActiveIsInkMask())),
- setInk: (doc: Doc) => { doc[DocData].stroke_isInkMask = !doc.stroke_isInkMask; },
+ checkResult: () => ((selected?._layout_isSvg ? BoolCast(selected.$stroke_isInkMask) : ActiveIsInkMask())),
+ setInk: (doc: Doc) => { doc.$stroke_isInkMask = !doc.stroke_isInkMask; },
setMode: () => SetActiveIsInkMask(value ? true : false)
}],
[InkProperty.Labels, {
- checkResult: () => ((selected?._layout_isSvg ? BoolCast(selected[DocData].stroke_showLabel) : !ActiveHideTextLabels())),
- setInk: (doc: Doc) => { doc[DocData].stroke_showLabel = value; },
+ checkResult: () => ((selected?._layout_isSvg ? BoolCast(selected.$stroke_showLabel) : !ActiveHideTextLabels())),
+ setInk: (doc: Doc) => { doc.$stroke_showLabel = value; },
setMode: () => SetactiveHideTextLabels(value? false : true),
}],
[ InkProperty.StrokeWidth, {
- checkResult: () => (selected?._layout_isSvg ? NumCast(selected[DocData].stroke_width, 1) : ActiveInkWidth()),
- setInk: (doc: Doc) => { doc[DocData].stroke_width = NumCast(value); },
+ checkResult: () => (selected?._layout_isSvg ? NumCast(selected.$stroke_width, 1) : ActiveInkWidth()),
+ setInk: (doc: Doc) => { doc.$stroke_width = NumCast(value); },
setMode: () => SetActiveInkWidth(value.toString()),
}],
[InkProperty.StrokeColor, {
- checkResult: () => (selected?._layout_isSvg? StrCast(selected[DocData].color) : ActiveInkColor()),
- setInk: (doc: Doc) => { doc[DocData].color = String(value); },
+ checkResult: () => (selected?._layout_isSvg? StrCast(selected.$color) : ActiveInkColor()),
+ setInk: (doc: Doc) => { doc.$color = String(value); },
setMode: () => SetActiveInkColor(StrCast(value))
}],
[ InkProperty.EraserWidth, {
diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx
index 25e76e2a6..e0d59cc9d 100644
--- a/src/client/views/nodes/AudioBox.tsx
+++ b/src/client/views/nodes/AudioBox.tsx
@@ -296,7 +296,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent() {
'Content-Type': 'application/json',
},
});
- this.Document[DocData].phoneticTranscription = response.data['transcription'];
+ this.Document.$phoneticTranscription = response.data['transcription'];
};
// context menu
diff --git a/src/client/views/nodes/ComparisonBox.tsx b/src/client/views/nodes/ComparisonBox.tsx
index c0c6db4d3..992fbba66 100644
--- a/src/client/views/nodes/ComparisonBox.tsx
+++ b/src/client/views/nodes/ComparisonBox.tsx
@@ -80,8 +80,8 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent()
const front = Docs.Create.CenteredTextCreator('question', question, {}, img);
const back = Docs.Create.CenteredTextCreator('answer', answer, {});
if (useDoc) {
- useDoc[DocData][frontKey] = front;
- useDoc[DocData][backKey] = back;
+ useDoc['$' + frontKey] = front;
+ useDoc['$' + backKey] = back;
return useDoc;
}
return Docs.Create.FlashcardDocument(title, front, back, { _width: 300, _height: 300 });
@@ -475,7 +475,7 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent()
axios
.post(
'http://localhost:105/recognize/', //
- { file: DocCast(this.Document.audio)[DocData].url },
+ { file: DocCast(this.Document.audio).$url },
{ headers: { 'Content-Type': 'application/json' } }
)
.then(response => {
@@ -520,7 +520,7 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent()
action(resp => {
switch (resp && callType) {
case GPTCallType.CHATCARD:
- DocCast(this.dataDoc[this.backKey])[DocData].text = resp;
+ DocCast(this.dataDoc[this.backKey]).$text = resp;
break;
case GPTCallType.QUIZDOC:
this._renderSide = this.backKey;
@@ -618,7 +618,7 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent()
const hrefBase64 = await imageUrlToBase64(u);
const response = await gptImageLabel(hrefBase64, 'Answer the following question as a short flashcard response. Do not include a label.' + (this.dataDoc.text as RichTextField)?.Text);
- DocCast(this.dataDoc[this.backKey])[DocData].text = response;
+ DocCast(this.dataDoc[this.backKey]).$text = response;
} catch (error) {
console.log('Error', error);
}
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index 7ef4bca6b..b31a0ec1e 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -160,8 +160,8 @@ export class TableBox extends ObservableReactComponent {
DragManager.StartAnchorAnnoDrag(moveEv.target instanceof HTMLElement ? [moveEv.target] : [], new DragManager.AnchorAnnoDragData(this._props.docView()!, sourceAnchorCreator, targetCreator), downX, downY, {
dragComplete: completeEv => {
if (!completeEv.aborted && completeEv.annoDragData && completeEv.annoDragData.linkSourceDoc && completeEv.annoDragData.dropDocument && completeEv.linkDocument) {
- completeEv.linkDocument[DocData].link_matchEmbeddings = true;
- completeEv.linkDocument[DocData].stroke_startMarker = true;
+ completeEv.linkDocument.$link_matchEmbeddings = true;
+ completeEv.linkDocument.$stroke_startMarker = true;
this._props.docView?.()?._props.addDocument?.(completeEv.linkDocument);
}
},
diff --git a/src/client/views/nodes/DiagramBox.tsx b/src/client/views/nodes/DiagramBox.tsx
index a49c69be3..3b666bad5 100644
--- a/src/client/views/nodes/DiagramBox.tsx
+++ b/src/client/views/nodes/DiagramBox.tsx
@@ -3,7 +3,6 @@ import { action, computed, makeObservable, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { Doc, DocListCast } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { RichTextField } from '../../../fields/RichTextField';
import { Cast, DocCast, NumCast, RTFCast, StrCast } from '../../../fields/Types';
import { Gestures } from '../../../pen-gestures/GestureTypes';
@@ -46,7 +45,7 @@ export class DiagramBox extends ViewBoxAnnotatableComponent() {
@observable _errorMessage = '';
@computed get mermaidcode() {
- return StrCast(this.Document[DocData].text, RTFCast(this.Document[DocData].text)?.Text);
+ return StrCast(this.Document.$text, RTFCast(this.Document.$text)?.Text);
}
componentDidMount() {
@@ -89,7 +88,7 @@ export class DiagramBox extends ViewBoxAnnotatableComponent() {
};
setMermaidCode = undoable((res: string) => {
- this.Document[DocData].text = new RichTextField(
+ this.Document.$text = new RichTextField(
JSON.stringify({
doc: {
type: 'doc',
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 46bd076d4..e9353b001 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -9,7 +9,7 @@ import { Fade, JackInTheBox } from 'react-awesome-reveal';
import { ClientUtils, DivWidth, isTargetChildOf as isParentOf, lightOrDark, returnFalse, returnVal, simMouseEvent, simulateMouseClick } from '../../../ClientUtils';
import { Utils, emptyFunction } from '../../../Utils';
import { Doc, DocListCast, Field, FieldType, Opt, StrListCast } from '../../../fields/Doc';
-import { AclAdmin, AclEdit, AclPrivate, Animation, AudioPlay, DocData, DocViews } from '../../../fields/DocSymbols';
+import { AclAdmin, AclEdit, AclPrivate, Animation, AudioPlay, DocViews } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { InkTool } from '../../../fields/InkField';
import { List } from '../../../fields/List';
@@ -40,6 +40,7 @@ import { FieldsDropdown } from '../FieldsDropdown';
import { ObserverJsxParser } from '../ObservableReactComponent';
import { PinProps } from '../PinFuncs';
import { StyleProp } from '../StyleProp';
+import { TagsView } from '../TagsView';
import { ViewBoxInterface } from '../ViewBoxInterface';
import { GroupActive } from './CollectionFreeFormDocumentView';
import { DocumentContentsView } from './DocumentContentsView';
@@ -52,7 +53,6 @@ import { FormattedTextBox } from './formattedText/FormattedTextBox';
import { PresEffect, PresEffectDirection } from './trails/PresEnums';
import SpringAnimation from './trails/SlideEffect';
import { SpringType, springMappings } from './trails/SpringUtils';
-import { TagsView } from '../TagsView';
export interface DocumentViewProps extends FieldViewSharedProps {
hideDecorations?: boolean; // whether to suppress all DocumentDecorations when doc is selected
@@ -426,7 +426,7 @@ export class DocumentViewInternal extends DocComponent {
this.Document.ignoreClick = false;
- this.Document.onClick = this.Document[DocData].onClick = undefined;
+ this.Document.onClick = this.Document.$onClick = undefined;
}, 'default on click');
deleteClicked = undoable(() => this._props.removeDocument?.(this.Document), 'delete doc');
@@ -758,7 +758,7 @@ export class DocumentViewInternal extends DocComponent
')[1];
const matchedTags = Array.from(SearchUtil.SearchCollection(Doc.MyFilesystem, tag, false, ['tags']).keys());
- const collectionDocs = DocListCast(collection[DocData].data).concat(collection);
+ const collectionDocs = DocListCast(collection.$data).concat(collection);
let wid = 100;
let created = false;
const matchedDocs = matchedTags
@@ -1749,6 +1749,6 @@ ScriptingGlobals.add(function updateTagsCollection(collection: Doc) {
return aset;
}, new Set());
- created && (collection[DocData].data = new List(Array.from(matchedDocs)));
+ created && (collection.$data = new List(Array.from(matchedDocs)));
return true;
});
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index 5b06e9fc5..5d9718760 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -284,10 +284,9 @@ export class ImageBox extends ViewBoxAnnotatableComponent() {
crop = (region: Doc | undefined, addCrop?: boolean) => {
if (!region) return undefined;
const cropping = Doc.MakeCopy(region, true);
- const regionData = region[DocData];
- regionData.lockedPosition = true;
- regionData.title = 'region:' + this.Document.title;
- regionData.followLinkToggle = true;
+ region.$lockedPosition = true;
+ region.$title = 'region:' + this.Document.title;
+ region.$followLinkToggle = true;
this.addDocument(region);
const anchx = NumCast(cropping.x);
const anchy = NumCast(cropping.y);
@@ -300,24 +299,23 @@ export class ImageBox extends ViewBoxAnnotatableComponent() {
cropping._width = anchw * (this._props.NativeDimScaling?.() || 1);
cropping._height = anchh * (this._props.NativeDimScaling?.() || 1);
cropping.onClick = undefined;
- const croppingProto = cropping[DocData];
- croppingProto.annotationOn = undefined;
- croppingProto.isDataDoc = true;
- croppingProto.backgroundColor = undefined;
- croppingProto.proto = Cast(this.Document.proto, Doc, null)?.proto; // set proto of cropping's data doc to be IMAGE_PROTO
- croppingProto.type = DocumentType.IMG;
- croppingProto.layout = ImageBox.LayoutString('data');
- croppingProto.data = ObjectField.MakeCopy(this.dataDoc[this.fieldKey] as ObjectField);
- croppingProto.data_nativeWidth = anchw;
- croppingProto.data_nativeHeight = anchh;
- croppingProto.freeform_scale = viewScale;
- croppingProto.freeform_panX = anchx / viewScale;
- croppingProto.freeform_panY = anchy / viewScale;
- croppingProto.freeform_scale_min = viewScale;
- croppingProto.freeform_panX_min = anchx / viewScale;
- croppingProto.freeform_panX_max = anchw / viewScale;
- croppingProto.freeform_panY_min = anchy / viewScale;
- croppingProto.freeform_panY_max = anchh / viewScale;
+ cropping.$annotationOn = undefined;
+ cropping.$isDataDoc = true;
+ cropping.$backgroundColor = undefined;
+ cropping.$proto = Cast(this.Document.proto, Doc, null)?.proto; // set proto of cropping's data doc to be IMAGE_PROTO
+ cropping.$type = DocumentType.IMG;
+ cropping.$layout = ImageBox.LayoutString('data');
+ cropping.$data = ObjectField.MakeCopy(this.dataDoc[this.fieldKey] as ObjectField);
+ cropping.$data_nativeWidth = anchw;
+ cropping.$data_nativeHeight = anchh;
+ cropping.$freeform_scale = viewScale;
+ cropping.$reeform_panX = anchx / viewScale;
+ cropping.$freeform_panY = anchy / viewScale;
+ cropping.$freeform_scale_min = viewScale;
+ cropping.$freeform_panX_min = anchx / viewScale;
+ cropping.$freeform_panX_max = anchw / viewScale;
+ cropping.$freeform_panY_min = anchy / viewScale;
+ cropping.$freeform_panY_max = anchh / viewScale;
if (addCrop) {
DocUtils.MakeLink(region, cropping, { link_relationship: 'cropped image' });
cropping.x = NumCast(this.Document.x) + NumCast(this.layoutDoc._width);
diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index 9795febbe..32c9efbd9 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -105,7 +105,7 @@ export class KeyValueBox extends ViewBoxBaseComponent() {
if (setResult) setResult?.(value);
else target[key] = field;
};
- const res = script.run({ this: Doc.Layout(doc), _setCacheResult_ }, console.log);
+ const res = script.run({ this: doc, _setCacheResult_ }, console.log);
if (!res.success) {
if (key) target[key] = script.originalScript;
return false;
diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx
index d5dc256d9..8bf65b637 100644
--- a/src/client/views/nodes/LinkBox.tsx
+++ b/src/client/views/nodes/LinkBox.tsx
@@ -252,7 +252,7 @@ export class LinkBox extends ViewBoxBaseComponent() {
fontSize={fontSize}
GetValue={() => linkDesc}
SetValue={action(val => {
- this.Document[DocData].link_description = val;
+ this.Document.$link_description = val;
return true;
})}
/>
@@ -262,8 +262,8 @@ export class LinkBox extends ViewBoxBaseComponent() {
background={color}
color={fontColor || lightOrDark(DashColor(color).fade(0.5).toString())}
type={Type.PRIM}
- val={StrCast(this.Document[DocData].link_description)}
- setVal={action(val => (this.Document[DocData].link_description = val))}
+ val={StrCast(this.Document.$link_description)}
+ setVal={action(val => (this.Document.$link_description = val))}
fillWidth
/> */}
diff --git a/src/client/views/nodes/LinkDescriptionPopup.tsx b/src/client/views/nodes/LinkDescriptionPopup.tsx
index ff95f8547..6bec9c53d 100644
--- a/src/client/views/nodes/LinkDescriptionPopup.tsx
+++ b/src/client/views/nodes/LinkDescriptionPopup.tsx
@@ -1,7 +1,6 @@
import { action, makeObservable, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
-import { DocData } from '../../../fields/DocSymbols';
import { StrCast } from '../../../fields/Types';
import { LinkManager } from '../../util/LinkManager';
import './LinkDescriptionPopup.scss';
@@ -48,7 +47,7 @@ export class LinkDescriptionPopup extends React.Component<{}> {
onDismiss = (add: boolean) => {
this.display = false;
if (add) {
- LinkManager.Instance.currentLink && (LinkManager.Instance.currentLink[DocData].link_description = this.description);
+ LinkManager.Instance.currentLink && (LinkManager.Instance.currentLink.$link_description = this.description);
}
this.description = '';
};
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index 06b75e243..1f72206fc 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -129,15 +129,14 @@ export class PDFBox extends ViewBoxAnnotatableComponent() {
cropping._width = anchw;
cropping._height = anchh;
cropping.onClick = undefined;
- const croppingProto = cropping[DocData];
- croppingProto.annotationOn = undefined;
- croppingProto.isDataDoc = true;
- croppingProto.proto = Cast(this.Document.proto, Doc, null)?.proto; // set proto of cropping's data doc to be IMAGE_PROTO
- croppingProto.type = DocumentType.IMG;
- croppingProto.layout = ImageBox.LayoutString('data');
- croppingProto.data = new ImageField(ClientUtils.CorsProxy('http://www.cs.brown.edu/~bcz/noImage.png'));
- croppingProto.data_nativeWidth = anchw;
- croppingProto.data_nativeHeight = anchh;
+ cropping.$annotationOn = undefined;
+ cropping.$isDataDoc = true;
+ cropping.$proto = Cast(this.Document.proto, Doc, null)?.proto; // set proto of cropping's data doc to be IMAGE_PROTO
+ cropping.$type = DocumentType.IMG;
+ cropping.$layout = ImageBox.LayoutString('data');
+ cropping.$data = new ImageField(ClientUtils.CorsProxy('http://www.cs.brown.edu/~bcz/noImage.png'));
+ cropping.$data_nativeWidth = anchw;
+ cropping.$data_nativeHeight = anchh;
if (addCrop) {
DocUtils.MakeLink(region, cropping, { link_relationship: 'cropped image' });
}
diff --git a/src/client/views/nodes/RecordingBox/RecordingBox.tsx b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
index 7ba313e92..53783e8a3 100644
--- a/src/client/views/nodes/RecordingBox/RecordingBox.tsx
+++ b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
@@ -3,7 +3,6 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { DateField } from '../../../../fields/DateField';
import { Doc, DocListCast } from '../../../../fields/Doc';
-import { DocData } from '../../../../fields/DocSymbols';
import { Id } from '../../../../fields/FieldSymbols';
import { List } from '../../../../fields/List';
import { BoolCast, DocCast } from '../../../../fields/Types';
@@ -99,7 +98,7 @@ export class RecordingBox extends ViewBoxBaseComponent() {
});
screengrabber.overlayX = 70; // was -400
screengrabber.overlayY = 590; // was 0
- screengrabber[DocData][Doc.LayoutFieldKey(screengrabber) + '_trackScreen'] = true;
+ screengrabber['$' + Doc.LayoutFieldKey(screengrabber) + '_trackScreen'] = true;
Doc.AddToMyOverlay(screengrabber); // just adds doc to overlay
DocumentView.addViewRenderedCb(screengrabber, docView => {
RecordingBox.screengrabber = docView.ComponentView as RecordingBox;
diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx
index 9adee53e8..fa099178c 100644
--- a/src/client/views/nodes/VideoBox.tsx
+++ b/src/client/views/nodes/VideoBox.tsx
@@ -331,7 +331,7 @@ export class VideoBox extends ViewBoxAnnotatableComponent() {
Doc.SetNativeHeight(imageSnapshot[DocData], Doc.NativeHeight(this.layoutDoc));
this._props.addDocument?.(imageSnapshot);
DocUtils.MakeLink(imageSnapshot, this.getAnchor(true), { link_relationship: 'video snapshot' });
- // link && (DocCast(link.link_anchor_2)[DocData].timecodeToHide = NumCast(DocCast(link.link_anchor_2).timecodeToShow) + 3); // do we need to set an end time? should default to +0.1
+ // link && (DocCast(link.link_anchor_2).$timecodeToHide = NumCast(DocCast(link.link_anchor_2).timecodeToShow) + 3); // do we need to set an end time? should default to +0.1
setTimeout(() => downX !== undefined && downY !== undefined && DocumentView.getFirstDocumentView(imageSnapshot)?.startDragging(downX, downY, dropActionType.move, true));
};
@@ -918,11 +918,10 @@ export class VideoBox extends ViewBoxAnnotatableComponent() {
crop = (region: Doc | undefined, addCrop?: boolean) => {
if (!region) return undefined;
const cropping = Doc.MakeCopy(region, true);
- const regionData = region[DocData];
- regionData.backgroundColor = 'transparent';
- regionData.lockedPosition = true;
- regionData.title = 'region:' + this.Document.title;
- regionData.followLinkToggle = true;
+ region.$backgroundColor = 'transparent';
+ region.$lockedPosition = true;
+ region.$title = 'region:' + this.Document.title;
+ region.$followLinkToggle = true;
region._timecodeToHide = NumCast(region._timecodeToShow) + 0.0001;
this.addDocument(region);
const anchx = NumCast(cropping.x);
@@ -938,25 +937,24 @@ export class VideoBox extends ViewBoxAnnotatableComponent() {
cropping.timecodeToHide = undefined;
cropping.timecodeToShow = undefined;
cropping.onClick = undefined;
- const croppingProto = cropping[DocData];
- croppingProto.annotationOn = undefined;
- croppingProto.isDataDoc = true;
- croppingProto.proto = Cast(this.Document.proto, Doc, null)?.proto; // set proto of cropping's data doc to be IMAGE_PROTO
- croppingProto.type = DocumentType.VID;
- croppingProto.layout = VideoBox.LayoutString('data');
- croppingProto.data = ObjectField.MakeCopy(this.dataDoc[this.fieldKey] as ObjectField);
- croppingProto.data_nativeWidth = anchw;
- croppingProto.data_nativeHeight = anchh;
- croppingProto.videoCrop = true;
- croppingProto.layout_currentTimecode = this.layoutDoc._layout_currentTimecode;
- croppingProto.freeform_scale = viewScale;
- croppingProto.freeform_scale_min = viewScale;
- croppingProto.freeform_ = anchx / viewScale;
- croppingProto.freeform_panY = anchy / viewScale;
- croppingProto.freeform_panX_min = anchx / viewScale;
- croppingProto.freeform_panX_max = anchw / viewScale;
- croppingProto.freeform_panY_min = anchy / viewScale;
- croppingProto.freeform_panY_max = anchh / viewScale;
+ cropping.$annotationOn = undefined;
+ cropping.$isDataDoc = true;
+ cropping.$proto = Cast(this.Document.proto, Doc, null)?.proto; // set proto of cropping's data doc to be IMAGE_PROTO
+ cropping.$type = DocumentType.VID;
+ cropping.$layout = VideoBox.LayoutString('data');
+ cropping.$data = ObjectField.MakeCopy(this.dataDoc[this.fieldKey] as ObjectField);
+ cropping.$data_nativeWidth = anchw;
+ cropping.$data_nativeHeight = anchh;
+ cropping.$videoCrop = true;
+ cropping.$layout_currentTimecode = this.layoutDoc._layout_currentTimecode;
+ cropping.$freeform_scale = viewScale;
+ cropping.$freeform_scale_min = viewScale;
+ cropping.$freeform_ = anchx / viewScale;
+ cropping.$freeform_panY = anchy / viewScale;
+ cropping.$freeform_panX_min = anchx / viewScale;
+ cropping.$freeform_panX_max = anchw / viewScale;
+ cropping.$freeform_panY_min = anchy / viewScale;
+ cropping.$freeform_panY_max = anchh / viewScale;
if (addCrop) {
DocUtils.MakeLink(region, cropping, { link_relationship: 'cropped image' });
}
diff --git a/src/client/views/nodes/calendarBox/CalendarBox.tsx b/src/client/views/nodes/calendarBox/CalendarBox.tsx
index 1cbfd5fba..e3408696b 100644
--- a/src/client/views/nodes/calendarBox/CalendarBox.tsx
+++ b/src/client/views/nodes/calendarBox/CalendarBox.tsx
@@ -113,7 +113,7 @@ export class CalendarBox extends CollectionSubView() {
if (!super.onInternalDrop(e, de)) return false;
de.complete.docDragData?.droppedDocuments.forEach(doc => {
const today = new Date().toISOString();
- if (!doc.date_range) doc[DocData].date_range = `${today}|${today}`;
+ if (!doc.date_range) doc.$date_range = `${today}|${today}`;
});
return true;
};
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
index 6e9307d37..b023b1de6 100644
--- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
+++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
@@ -733,9 +733,9 @@ export class ChatBox extends ViewBoxAnnotatableComponent() {
const x2 = parseFloat(values[2]) * Doc.NativeWidth(doc);
const y2 = parseFloat(values[3]) * Doc.NativeHeight(doc) + foundChunk.startPage * Doc.NativeHeight(doc);
- const annotationKey = Doc.LayoutFieldKey(doc) + '_annotations';
+ const annotationKey = '$' + Doc.LayoutFieldKey(doc) + '_annotations';
- const existingDoc = DocListCast(doc[DocData][annotationKey]).find(d => d.citation_id === citation.citation_id);
+ const existingDoc = DocListCast(doc[annotationKey]).find(d => d.citation_id === citation.citation_id);
const highlightDoc = existingDoc ?? this.createImageCitationHighlight(x1, y1, x2, y2, citation, annotationKey, doc);
DocumentManager.Instance.showDocument(highlightDoc, { willZoomCentered: true }, () => {});
@@ -779,7 +779,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent() {
_height: y2 - y1,
backgroundColor: 'rgba(255, 255, 0, 0.5)',
});
- highlight_doc[DocData].citation_id = citation.citation_id;
+ highlight_doc.$citation_id = citation.citation_id;
Doc.AddDocToList(pdfDoc[DocData], annotationKey, highlight_doc);
highlight_doc.annotationOn = pdfDoc;
Doc.SetContainer(highlight_doc, pdfDoc);
diff --git a/src/client/views/nodes/formattedText/EquationView.tsx b/src/client/views/nodes/formattedText/EquationView.tsx
index e0450b202..827db190a 100644
--- a/src/client/views/nodes/formattedText/EquationView.tsx
+++ b/src/client/views/nodes/formattedText/EquationView.tsx
@@ -6,7 +6,6 @@ import { EditorView } from 'prosemirror-view';
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import { Doc } from '../../../../fields/Doc';
-import { DocData } from '../../../../fields/DocSymbols';
import { StrCast } from '../../../../fields/Types';
import './DashFieldView.scss';
import EquationEditor from './EquationEditor';
@@ -63,9 +62,9 @@ export class EquationViewInternal extends React.Component
}}>
{
- this._textBoxDoc[DocData][this._fieldKey] = str;
+ this._textBoxDoc['$' + this._fieldKey] = str;
}}
autoCommands="pi theta sqrt sum prod alpha beta gamma rho"
autoOperatorNames="sin cos tan"
diff --git a/src/client/views/nodes/imageEditor/ImageEditor.tsx b/src/client/views/nodes/imageEditor/ImageEditor.tsx
index 657e689bb..85bd95d15 100644
--- a/src/client/views/nodes/imageEditor/ImageEditor.tsx
+++ b/src/client/views/nodes/imageEditor/ImageEditor.tsx
@@ -24,8 +24,8 @@ import { PointerHandler } from './imageEditorUtils/PointerHandler';
import { activeColor, bgColor, brushWidthOffset, canvasSize, eraserColor, freeformRenderSize, newCollectionSize, offsetDistanceY, offsetX } from './imageEditorUtils/imageEditorConstants';
import { CutMode, CursorData, ImageDimensions, ImageEditTool, ImageToolType, Point } from './imageEditorUtils/imageEditorInterfaces';
import { DocumentView } from '../DocumentView';
-import { DocData } from '../../../../fields/DocSymbols';
import { SettingsManager } from '../../../util/SettingsManager';
+import { Upload } from '../../../../server/SharedMediaTypes';
interface GenerativeFillProps {
imageEditorOpen: boolean;
@@ -397,9 +397,8 @@ const ImageEditor = ({ imageEditorOpen, imageEditorSource, imageRootDoc, addDoc
const newImgDoc = await createNewImgDoc(finalImg, firstDoc);
if (newImgDoc) {
// set the image to transparent to remove the background / brushstrokes
- const docData = newImgDoc[DocData];
- docData.backgroundColor = 'transparent';
- docData.disableMixBlend = true;
+ newImgDoc.$backgroundColor = 'transparent';
+ newImgDoc.$disableMixBlend = true;
if (firstDoc) setIsFirstDoc(false);
setEdits([...prevEdits, { url: finalImgURL, saveRes: undefined }]);
}
@@ -476,7 +475,7 @@ const ImageEditor = ({ imageEditorOpen, imageEditorSource, imageRootDoc, addDoc
const createNewImgDoc = async (img: HTMLImageElement, firstDoc: boolean /*, parent?: Doc */): Promise => {
if (!imageRootDoc) return undefined;
const { src } = img;
- const [result] = await Networking.PostToServer('/uploadRemoteImage', { sources: [src] });
+ const [result] = (await Networking.PostToServer('/uploadRemoteImage', { sources: [src] })) as Upload.ImageInformation[];
const source = ClientUtils.prepend(result.accessPaths.agnostic.client);
if (firstDoc) {
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index ec97e067a..23155ebf3 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -532,11 +532,10 @@ export class PresBox extends ViewBoxBaseComponent() {
const setData = bestTargetView?.ComponentView?.setData;
if (setData) setData(activeItem.config_data);
else {
- const bestTargetData = bestTarget[DocData];
- const current = bestTargetData[fkey];
- const hash = bestTargetData[fkey] ? stringHash(Field.toString(bestTargetData[fkey] as FieldType)) : undefined;
- if (hash) bestTargetData[fkey + '_' + hash] = current instanceof ObjectField ? current[Copy]() : current;
- bestTargetData[fkey] = activeItem.config_data instanceof ObjectField ? activeItem.config_data[Copy]() : activeItem.config_data;
+ const current = bestTarget['$' + fkey];
+ const hash = bestTarget['$' + fkey] ? stringHash(Field.toString(bestTarget['$' + fkey] as FieldType)) : undefined;
+ if (hash) bestTarget['$' + fkey + '_' + hash] = current instanceof ObjectField ? current[Copy]() : current;
+ bestTarget['$' + fkey] = activeItem.config_data instanceof ObjectField ? activeItem.config_data[Copy]() : activeItem.config_data;
}
bestTarget[fkey + '_usePath'] = activeItem.config_usePath;
setTimeout(() => {
diff --git a/src/client/views/smartdraw/SmartDrawHandler.tsx b/src/client/views/smartdraw/SmartDrawHandler.tsx
index 1cceabed3..2283ef965 100644
--- a/src/client/views/smartdraw/SmartDrawHandler.tsx
+++ b/src/client/views/smartdraw/SmartDrawHandler.tsx
@@ -10,9 +10,11 @@ import { INode, parse } from 'svgson';
import { imageUrlToBase64, setupMoveUpEvents } from '../../../ClientUtils';
import { unimplementedFunction } from '../../../Utils';
import { Doc, DocListCast } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { InkData, InkField, InkTool } from '../../../fields/InkField';
+import { List } from '../../../fields/List';
import { BoolCast, ImageCast, NumCast, StrCast } from '../../../fields/Types';
+import { PointData } from '../../../pen-gestures/GestureTypes';
+import { Upload } from '../../../server/SharedMediaTypes';
import { Networking } from '../../Network';
import { GPTCallType, gptAPICall, gptDrawingColor } from '../../apis/gpt/GPT';
import { DocumentType } from '../../documents/DocumentTypes';
@@ -26,9 +28,6 @@ import { MarqueeView } from '../collections/collectionFreeForm';
import { ActiveInkArrowEnd, ActiveInkArrowStart, ActiveInkBezierApprox, ActiveInkColor, ActiveInkDash, ActiveInkFillColor, ActiveInkWidth, ActiveIsInkMask, DocumentView } from '../nodes/DocumentView';
import { FireflyDimensionsMap, FireflyImageData, FireflyImageDimensions } from './FireflyConstants';
import './SmartDrawHandler.scss';
-import { Upload } from '../../../server/SharedMediaTypes';
-import { PointData } from '../../../pen-gestures/GestureTypes';
-import { List } from '../../../fields/List';
export interface DrawingOptions {
text?: string;
@@ -153,9 +152,9 @@ export class SmartDrawHandler extends ObservableReactComponent {
this._display = false;
this.ShowRegenerate = true;
this._showEditBox = false;
- const docData = this._selectedDocs[0][DocData];
- this._lastResponse = StrCast(docData.drawingData);
- this._lastInput = { text: StrCast(docData.ai_drawing_input), complexity: NumCast(docData.ai_drawing_complexity), size: NumCast(docData.ai_drawing_size), autoColor: BoolCast(docData.ai_drawing_colored), x: this._pageX, y: this._pageY };
+ const docData = this._selectedDocs[0];
+ this._lastResponse = StrCast(docData.$drawingData);
+ this._lastInput = { text: StrCast(docData.$ai_drawing_input), complexity: NumCast(docData.$ai_drawing_complexity), size: NumCast(docData.$ai_drawing_size), autoColor: BoolCast(docData.$ai_drawing_colored), x: this._pageX, y: this._pageY };
};
/**
@@ -404,7 +403,7 @@ export class SmartDrawHandler extends ObservableReactComponent {
const hrefComplete = `${hrefParts[0]}_o.${hrefParts[1]}`;
try {
const hrefBase64 = await imageUrlToBase64(hrefComplete);
- const strokes = DocListCast(drawing[DocData].data);
+ const strokes = DocListCast(drawing.$data);
const coords: string[] = [];
strokes.forEach((stroke, i) => {
const inkingStroke = DocumentView.getDocumentView(stroke)?.ComponentView as InkingStroke;
@@ -423,14 +422,14 @@ export class SmartDrawHandler extends ObservableReactComponent {
*/
colorStrokes = undoable((res: string, drawing: Doc) => {
const colorList = res.match(/\{.*?\}/g);
- const strokes = DocListCast(drawing[DocData].data);
+ const strokes = DocListCast(drawing.$data);
colorList?.forEach((colors, index) => {
const strokeAndFill = colors.match(/#[0-9A-Fa-f]{6}/g);
if (strokeAndFill && strokeAndFill.length == 2) {
- strokes[index][DocData].color = strokeAndFill[0];
+ strokes[index].$color = strokeAndFill[0];
const inkStroke = DocumentView.getDocumentView(strokes[index])?.ComponentView as InkingStroke;
const { inkData } = inkStroke.inkScaledData();
- InkingStroke.IsClosed(inkData) ? (strokes[index][DocData].fillColor = strokeAndFill[1]) : (strokes[index][DocData].fillColor = undefined);
+ InkingStroke.IsClosed(inkData) ? (strokes[index].$fillColor = strokeAndFill[1]) : (strokes[index].$fillColor = undefined);
}
});
}, 'color strokes');
diff --git a/src/client/views/smartdraw/StickerPalette.tsx b/src/client/views/smartdraw/StickerPalette.tsx
index e3305851a..080a05d42 100644
--- a/src/client/views/smartdraw/StickerPalette.tsx
+++ b/src/client/views/smartdraw/StickerPalette.tsx
@@ -9,7 +9,6 @@ import ReactLoading from 'react-loading';
import { returnEmptyFilter, returnFalse, returnTrue } from '../../../ClientUtils';
import { emptyFunction, numberRange } from '../../../Utils';
import { Doc, DocListCast, returnEmptyDoclist } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { ImageCast, NumCast } from '../../../fields/Types';
import { ImageField } from '../../../fields/URLField';
import { DocumentType } from '../../documents/DocumentTypes';
@@ -133,7 +132,7 @@ export class StickerPalette extends ObservableReactComponent {
this._isLoading = true;
- const prevDrawings = DocListCast(this._props.Document[DocData].data);
- this._props.Document[DocData].data = undefined;
+ const prevDrawings = DocListCast(this._props.Document.$data);
+ this._props.Document.$data = undefined;
SmartDrawHandler.Instance.AddDrawing = this.addDrawing;
this._canInteract = false;
Promise.all(
@@ -164,7 +163,7 @@ export class StickerPalette extends ObservableReactComponent {
this._gptRes.push(gptRes);
- drawing[DocData].freeform_fitContentsToBox = true;
+ drawing.$freeform_fitContentsToBox = true;
Doc.AddDocToList(this._props.Document, 'data', drawing);
};
@@ -176,17 +175,16 @@ export class StickerPalette extends ObservableReactComponent {
const cIndex = NumCast(this._props.Document.carousel_index);
const focusedDrawing = DocListCast(this._props.Document.data)[cIndex];
- const docData = focusedDrawing[DocData];
- docData.title = this._opts.text?.match(/^(.*?)~~~.*$/)?.[1] || this._opts.text;
- docData.ai_drawing_input = this._opts.text;
- docData.ai_drawing_complexity = this._opts.complexity;
- docData.ai_drawing_colored = this._opts.autoColor;
- docData.ai_drawing_size = this._opts.size;
- docData.ai_drawing_data = this._gptRes[cIndex];
- docData.ai = 'gpt';
+ focusedDrawing.$title = this._opts.text?.match(/^(.*?)~~~.*$/)?.[1] || this._opts.text;
+ focusedDrawing.$ai_drawing_input = this._opts.text;
+ focusedDrawing.$ai_drawing_complexity = this._opts.complexity;
+ focusedDrawing.$ai_drawing_colored = this._opts.autoColor;
+ focusedDrawing.$ai_drawing_size = this._opts.size;
+ focusedDrawing.$ai_drawing_data = this._gptRes[cIndex];
+ focusedDrawing.$ai = 'gpt';
focusedDrawing.width = this._opts.size;
- docData.x = this._opts.x;
- docData.y = this._opts.y;
+ focusedDrawing.x = this._opts.x;
+ focusedDrawing.y = this._opts.y;
StickerPalette.addToPalette(focusedDrawing).then(() => this.resetPalette(true));
};
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index e2f708700..4bf04da5c 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -273,12 +273,12 @@ export class Doc extends RefField {
public static AddToMyOverlay(doc: Doc) { return Doc.ActiveDashboard ? Doc.AddDocToList(Doc.ActiveDashboard, 'myOverlayDocs', doc) : Doc.AddDocToList(DocCast(Doc.UserDoc().myOverlayDocs), undefined, doc); } // prettier-ignore
public static RemFromMyOverlay(doc: Doc) { return Doc.ActiveDashboard ? Doc.RemoveDocFromList(Doc.ActiveDashboard,'myOverlayDocs', doc) : Doc.RemoveDocFromList(DocCast(Doc.UserDoc().myOverlayDocs), undefined, doc); } // prettier-ignore
public static AddToMyPublished(doc: Doc) {
- doc[DocData].title_custom = true;
- doc[DocData].layout_showTitle = 'title';
+ doc.$title_custom = true;
+ doc.$layout_showTitle = 'title';
Doc.ActiveDashboard ? Doc.AddDocToList(Doc.ActiveDashboard, 'myPublishedDocs', doc) : Doc.AddDocToList(DocCast(Doc.UserDoc().myPublishedDocs), undefined, doc); } // prettier-ignore
public static RemFromMyPublished(doc: Doc){
- doc[DocData].title_custom = false;
- doc[DocData].layout_showTitle = undefined;
+ doc.$title_custom = false;
+ doc.$layout_showTitle = undefined;
Doc.ActiveDashboard ? Doc.RemoveDocFromList(Doc.ActiveDashboard,'myPublishedDocs', doc) : Doc.RemoveDocFromList(DocCast(Doc.UserDoc().myPublishedDocs), undefined, doc); } // prettier-ignore
public static IsComicStyle(doc?: Doc) { return doc && Doc.ActiveDashboard && !Doc.IsSystem(doc) && Doc.UserDoc().renderStyle === 'comic' ; } // prettier-ignore
@@ -629,7 +629,7 @@ export namespace Doc {
*/
export function RemoveDocFromList(listDoc: Doc, fieldKey: string | undefined, doc: Doc, ignoreProto = false) {
const key = fieldKey || Doc.LayoutFieldKey(listDoc);
- const list = Doc.Get(listDoc, key, ignoreProto) === undefined ? (listDoc[DocData][key] = new List()) : Cast(listDoc[key], listSpec(Doc));
+ const list = Doc.Get(listDoc, key, ignoreProto) === undefined ? (listDoc['$' + key] = new List()) : Cast(listDoc[key], listSpec(Doc));
if (list) {
const ind = list.indexOf(doc);
if (ind !== -1) {
@@ -646,7 +646,7 @@ export namespace Doc {
*/
export function AddDocToList(listDoc: Doc, fieldKey: string | undefined, doc: Doc, relativeTo?: Doc, before?: boolean, first?: boolean, allowDuplicates?: boolean, reversed?: boolean, ignoreProto?: boolean) {
const key = fieldKey || Doc.LayoutFieldKey(listDoc);
- const list = Doc.Get(listDoc, key, ignoreProto) === undefined ? (listDoc[DocData][key] = new List()) : Cast(listDoc[key], listSpec(Doc));
+ const list = Doc.Get(listDoc, key, ignoreProto) === undefined ? (listDoc['$' + key] = new List()) : Cast(listDoc[key], listSpec(Doc));
if (list) {
if (!allowDuplicates) {
const pind = list.findIndex(d => d instanceof Doc && d[Id] === doc[Id]);
@@ -691,7 +691,7 @@ export namespace Doc {
Doc.SetLayout(embedding, Doc.MakeEmbedding(layout));
}
embedding.createdFrom = doc;
- embedding.proto_embeddingId = doc[DocData].proto_embeddingId = Doc.GetEmbeddings(doc).length - 1;
+ embedding.proto_embeddingId = doc.$proto_embeddingId = Doc.GetEmbeddings(doc).length - 1;
!Doc.GetT(embedding, 'title', 'string', true) && (embedding.title = ComputedField.MakeFunction(`renameEmbedding(this)`));
embedding.author = ClientUtils.CurrentUserEmail();
@@ -699,9 +699,8 @@ export namespace Doc {
}
export function BestEmbedding(doc: Doc) {
- const dataDoc = doc[DocData];
- const availableEmbeddings = Doc.GetEmbeddings(dataDoc);
- const bestEmbedding = [...(dataDoc !== doc ? [doc] : []), ...availableEmbeddings].find(d => !d.embedContainer && d.author === ClientUtils.CurrentUserEmail());
+ const availableEmbeddings = Doc.GetEmbeddings(doc);
+ const bestEmbedding = [...(doc[DocData] !== doc ? [doc] : []), ...availableEmbeddings].find(d => !d.embedContainer && d.author === ClientUtils.CurrentUserEmail());
bestEmbedding && Doc.AddEmbedding(doc, doc);
return bestEmbedding ?? Doc.MakeEmbedding(doc);
}
@@ -1475,7 +1474,7 @@ export namespace Doc {
* @returns
*/
export function getDescription(doc: Doc) {
- const curDescription = StrCast(doc[DocData][Doc.LayoutFieldKey(doc) + '_description']);
+ const curDescription = StrCast(doc['$' + Doc.LayoutFieldKey(doc) + '_description']);
const docText = (async (tdoc:Doc) => {
switch (tdoc.type) {
case DocumentType.PDF: return curDescription || StrCast(tdoc.text).split(/\s+/).slice(0, 50).join(' '); // first 50 words of pdf text
@@ -1484,7 +1483,7 @@ export namespace Doc {
case DocumentType.RTF: return RTFCast(tdoc[Doc.LayoutFieldKey(tdoc)]).Text;
default: return StrCast(tdoc.title).startsWith("Untitled") ? "" : StrCast(tdoc.title);
}}); // prettier-ignore
- return docText(doc).then(text => (doc[DocData][Doc.LayoutFieldKey(doc) + '_description'] = text));
+ return docText(doc).then(text => (doc['$' + Doc.LayoutFieldKey(doc) + '_description'] = text));
}
// prettier-ignore
@@ -1737,7 +1736,7 @@ ScriptingGlobals.add(function idToDoc(id: string): Doc {
});
// eslint-disable-next-line prefer-arrow-callback
ScriptingGlobals.add(function renameEmbedding(doc: Doc) {
- return StrCast(doc[DocData].title).replace(/\([0-9]*\)/, '') + `(${doc.proto_embeddingId})`;
+ return StrCast(doc.$title).replace(/\([0-9]*\)/, '') + `(${doc.proto_embeddingId})`;
});
// eslint-disable-next-line prefer-arrow-callback
ScriptingGlobals.add(function getProto(doc: Doc) {
diff --git a/src/fields/ScriptField.ts b/src/fields/ScriptField.ts
index b294ee8c6..6e2d7eb78 100644
--- a/src/fields/ScriptField.ts
+++ b/src/fields/ScriptField.ts
@@ -210,6 +210,7 @@ export class ComputedField extends ScriptField {
this._lastComputedResult =
this._cachedResult ??
computedFn(() =>
+ ((val) => val instanceof Array ? new List(val) : val)(
this.script.compiled &&
this.script.run(
{
@@ -220,7 +221,7 @@ export class ComputedField extends ScriptField {
_readOnly_: true,
},
console.log
- ).result as FieldResult
+ ).result as FieldResult)
)(); // prettier-ignore
return this._lastComputedResult;
};
--
cgit v1.2.3-70-g09d2
From 705975eb43e7904c62e7e847478f6d0dac60d443 Mon Sep 17 00:00:00 2001
From: bobzel
Date: Sun, 23 Mar 2025 18:14:31 -0400
Subject: more _props.Document to .Document refactoring. type updates to
prosemirrortransfer
---
src/client/util/SharingManager.tsx | 2 +-
src/client/views/DocComponent.tsx | 85 +++++++---
src/client/views/DocumentDecorations.tsx | 2 +-
src/client/views/FieldsDropdown.tsx | 4 +-
src/client/views/FilterPanel.tsx | 4 +-
src/client/views/LightboxView.tsx | 2 +-
src/client/views/SidebarAnnos.tsx | 24 +--
src/client/views/TemplateMenu.tsx | 1 -
src/client/views/animationtimeline/Timeline.tsx | 56 +++----
.../collections/CollectionMasonryViewFieldRow.tsx | 8 +-
.../views/collections/CollectionNoteTakingView.tsx | 15 +-
.../collections/CollectionNoteTakingViewColumn.tsx | 18 +--
.../views/collections/CollectionPivotView.tsx | 2 +-
.../views/collections/CollectionStackingView.tsx | 19 +--
.../CollectionStackingViewFieldColumn.tsx | 28 ++--
src/client/views/collections/CollectionSubView.tsx | 10 +-
.../views/collections/CollectionTimeView.tsx | 2 +-
.../views/collections/CollectionTreeView.tsx | 4 +-
src/client/views/collections/TabDocView.tsx | 28 ++--
.../CollectionFreeFormInfoUI.tsx | 14 +-
.../CollectionFreeFormPannableContents.tsx | 4 +-
.../CollectionFreeFormRemoteCursors.tsx | 2 +-
.../collectionFreeForm/CollectionFreeFormView.tsx | 48 +++---
.../collections/collectionFreeForm/MarqueeView.tsx | 1 +
.../collectionSchema/SchemaCellField.tsx | 4 +-
.../collections/collectionSchema/SchemaRowBox.tsx | 2 +-
.../collectionSchema/SchemaTableCell.tsx | 46 +++---
.../views/nodes/CollectionFreeFormDocumentView.tsx | 2 +-
src/client/views/nodes/DataVizBox/DataVizBox.tsx | 30 ++--
.../nodes/DataVizBox/components/Histogram.tsx | 13 +-
.../nodes/DataVizBox/components/LineChart.tsx | 8 +-
.../views/nodes/DataVizBox/components/PieChart.tsx | 16 +-
.../views/nodes/DataVizBox/components/TableBox.tsx | 10 +-
src/client/views/nodes/DocumentView.tsx | 4 +-
src/client/views/nodes/FieldView.tsx | 4 +-
src/client/views/nodes/ImageBox.tsx | 2 +-
src/client/views/nodes/KeyValueBox.tsx | 10 +-
src/client/views/nodes/MapBox/MapBox.tsx | 2 +-
.../views/nodes/MapboxMapBox/MapboxContainer.tsx | 3 +-
src/client/views/nodes/PDFBox.tsx | 3 +-
src/client/views/nodes/ScreenshotBox.tsx | 2 -
src/client/views/nodes/WebBox.tsx | 2 +-
.../views/nodes/formattedText/DashFieldView.tsx | 2 +-
.../views/nodes/formattedText/FormattedTextBox.tsx | 10 +-
.../formattedText/ProsemirrorExampleTransfer.ts | 174 +++++++++++----------
.../views/nodes/formattedText/SummaryView.tsx | 46 +++---
src/client/views/pdf/PDFViewer.tsx | 30 ++--
src/client/views/search/SearchBox.tsx | 16 +-
src/client/views/smartdraw/StickerPalette.tsx | 16 +-
src/fields/RichTextUtils.ts | 3 +-
src/fields/Types.ts | 5 -
src/server/DashSession/DashSessionAgent.ts | 4 +-
52 files changed, 438 insertions(+), 414 deletions(-)
(limited to 'src/client/util')
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 3a248400b..962f51cd4 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -633,7 +633,7 @@ export class SharingManager extends React.Component {
private focusOn = (contents: string) => {
const title = this.targetDoc ? StrCast(this.targetDoc.title) : '';
- const docs = DocumentView.Selected().length > 1 ? DocumentView.Selected().map(docView => docView.props.Document) : [this.targetDoc];
+ const docs = DocumentView.Selected().length > 1 ? DocumentView.Selected().map(docView => docView.Document) : [this.targetDoc];
return (
() {
}
/**
- * This is the document being rendered. In the case of a compound template, it
- * may not be the actual document rendered and it also may not be the 'real' root document.
- * Rather, it specifies the shared properties of all layouts of the document (eg, x,y,)
+ * This is the doc that is being rendered. It will be either:
+ * 1) the same as Document if the root of a regular or compound Doc is rendered
+ * 2) the same as the layoutDoc if a component of a compound Doc is rendered.
+ * NOTE: it is very unlikely that you really want to use this method. Instead
+ * consider: Document, layoutDoc, dataDoc
*/
- get Document() {
- return DocCast(this._props.Document.rootDocument, this._props.Document);
+ get _renderDoc() {
+ return this._props.Document;
}
/**
- * This is the document being rendered. It may be a template so it may or may no inherit from the data doc.
+ * This is the "root" Doc being rendered. In the case of a compound template Doc,
+ * this is the outermost Doc that represents the entire compound Doc. It is not
+ * necessarily the Doc being rendered in the current React component.
+ * This Doc inherits from the dataDoc, and may or may not inherit (or be) the layoutDoc.
+ */
+ get Document() {
+ return DocCast(this._renderDoc.rootDocument, this._renderDoc);
+ }
+ /**
+ * This is the document being rendered by the React component. In the
+ * case of a compound template, this will be the expanded template Doc
+ * that represents the component of the compound Doc being rendered.
+ * This may or may not inherit from the data doc.
*/
@computed get layoutDoc() {
- return this._props.LayoutTemplateString ? this._props.Document : Doc.Layout(this._props.Document, this._props.LayoutTemplate?.());
+ return this._props.LayoutTemplateString ? this._renderDoc : Doc.Layout(this._renderDoc, this._props.LayoutTemplate?.());
}
/**
- * This is the unique data repository for a dcoument that stores the intrinsic document data
+ * This is the unique data repository for a document that stores the intrinsic document data.
*/
@computed get dataDoc() {
- return this._props.Document[DocData];
+ return this._renderDoc[DocData];
}
}
return Component;
@@ -75,25 +89,40 @@ export function ViewBoxBaseComponent() {
}
/**
- * This is the document being rendered. In the case of a compound template, it
- * may not be the actual document rendered and it also may not be the 'real' root document.
- * Rather, it specifies the shared properties of all layouts of the document (eg, x,y,)
+ * This is the doc that is being rendered. It will be either:
+ * 1) the same as Document if the root of a regular or compound Doc is rendered
+ * 2) the same as the layoutDoc if a component of a compound Doc is rendered.
+ * NOTE: it is very unlikely that you really want to use this method. Instead
+ * consider: Document, layoutDoc, dataDoc
+ */
+ get _renderDoc() {
+ return this._props.Document;
+ }
+
+ /**
+ * This is the "root" Doc being rendered. In the case of a compound template Doc,
+ * this is the outermost Doc that represents the entire compound Doc. It is not
+ * necessarily the Doc being rendered in the current React component.
+ * This Doc inherits from the dataDoc, and may or may not inherit (or be) the layoutDoc.
*/
get Document() {
- return DocCast(this._props.Document.rootDocument, this._props.Document);
+ return DocCast(this._renderDoc.rootDocument, this._renderDoc);
}
/**
- * This is the document being rendered. It may be a template so it may or may no inherit from the data doc.
+ * This is the document being rendered by the React component. In the
+ * case of a compound template, this will be the expanded template Doc
+ * that represents the component of the compound Doc being rendered.
+ * This may or may not inherit from the data doc.
*/
@computed get layoutDoc() {
- return Doc.Layout(this._props.Document);
+ return Doc.Layout(this._renderDoc);
}
/**
* This is the unique data repository for a dcoument that stores the intrinsic document data
*/
@computed get dataDoc() {
- return this._props.Document.isTemplateForField || this._props.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._props.Document[DocData]) : this._props.Document[DocData];
+ return this._renderDoc.isTemplateForField || this._renderDoc.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._renderDoc[DocData]) : this._renderDoc[DocData];
}
/**
@@ -133,25 +162,37 @@ export function ViewBoxAnnotatableComponent
() {
}
/**
- * This is the document being rendered. In the case of a compound template, it
- * may not be the actual document rendered and it also may not be the 'real' root document.
- * Rather, it specifies the shared properties of all layouts of the document (eg, x,y,)
+ * This is the doc that is being rendered. It will be either:
+ * 1) the same as Document if the root of a regular or compound Doc is rendered
+ * 2) the same as the layoutDoc if a component of a compound Doc is rendered.
+ * NOTE: it would unlikely that you really want to use this instead of the
+ * other Doc options (Document, layoutDoc, dataDoc)
+ */
+ get _renderDoc() {
+ return this._props.Document;
+ }
+
+ /**
+ * This is the "root" Doc being rendered. In the case of a compound template Doc,
+ * this is the outermost Doc that represents the entire compound Doc. It is not
+ * necessarily the Doc being rendered in the current React component.
+ * This Doc inherits from the dataDoc, and may or may not inherit (or be) the layoutDoc.
*/
@computed get Document() {
- return DocCast(this._props.Document.rootDocument, this._props.Document);
+ return DocCast(this._renderDoc.rootDocument, this._renderDoc);
}
/**
* This is the document being rendered. It may be a template so it may or may no inherit from the data doc.
*/
@computed get layoutDoc() {
- return Doc.Layout(this._props.Document);
+ return Doc.Layout(this._renderDoc);
}
/**
* This is the unique data repository for a dcoument that stores the intrinsic document data
*/
@computed get dataDoc() {
- return this._props.Document.isTemplateForField || this._props.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._props.Document[DocData]) : this._props.Document[DocData];
+ return this._renderDoc.isTemplateForField || this._renderDoc.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._renderDoc[DocData]) : this._props.Document[DocData];
}
/**
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 92b4d6fbf..19b987cb5 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -635,7 +635,7 @@ export class DocumentDecorations extends ObservableReactComponent void;
menuClose?: () => void;
placeholder?: string | (() => string);
@@ -36,7 +36,7 @@ export class FieldsDropdown extends ObservableReactComponent();
- SearchUtil.foreachRecursiveDoc([this._props.Document], (depth, doc) => allDocs.add(doc));
+ SearchUtil.foreachRecursiveDoc([this._props.Doc], (depth, doc) => allDocs.add(doc));
return Array.from(allDocs);
}
diff --git a/src/client/views/FilterPanel.tsx b/src/client/views/FilterPanel.tsx
index 4fc8d7a68..c3b3f9d0c 100644
--- a/src/client/views/FilterPanel.tsx
+++ b/src/client/views/FilterPanel.tsx
@@ -379,7 +379,7 @@ export class FilterPanel extends ObservableReactComponent {
-
+
{/* THE FOLLOWING CODE SHOULD BE DEVELOPER FOR BOOLEAN EXPRESSION (AND / OR) */}
{/*
@@ -443,7 +443,7 @@ export class FilterPanel extends ObservableReactComponent
{
diff --git a/src/client/views/LightboxView.tsx b/src/client/views/LightboxView.tsx
index 5698da785..de2c7cd09 100644
--- a/src/client/views/LightboxView.tsx
+++ b/src/client/views/LightboxView.tsx
@@ -317,7 +317,7 @@ export class LightboxView extends ObservableReactComponent {
- {this._showPalette &&
(this._annoPaletteView = r)} Document={DocCast(Doc.UserDoc().myLightboxDrawings)} />}
+ {this._showPalette && (this._annoPaletteView = r)} Doc={DocCast(Doc.UserDoc().myLightboxDrawings)} />}
{this.renderNavBtn(0, undefined, this._props.PanelHeight / 2 - 12.5, 'chevron-left', this._doc && this._history.length ? true : false, this.previous)}
{this.renderNavBtn(
this._props.PanelWidth - Math.min(this._props.PanelWidth / 4, this._props.maxBorder[0]),
diff --git a/src/client/views/SidebarAnnos.tsx b/src/client/views/SidebarAnnos.tsx
index b3f3a4478..3c0611f03 100644
--- a/src/client/views/SidebarAnnos.tsx
+++ b/src/client/views/SidebarAnnos.tsx
@@ -22,7 +22,7 @@ import { FieldViewProps } from './nodes/FieldView';
interface ExtraProps {
fieldKey: string;
- Document: Doc;
+ Doc: Doc;
layoutDoc: Doc;
dataDoc: Doc;
// usePanelWidth: boolean;
@@ -45,7 +45,7 @@ export class SidebarAnnos extends ObservableReactComponent();
@computed get allMetadata() {
const keys = new Map>();
- DocListCast(this._props.Document[this.sidebarKey]).forEach(doc =>
+ DocListCast(this._props.Doc[this.sidebarKey]).forEach(doc =>
SearchUtil.documentKeys(doc)
.filter(key => key[0] && key[0] !== '_' && key[0] === key[0].toUpperCase())
.map(key => keys.set(key, doc[key]))
@@ -54,7 +54,7 @@ export class SidebarAnnos extends ObservableReactComponent();
- DocListCast(this._props.Document[this.sidebarKey]).forEach(doc => StrListCast(doc.tags).forEach(tag => keys.add(tag)));
+ DocListCast(this._props.Doc[this.sidebarKey]).forEach(doc => StrListCast(doc.tags).forEach(tag => keys.add(tag)));
return Array.from(keys.keys())
.filter(key => key[0])
.filter(key => !key.startsWith('_') && (key[0] === '#' || key[0] === key[0].toUpperCase()))
@@ -62,7 +62,7 @@ export class SidebarAnnos extends ObservableReactComponent();
- DocListCast(this._props.Document[this.sidebarKey]).forEach(doc => keys.add(StrCast(doc.author)));
+ DocListCast(this._props.Doc[this.sidebarKey]).forEach(doc => keys.add(StrCast(doc.author)));
return Array.from(keys.keys()).sort();
}
@@ -72,7 +72,7 @@ export class SidebarAnnos extends ObservableReactComponent data.split(':')[0])
.filter(data => !filterExlusions?.includes(data.split(':')[0]))
.map(data => {
- const key = '$'+data.split(':')[0];
+ const key = '$' + data.split(':')[0];
const val = Field.Copy(this.allMetadata.get(key));
target[key] = val;
return {
@@ -148,7 +148,7 @@ export class SidebarAnnos extends ObservableReactComponent {
- if (DocListCast(this._props.Document[this.sidebarKey]).find(anno => Doc.AreProtosEqual(doc.layout_unrendered ? DocCast(doc.annotationOn) : doc, anno))) {
+ if (DocListCast(this._props.Doc[this.sidebarKey]).find(anno => Doc.AreProtosEqual(doc.layout_unrendered ? DocCast(doc.annotationOn) : doc, anno))) {
if (this.childFilters()) {
// if any child filters exist, get rid of them
this._props.layoutDoc._childFilters = new List();
@@ -189,7 +189,7 @@ export class SidebarAnnos extends ObservableReactComponent {
const active = this.childFilters().includes(`tags${Doc.FilterSep}${tag}${Doc.FilterSep}check`);
return (
- Doc.setDocFilter(this._props.Document, 'tags', tag, 'check', true, undefined, e.shiftKey)}>
+
Doc.setDocFilter(this._props.Doc, 'tags', tag, 'check', true, undefined, e.shiftKey)}>
{tag}
);
@@ -197,7 +197,7 @@ export class SidebarAnnos extends ObservableReactComponent
{
const active = this.childFilters().includes(`${tag}${Doc.FilterSep}${Doc.FilterAny}${Doc.FilterSep}exists`);
return (
- Doc.setDocFilter(this._props.Document, tag, Doc.FilterAny, 'exists', true, undefined, e.shiftKey)}>
+
Doc.setDocFilter(this._props.Doc, tag, Doc.FilterAny, 'exists', true, undefined, e.shiftKey)}>
{tag}
);
@@ -205,7 +205,7 @@ export class SidebarAnnos extends ObservableReactComponent
{
const active = this.childFilters().includes(`author:${user}:check`);
return (
- Doc.setDocFilter(this._props.Document, 'author', user, 'check', true, undefined, e.shiftKey)}>
+
Doc.setDocFilter(this._props.Doc, 'author', user, 'check', true, undefined, e.shiftKey)}>
{user}
);
@@ -216,9 +216,9 @@ export class SidebarAnnos extends ObservableReactComponent
diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx
index 680c8ed0e..1266a11c1 100644
--- a/src/client/views/TemplateMenu.tsx
+++ b/src/client/views/TemplateMenu.tsx
@@ -80,7 +80,6 @@ export class TemplateMenu extends React.Component {
const addedTypes = DocListCast(Cast(Doc.UserDoc().template_clickFuncs, Doc, null)?.data);
const templateMenu: Array = [];
templateMenu.push( );
- // eslint-disable-next-line no-return-assign
addedTypes.concat(noteTypes).map(template => (template.treeView_Checked = this.templateIsUsed(firstDoc, template)));
this._addedKeys &&
Array.from(this._addedKeys)
diff --git a/src/client/views/animationtimeline/Timeline.tsx b/src/client/views/animationtimeline/Timeline.tsx
index 15683ebf2..cd2c7df1b 100644
--- a/src/client/views/animationtimeline/Timeline.tsx
+++ b/src/client/views/animationtimeline/Timeline.tsx
@@ -46,7 +46,7 @@ import { Id } from '../../../fields/FieldSymbols';
*/
@observer
-export class Timeline extends ObservableReactComponent {
+export class Timeline extends ObservableReactComponent {
// readonly constants
private readonly DEFAULT_TICK_SPACING: number = 50;
private readonly MAX_TITLE_HEIGHT = 75;
@@ -57,7 +57,7 @@ export class Timeline extends ObservableReactComponent {
private DEFAULT_CONTAINER_HEIGHT: number = 330;
private MIN_CONTAINER_HEIGHT: number = 205;
- constructor(props: FieldViewProps) {
+ constructor(props: FieldViewProps & { Doc: Doc }) {
super(props);
makeObservable(this);
}
@@ -90,11 +90,11 @@ export class Timeline extends ObservableReactComponent {
*/
@computed
private get children(): Doc[] {
- const annotatedDoc = [DocumentType.IMG, DocumentType.VID, DocumentType.PDF, DocumentType.MAP].includes(StrCast(this._props.Document.type) as unknown as DocumentType);
+ const annotatedDoc = [DocumentType.IMG, DocumentType.VID, DocumentType.PDF, DocumentType.MAP].includes(StrCast(this._props.Doc.type) as unknown as DocumentType);
if (annotatedDoc) {
- return DocListCast(this._props.Document[Doc.LayoutFieldKey(this._props.Document) + '_annotations']);
+ return DocListCast(this._props.Doc[Doc.LayoutFieldKey(this._props.Doc) + '_annotations']);
}
- return DocListCast(this._props.Document[this._props.fieldKey]);
+ return DocListCast(this._props.Doc[this._props.fieldKey]);
}
/// //////lifecycle functions////////////
@@ -104,21 +104,21 @@ export class Timeline extends ObservableReactComponent {
this._titleHeight = relativeHeight < this.MAX_TITLE_HEIGHT ? relativeHeight : this.MAX_TITLE_HEIGHT; // check if relHeight is less than Maxheight. Else, just set relheight to max
this.MIN_CONTAINER_HEIGHT = this._titleHeight + 130; // offset
this.DEFAULT_CONTAINER_HEIGHT = this._titleHeight * 2 + 130; // twice the titleheight + offset
- if (!this._props.Document.AnimationLength) {
+ if (!this._props.Doc.AnimationLength) {
// if animation length did not exist
- this._props.Document.AnimationLength = this._time; // set it to default time
+ this._props.Doc.AnimationLength = this._time; // set it to default time
} else {
- this._time = NumCast(this._props.Document.AnimationLength); // else, set time to animationlength stored from before
+ this._time = NumCast(this._props.Doc.AnimationLength); // else, set time to animationlength stored from before
}
this._totalLength = this._tickSpacing * (this._time / this._tickIncrement); // the entire length of the timeline div (actual div part itself)
this._visibleLength = this._infoContainer.current!.getBoundingClientRect().width; // the visible length of the timeline (the length that you current see)
this._visibleStart = this._infoContainer.current!.scrollLeft; // where the div starts
- this._props.Document.isATOn = !this._props.Document.isATOn; // turns the boolean on, saying AT (animation timeline) is on
+ this._props.Doc.isATOn = !this._props.Doc.isATOn; // turns the boolean on, saying AT (animation timeline) is on
this.toggleHandle();
}
componentWillUnmount() {
- this._props.Document.AnimationLength = this._time; // save animation length
+ this._props.Doc.AnimationLength = this._time; // save animation length
}
/// //////////////////////////////////////////////
@@ -224,7 +224,7 @@ export class Timeline extends ObservableReactComponent {
*/
@action
onPanDown = (e: React.PointerEvent) => {
- setupMoveUpEvents(this, e, this.onPanMove, emptyFunction, e => this.changeCurrentBarX(this._trackbox.current!.scrollLeft + e.clientX - this._trackbox.current!.getBoundingClientRect().left));
+ setupMoveUpEvents(this, e, this.onPanMove, emptyFunction, movEv => this.changeCurrentBarX(this._trackbox.current!.scrollLeft + movEv.clientX - this._trackbox.current!.getBoundingClientRect().left));
};
/**
@@ -241,7 +241,7 @@ export class Timeline extends ObservableReactComponent {
this._visibleStart -= e.movementX;
this._totalLength -= e.movementX;
this._time -= RegionHelpers.convertPixelTime(e.movementX, 'mili', 'time', this._tickSpacing, this._tickIncrement);
- this._props.Document.AnimationLength = this._time;
+ this._props.Doc.AnimationLength = this._time;
}
return false;
};
@@ -259,8 +259,8 @@ export class Timeline extends ObservableReactComponent {
setupMoveUpEvents(
this,
e,
- action(e => {
- const offset = e.clientY - this._timelineContainer.current!.getBoundingClientRect().bottom;
+ action(movEv => {
+ const offset = movEv.clientY - this._timelineContainer.current!.getBoundingClientRect().bottom;
this._containerHeight = clamp(this.MIN_CONTAINER_HEIGHT, this._containerHeight + offset, this.MAX_CONTAINER_HEIGHT);
return false;
}),
@@ -358,7 +358,7 @@ export class Timeline extends ObservableReactComponent {
const size = 40 * scale; // 50 is default
const iconSize = 25;
const width: number = this._props.PanelWidth();
- const modeType = this._props.Document.isATOn ? 'Author' : 'Play';
+ const modeType = this._props.Doc.isATOn ? 'Author' : 'Play';
// decides if information should be omitted because the timeline is very small
// if its less than 950 pixels then it's going to be overlapping
@@ -397,7 +397,7 @@ export class Timeline extends ObservableReactComponent {
tickIncrement={this._tickIncrement}
time={this._time}
parent={this}
- isAuthoring={BoolCast(this._props.Document.isATOn)}
+ isAuthoring={BoolCast(this._props.Doc.isATOn)}
currentBarX={this._currentBarX}
totalLength={this._totalLength}
visibleLength={this._visibleLength}
@@ -418,10 +418,10 @@ export class Timeline extends ObservableReactComponent {
{this.timeIndicator(lengthString, totalTime)}
-
this.resetView(this._props.Document)}>
+
this.resetView(this._props.Doc)}>
-
this.setView(this._props.Document)}>
+
this.setView(this._props.Doc)}>
@@ -431,17 +431,17 @@ export class Timeline extends ObservableReactComponent
{
};
timeIndicator(lengthString: string, totalTime: number) {
- if (this._props.Document.isATOn) {
- return {`Total: ${this.toReadTime(totalTime)}`}
;
+ if (this._props.Doc.isATOn) {
+ return {`Total: ${this.toReadTime(totalTime)}`}
;
} else {
const ctime = `Current: ${this.getCurrentTime()}`;
const ttime = `Total: ${this.toReadTime(this._time)}`;
return (
-
+
{ctime}
-
@@ -467,8 +467,8 @@ export class Timeline extends ObservableReactComponent
{
const roundToggleContainer = this._roundToggleContainerRef.current!;
const timelineContainer = this._timelineContainer.current!;
- this._props.Document.isATOn = !this._props.Document.isATOn;
- if (!BoolCast(this._props.Document.isATOn)) {
+ this._props.Doc.isATOn = !this._props.Doc.isATOn;
+ if (!BoolCast(this._props.Doc.isATOn)) {
// turning on playmode...
roundToggle.style.transform = 'translate(0px, 0px)';
roundToggle.style.animationName = 'turnoff';
@@ -543,7 +543,7 @@ export class Timeline extends ObservableReactComponent {
// change visible and total width
return (
-
+
{this.drawTicks()}
@@ -551,7 +551,7 @@ export class Timeline extends ObservableReactComponent
{
- {[...this.children, this._props.Document].map(doc => (
+ {[...this.children, this._props.Doc].map(doc => (
this.mapOfTracks.push(ref)}
@@ -563,7 +563,7 @@ export class Timeline extends ObservableReactComponent {
time={this._time}
tickSpacing={this._tickSpacing}
tickIncrement={this._tickIncrement}
- collection={this._props.Document}
+ collection={this._props.Doc}
timelineVisible={true}
/>
))}
@@ -571,7 +571,7 @@ export class Timeline extends ObservableReactComponent {
Current: {this.getCurrentTime()}
- {[...this.children, this._props.Document].map(doc => (
+ {[...this.children, this._props.Doc].map(doc => (
Doc.BrushDoc(doc)} onPointerOut={() => Doc.UnBrushDoc(doc)}>
{StrCast(doc.title)}
diff --git a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
index 4fe73895e..89ccf5a0f 100644
--- a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
+++ b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
@@ -22,7 +22,7 @@ import './CollectionStackingView.scss';
interface CMVFieldRowProps {
rows: () => number;
headings: () => object[];
- Document: Doc;
+ Doc: Doc;
chromeHidden?: boolean;
heading: string;
headingObject: SchemaHeaderField | undefined;
@@ -73,7 +73,7 @@ export class CollectionMasonryViewFieldRow extends ObservableReactComponent
{
this._dropDisposer?.();
- if (ele) this._dropDisposer = DragManager.MakeDropTarget(ele, this.rowDrop.bind(this), this._props.Document);
+ if (ele) this._dropDisposer = DragManager.MakeDropTarget(ele, this.rowDrop.bind(this), this._props.Doc);
else if (this._ele) this.props.refList.splice(this.props.refList.indexOf(this._ele), 1);
this._ele = ele;
};
@@ -189,7 +189,7 @@ export class CollectionMasonryViewFieldRow extends ObservableReactComponent {
- const embedding = Doc.MakeEmbedding(this._props.Document);
+ const embedding = Doc.MakeEmbedding(this._props.Doc);
const key = this._props.pivotField;
let value = this.getValue(this.heading);
value = typeof value === 'string' ? `"${value}"` : value;
@@ -289,7 +289,7 @@ export class CollectionMasonryViewFieldRow extends ObservableReactComponent evContents} SetValue={this.headingChanged} contents={evContents} oneLine />;
- return this._props.Document.miniHeaders ? (
+ return this._props.Doc.miniHeaders ? (
{editableHeaderView}
) : !this._props.headingObject ? null : (
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index 4650727eb..2dabd3269 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -32,6 +32,7 @@ import { CollectionNoteTakingViewColumn } from './CollectionNoteTakingViewColumn
import { CollectionNoteTakingViewDivider } from './CollectionNoteTakingViewDivider';
import { CollectionSubView, SubCollectionViewProps } from './CollectionSubView';
import { Property } from 'csstype';
+import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox';
/**
* CollectionNoteTakingView is a column-based view for displaying documents. In this view, the user can (1)
@@ -437,10 +438,10 @@ export class CollectionNoteTakingView extends CollectionSubView() {
};
@undoBatch
- onKeyDown = (e: React.KeyboardEvent, fieldProps: FieldViewProps) => {
- if ((e.ctrlKey || fieldProps.Document._createDocOnCR) && ['Enter'].includes(e.key)) {
+ onKeyDown = (e: React.KeyboardEvent, textBox: FormattedTextBox) => {
+ if ((e.ctrlKey || textBox.Document._createDocOnCR) && ['Enter'].includes(e.key)) {
e.stopPropagation?.();
- const newDoc = Doc.MakeCopy(fieldProps.Document, true);
+ const newDoc = Doc.MakeCopy(textBox.Document, true);
newDoc.$text = undefined;
DocumentView.SetSelectOnLoad(newDoc);
return this.addDocument?.(newDoc);
@@ -543,8 +544,8 @@ export class CollectionNoteTakingView extends CollectionSubView() {
addDocument={this.addDocument}
chromeHidden={this.chromeHidden}
colHeaderData={this.colHeaderData}
- Document={this.Document}
- TemplateDataDocument={this._props.TemplateDataDocument}
+ Doc={this.Document}
+ TemplateDataDoc={this._props.TemplateDataDocument}
resizeColumns={this.resizeColumns}
renderChildren={this.children}
numGroupColumns={this.numGroupColumns}
@@ -567,7 +568,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
@undoBatch
remColumn = (value: SchemaHeaderField) => {
- const colHdrData = Array.from(Cast(this._props.Document[this._props.fieldKey + '_columnHeaders'], listSpec(SchemaHeaderField), null));
+ const colHdrData = Array.from(Cast(this.Document[this._props.fieldKey + '_columnHeaders'], listSpec(SchemaHeaderField), null));
if (value) {
const index = colHdrData.indexOf(value);
index !== -1 && colHdrData.splice(index, 1);
@@ -701,7 +702,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
{this.renderedSections}
{
this.layoutDoc._pivotField = fieldKey;
this.removeEmptyColumns();
diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index df9b5a1eb..f283b0abe 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -21,8 +21,8 @@ import './CollectionNoteTakingView.scss';
import { DocumentView } from '../nodes/DocumentView';
interface CSVFieldColumnProps {
- Document: Doc;
- TemplateDataDocument: Opt;
+ Doc: Doc;
+ TemplateDataDoc: Opt;
backgroundColor?: () => string | undefined;
docList: Doc[];
heading: string;
@@ -65,7 +65,7 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent hd.heading === this._props.headingObject?.heading && hd.color === this._props.headingObject.color);
return ((this._props.colHeaderData[i].width * this._props.availableWidth) / this._props.PanelWidth()) * 100 + '%';
@@ -81,7 +81,7 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent {
this.dropDisposer?.();
- if (ele) this.dropDisposer = DragManager.MakeDropTarget(ele, this.columnDrop.bind(this), this._props.Document);
+ if (ele) this.dropDisposer = DragManager.MakeDropTarget(ele, this.columnDrop.bind(this), this._props.Doc);
else if (this._ele) this.props.refList.slice(this.props.refList.indexOf(this._ele), 1);
this._ele = ele;
};
@@ -155,7 +155,7 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent {
- const colHdrData = Array.from(Cast(this._props.Document[this._props.fieldKey + '_columnHeaders'], listSpec(SchemaHeaderField), null));
+ const colHdrData = Array.from(Cast(this._props.Doc[this._props.fieldKey + '_columnHeaders'], listSpec(SchemaHeaderField), null));
if (this._props.headingObject) {
// this._props.docList.forEach(d => (d['$'+this._props.pivotField] = undefined));
colHdrData.splice(colHdrData.indexOf(this._props.headingObject), 1);
@@ -184,11 +184,11 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent {
- Doc.GetProto(this._props.Document)[name] = '';
+ Doc.GetProto(this._props.Doc)[name] = '';
const created = Docs.Create.TextDocument('', { title: name, _width: 250, _layout_autoHeight: true });
if (created) {
- if (this._props.Document.isTemplateDoc) {
- Doc.MakeMetadataFieldTemplate(created, this._props.Document);
+ if (this._props.Doc.isTemplateDoc) {
+ Doc.MakeMetadataFieldTemplate(created, this._props.Doc);
}
this._props.addDocument?.(created);
}
@@ -267,7 +267,7 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent h[0] === this._props.headingObject) === 0 ? NumCast(this._props.Document.xMargin) : 0,
+ marginLeft: this._props.headings().findIndex(h => h[0] === this._props.headingObject) === 0 ? NumCast(this._props.Doc.xMargin) : 0,
}}>