aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/documents/DocUtils.ts11
-rw-r--r--src/client/util/CalendarManager.tsx11
-rw-r--r--src/client/util/CurrentUserUtils.ts17
-rw-r--r--src/client/util/DictationManager.ts6
-rw-r--r--src/client/util/DocumentManager.ts11
-rw-r--r--src/client/util/DragManager.ts5
-rw-r--r--src/client/util/History.ts2
-rw-r--r--src/client/util/Import & Export/ImageUtils.ts14
-rw-r--r--src/client/views/DashboardView.tsx26
-rw-r--r--src/client/views/DocComponent.tsx14
-rw-r--r--src/client/views/DocumentDecorations.tsx4
-rw-r--r--src/client/views/FilterPanel.tsx3
-rw-r--r--src/client/views/InkStrokeProperties.ts3
-rw-r--r--src/client/views/MainView.tsx3
-rw-r--r--src/client/views/MarqueeAnnotator.tsx22
-rw-r--r--src/client/views/PinFuncs.ts3
-rw-r--r--src/client/views/PropertiesButtons.tsx6
-rw-r--r--src/client/views/PropertiesView.tsx42
-rw-r--r--src/client/views/ScriptBox.tsx6
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx13
-rw-r--r--src/client/views/nodes/DocumentView.tsx36
-rw-r--r--src/client/views/nodes/KeyValueBox.tsx36
-rw-r--r--src/client/views/nodes/KeyValuePair.tsx18
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx9
-rw-r--r--src/client/views/nodes/formattedText/RichTextRules.ts36
-rw-r--r--src/client/views/nodes/trails/PresBox.tsx10
-rw-r--r--src/client/views/pdf/PDFViewer.tsx2
-rw-r--r--src/client/views/search/FaceRecognitionHandler.tsx21
-rw-r--r--src/client/views/search/SearchBox.tsx1
-rw-r--r--src/client/views/smartdraw/DrawingFillHandler.tsx6
-rw-r--r--src/fields/Doc.ts14
-rw-r--r--src/fields/util.ts10
32 files changed, 203 insertions, 218 deletions
diff --git a/src/client/documents/DocUtils.ts b/src/client/documents/DocUtils.ts
index 1c7ccadd1..13f6f6920 100644
--- a/src/client/documents/DocUtils.ts
+++ b/src/client/documents/DocUtils.ts
@@ -8,7 +8,6 @@ import * as JSZipUtils from '../../JSZipUtils';
import { decycle } from '../../decycler/decycler';
import { DateField } from '../../fields/DateField';
import { Doc, DocListCast, Field, FieldResult, FieldType, LinkedTo, Opt, StrListCast } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { Id } from '../../fields/FieldSymbols';
import { InkData, InkDataFieldName, InkField } from '../../fields/InkField';
import { List, ListFieldName } from '../../fields/List';
@@ -383,10 +382,10 @@ export namespace DocUtils {
event: undoable(() => {
const newDoc = DocUtils.copyDragFactory(dragDoc);
if (newDoc) {
- newDoc.author = ClientUtils.CurrentUserEmail();
- newDoc.x = x;
- newDoc.y = y;
- newDoc[DocData].backgroundColor = Doc.UserDoc().textBackgroundColor;
+ newDoc._author = ClientUtils.CurrentUserEmail();
+ newDoc._x = x;
+ newDoc._y = y;
+ newDoc.$backgroundColor = Doc.UserDoc().textBackgroundColor;
DocumentView.SetSelectOnLoad(newDoc);
if (pivotField) {
newDoc[pivotField] = pivotValue;
@@ -745,7 +744,7 @@ export namespace DocUtils {
if (defaultTextTemplate) {
tbox.layout_fieldKey = 'layout_' + StrCast(defaultTextTemplate.title);
Doc.GetProto(tbox)[StrCast(tbox.layout_fieldKey)] = defaultTextTemplate; // set the text doc's layout to render with the text template
- tbox[DocData].proto = defaultTextTemplate; // and also set the text doc to inherit from the template (this allows the template to specify default field values)
+ tbox.$proto = defaultTextTemplate; // and also set the text doc to inherit from the template (this allows the template to specify default field values)
}
return tbox;
}
diff --git a/src/client/util/CalendarManager.tsx b/src/client/util/CalendarManager.tsx
index d28b3a2c9..a0db4e32e 100644
--- a/src/client/util/CalendarManager.tsx
+++ b/src/client/util/CalendarManager.tsx
@@ -8,7 +8,6 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import Select from 'react-select';
import { Doc, DocListCast } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { StrCast } from '../../fields/Types';
import { Docs } from '../documents/Documents';
import { MainViewModal } from '../views/MainViewModal';
@@ -51,8 +50,6 @@ export class CalendarManager extends ObservableReactComponent<object> {
@observable private targetDocView: DocumentView | undefined = undefined; // the DocumentView of the target doc
@observable private dialogueBoxOpacity = 1; // for the modal
- @observable private layoutDocAcls: boolean = false; // whether the layout doc or data doc's acls are to be used
-
@observable private creationType: CreationType = 'new-calendar';
@observable private existingCalendars: Doc[] = DocListCast(Doc.MyCalendars?.data);
@@ -97,7 +94,6 @@ export class CalendarManager extends ObservableReactComponent<object> {
}),
500
);
- this.layoutDocAcls = false;
});
constructor(props: object) {
@@ -122,9 +118,8 @@ export class CalendarManager extends ObservableReactComponent<object> {
// TODO: Make undoable
private addToCalendar = () => {
const docs = DocumentView.Selected().length < 2 ? [this.targetDoc] : DocumentView.Selected().map(docView => docView.Document);
- const targetDoc = this.layoutDocAcls ? docs[0] : docs[0]?.[DocData]; // doc to add to calendar
+ const targetDoc = docs[0]; // doc to add to calendar
- console.log(targetDoc);
if (targetDoc) {
let calendar: Doc;
if (this.creationType === 'new-calendar') {
@@ -234,7 +229,7 @@ export class CalendarManager extends ObservableReactComponent<object> {
@computed
get calendarInterface() {
const docs = DocumentView.Selected().length < 2 ? [this.targetDoc] : DocumentView.Selected().map(docView => docView.Document);
- const targetDoc = this.layoutDocAcls ? docs[0] : docs[0]?.[DocData];
+ const targetDoc = docs[0];
return (
<div
@@ -324,7 +319,7 @@ export class CalendarManager extends ObservableReactComponent<object> {
<div className="date-range-picker-container">
<div>Select a date range: </div>
<Provider theme={defaultTheme}>
- <DateRangePicker aria-label="Select a date range" value={this.selectedDateRange} onChange={v => this.setSelectedDateRange(v)} />
+ <DateRangePicker aria-label="Select a date range" value={this.selectedDateRange} onChange={v => v && this.setSelectedDateRange(v)} />
</Provider>
</div>
{this.createButtonActive && (
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 21e1d3e12..924041552 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -3,7 +3,6 @@ import { reaction, runInAction } from "mobx";
import * as rp from 'request-promise';
import { ClientUtils, OmitKeys } from "../../ClientUtils";
import { Doc, DocListCast, DocListCastAsync, FieldType, Opt } from "../../fields/Doc";
-import { DocData } from "../../fields/DocSymbols";
import { InkEraserTool, InkInkTool, InkProperty, InkTool } from "../../fields/InkField";
import { List } from "../../fields/List";
import { PrefetchProxy } from "../../fields/Proxy";
@@ -323,10 +322,10 @@ export class CurrentUserUtils {
type: 'scatter'
}`);
const slide = Docs.Create.TextDocument("", opts);
- slide[DocData].text = rtfield;
- slide[DocData].layout_textPainted = `<CollectionView {...props} fieldKey={'text'}/>`;
- slide[DocData]._type_collection = CollectionViewType.Freeform;
- slide.onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
+ slide.$text = rtfield;
+ slide.$layout_textPainted = `<CollectionView {...props} fieldKey={'text'}/>`;
+ slide.$type_collection = CollectionViewType.Freeform;
+ slide._onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
return slide;
}
const mermaidsApi = () => {
@@ -374,10 +373,10 @@ pie title Minerals in my tap water
"Potassium" : 50
"Magnesium" : 10.01`);
const slide = Docs.Create.TextDocument("", opts);
- slide[DocData].text = rtfield;
- slide[DocData].layout_textPainted = `<CollectionView {...props} fieldKey={'text'}/>`;
- slide[DocData]._type_collection = CollectionViewType.Freeform;
- slide.onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
+ slide.$text = rtfield;
+ slide.$layout_textPainted = `<CollectionView {...props} fieldKey={'text'}/>`;
+ slide.$_type_collection = CollectionViewType.Freeform;
+ slide._onPaint = ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, {documentView:"any"});
return slide;
}
plotlyApi(); mermaidsApi();
diff --git a/src/client/util/DictationManager.ts b/src/client/util/DictationManager.ts
index 897366757..44fbda319 100644
--- a/src/client/util/DictationManager.ts
+++ b/src/client/util/DictationManager.ts
@@ -2,7 +2,6 @@
import * as interpreter from 'words-to-numbers';
import { ClientUtils } from '../../ClientUtils';
import { Doc, Opt } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { List } from '../../fields/List';
import { RichTextField } from '../../fields/RichTextField';
import { listSpec } from '../../fields/Schema';
@@ -339,13 +338,12 @@ export namespace DictationManager {
{
action: (target: DocumentView) => {
const newBox = Docs.Create.TextDocument('', { _width: 400, _height: 200, title: 'My Outline', _layout_autoHeight: true });
- const proto = newBox[DocData];
const prompt = 'Press alt + r to start dictating here...';
const head = 3;
const anchor = head + prompt.length;
const proseMirrorState = `{"doc":{"type":"doc","content":[{"type":"ordered_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"type":"text","text":"${prompt}"}]}]}]}]},"selection":{"type":"text","anchor":${anchor},"head":${head}}}`;
- proto.data = new RichTextField(proseMirrorState, prompt);
- proto.backgroundColor = '#eeffff';
+ newBox.$data = new RichTextField(proseMirrorState, prompt);
+ newBox.$backgroundColor = '#eeffff';
target.props.addDocTab(newBox, OpenWhere.addRight);
},
},
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index e33449782..5ce005811 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -2,7 +2,6 @@ import { Howl } from 'howler';
import { action, computed, makeObservable, observable, ObservableSet, observe } from 'mobx';
import { Doc, Opt } from '../../fields/Doc';
import { Animation, DocData } from '../../fields/DocSymbols';
-import { Id } from '../../fields/FieldSymbols';
import { listSpec } from '../../fields/Schema';
import { Cast, DocCast, NumCast, StrCast } from '../../fields/Types';
import { AudioField } from '../../fields/URLField';
@@ -108,16 +107,16 @@ export class DocumentManager {
});
// gets all views
- public getDocumentViewsById(id: string) {
+ public getAllDocumentViews(doc: Doc) {
const toReturn: DocumentView[] = [];
DocumentManager.Instance.DocumentViews.forEach(view => {
- if (view.Document[Id] === id) {
+ if (view.Document === doc) {
toReturn.push(view);
}
});
if (toReturn.length === 0) {
DocumentManager.Instance.DocumentViews.forEach(view => {
- if (view.Document[DocData]?.[Id] === id) {
+ if (view.Document[DocData] === doc) {
toReturn.push(view);
}
});
@@ -125,10 +124,6 @@ export class DocumentManager {
return toReturn;
}
- public getAllDocumentViews(doc: Doc) {
- return this.getDocumentViewsById(doc[Id]);
- }
-
public getDocumentView(target: Doc | undefined, preferredCollection?: DocumentView): DocumentView | undefined {
const docViewArray = DocumentManager.Instance.DocumentViews;
const passes = !target ? [] : preferredCollection ? [preferredCollection, undefined] : [undefined];
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 2a7859f09..e2e4c0fe4 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -280,11 +280,12 @@ export namespace DragManager {
export function StartButtonDrag(eles: HTMLElement[], script: string, title: string, vars: { [name: string]: FieldType }, params: string[], initialize: (button: Doc) => void, downX: number, downY: number, options?: DragOptions) {
const finishDrag = (e: DragCompleteEvent) => {
const bd = Docs.Create.ButtonDocument({ toolTip: title, z: 1, _width: 150, _height: 50, title, onClick: ScriptField.MakeScript(script) });
+ const bdData = bd[DocData];
params.forEach(p => {
- Object.keys(vars).indexOf(p) !== -1 && (bd[DocData][p] = new PrefetchProxy(vars[p] as Doc));
+ Object.keys(vars).indexOf(p) !== -1 && (bdData[p] = new PrefetchProxy(vars[p] as Doc));
}); // copy all "captured" arguments into document parameterfields
initialize?.(bd);
- bd[DocData]['onClick-paramFieldKeys'] = new List<string>(params);
+ bd.$onClick_paramFieldKeys = new List<string>(params);
e.docDragData && (e.docDragData.droppedDocuments = [bd]);
return e;
};
diff --git a/src/client/util/History.ts b/src/client/util/History.ts
index 9728e3177..0df0ec337 100644
--- a/src/client/util/History.ts
+++ b/src/client/util/History.ts
@@ -94,7 +94,7 @@ export namespace HistoryUtil {
}
if (Array.isArray(value)) {
} else if (parser === true || parser === 'json') {
- value = JSON.parse(value);
+ value = value === 'undefined' ? undefined : JSON.parse(value);
} else if (parser === 'none') {
} else {
value = parser(value);
diff --git a/src/client/util/Import & Export/ImageUtils.ts b/src/client/util/Import & Export/ImageUtils.ts
index 43807397f..9c32ca25a 100644
--- a/src/client/util/Import & Export/ImageUtils.ts
+++ b/src/client/util/Import & Export/ImageUtils.ts
@@ -1,6 +1,5 @@
import { ClientUtils } from '../../../ClientUtils';
import { Doc } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { Cast, NumCast, StrCast } from '../../../fields/Types';
import { ImageField } from '../../../fields/URLField';
@@ -16,13 +15,12 @@ export namespace ImageUtils {
export const AssignImgInfo = (document: Doc, data?: Upload.InspectionResults) => {
if (data) {
data.nativeWidth && (document._height = (NumCast(document._width) * data.nativeHeight) / data.nativeWidth);
- const proto = document[DocData];
- const field = Doc.LayoutFieldKey(document);
- proto[`${field}_nativeWidth`] = data.nativeWidth;
- proto[`${field}_nativeHeight`] = data.nativeHeight;
- proto[`${field}_path`] = data.source;
- proto[`${field}_exif`] = JSON.stringify(data.exifData.data);
- proto[`${field}_contentSize`] = data.contentSize ? data.contentSize : undefined;
+ const field = '$' + Doc.LayoutFieldKey(document);
+ document[`${field}_nativeWidth`] = data.nativeWidth;
+ document[`${field}_nativeHeight`] = data.nativeHeight;
+ document[`${field}_path`] = data.source;
+ document[`${field}_exif`] = JSON.stringify(data.exifData.data);
+ document[`${field}_contentSize`] = data.contentSize ? data.contentSize : undefined;
}
return document;
};
diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx
index 7f0118ed3..f61f6db18 100644
--- a/src/client/views/DashboardView.tsx
+++ b/src/client/views/DashboardView.tsx
@@ -6,7 +6,7 @@ import * as React from 'react';
import { FaPlus } from 'react-icons/fa';
import { ClientUtils } from '../../ClientUtils';
import { Doc, DocListCast } from '../../fields/Doc';
-import { AclPrivate, DocAcl, DocData } from '../../fields/DocSymbols';
+import { AclPrivate, DocAcl } from '../../fields/DocSymbols';
import { Id } from '../../fields/FieldSymbols';
import { List } from '../../fields/List';
import { PrefetchProxy } from '../../fields/Proxy';
@@ -113,7 +113,7 @@ export class DashboardView extends ObservableReactComponent<object> {
getDashboards = (whichGroup: DashboardGroup) => {
if (whichGroup === DashboardGroup.MyDashboards) {
- return DocListCast(Doc.MyDashboards.data).filter(dashboard => dashboard[DocData].author === ClientUtils.CurrentUserEmail());
+ return DocListCast(Doc.MyDashboards.data).filter(dashboard => dashboard.$author === ClientUtils.CurrentUserEmail());
}
return DocListCast(Doc.MySharedDocs.data_dashboards).filter(doc => doc.dockingConfig);
};
@@ -226,7 +226,7 @@ export class DashboardView extends ObservableReactComponent<object> {
color={color}
val={StrCast(dashboard.title)}
setVal={val => {
- dashboard[DocData].title = val;
+ dashboard.$title = val;
}}
/>
{this.selectedDashboardGroup === DashboardGroup.SharedDashboards && this.isUnviewedSharedDashboard(dashboard) ? <div>unviewed</div> : <div />}
@@ -403,8 +403,8 @@ export class DashboardView extends ObservableReactComponent<object> {
},
],
};
- if (dashboard.dockingConfig && dashboard.dockingConfig !== dashboard[DocData].dockingConfig) dashboard.dockingConfig = JSON.stringify(reset);
- else Doc.SetInPlace(dashboard, 'dockingConfig', JSON.stringify(reset), true);
+ const dockingOnLayout = dashboard._dockingConfig && dashboard._dockingConfig !== dashboard.$dockingConfig;
+ dashboard[`${dockingOnLayout ? '_' : '$'}dockingConfig`] = JSON.stringify(reset);
return reset;
};
@@ -427,14 +427,14 @@ export class DashboardView extends ObservableReactComponent<object> {
Doc.AddDocToList(Doc.MyHeaderBar, 'data', freeformDoc, undefined, undefined, true);
Doc.AddDocToList(Doc.MyDashboards, 'data', dashboardDoc);
- dashboardDoc.pane_count = 1;
- freeformDoc.embedContainer = dashboardDoc;
- dashboardDoc.myOverlayDocs = new List<Doc>();
- dashboardDoc[DocData].myPublishedDocs = new List<Doc>();
- dashboardDoc[DocData].myTagCollections = new List<Doc>();
- dashboardDoc[DocData].myUniqueFaces = new List<Doc>();
- dashboardDoc[DocData].myTrails = DashboardView.SetupDashboardTrails();
- dashboardDoc[DocData].myCalendars = DashboardView.SetupDashboardCalendars();
+ freeformDoc._embedContainer = dashboardDoc;
+ dashboardDoc.$myPaneCount = 1;
+ dashboardDoc.$myOverlayDocs = new List<Doc>();
+ dashboardDoc.$myPublishedDocs = new List<Doc>();
+ dashboardDoc.$myTagCollections = new List<Doc>();
+ dashboardDoc.$myUniqueFaces = new List<Doc>();
+ 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<P extends DocComponentProps>() {
* 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<P extends FieldViewProps>() {
* 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<P extends FieldViewProps>() {
* 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<DocumentDecora
} else if (this._titleControlString.startsWith('$')) {
if (this._accumulatedTitle.startsWith('-->#')) {
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<DocumentDecora
this._inkDragDocs
.map(oldbds => ({ 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<HotKeyButtonProps> = observer(({ hotKey /*, sel
key={icon.toString()}
onClick={undoable(e => {
e.stopPropagation;
- hotKey[DocData].icon = icon.toString();
+ hotKey.$icon = icon.toString();
}, '')}
className="icon-panel-button">
<FontAwesomeIcon icon={icon} color={SnappingManager.userColor} />
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<object> {
@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<MarqueeAnnotatorP
presentation_zoomText: true,
title: '>' + 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<MarqueeAnnotatorP
})
);
- textRegionAnnoProto.y = Math.max(minY, 0);
- textRegionAnnoProto.x = Math.max(minX, 0);
- textRegionAnnoProto.height = Math.max(maxY, 0) - Math.max(minY, 0);
- textRegionAnnoProto.width = Math.max(maxX, 0) - Math.max(minX, 0);
- textRegionAnnoProto.backgroundColor = color;
+ textRegionAnno.$y = Math.max(minY, 0);
+ textRegionAnno.$x = Math.max(minX, 0);
+ textRegionAnno.$height = Math.max(maxY, 0) - Math.max(minY, 0);
+ textRegionAnno.$width = Math.max(maxX, 0) - Math.max(minX, 0);
+ textRegionAnno.$backgroundColor = color;
// mainAnnoDocProto.text = this._selectionText;
- textRegionAnnoProto.text_inlineAnnotations = new List<string>(annoRects);
- textRegionAnnoProto.opacity = 0;
- textRegionAnnoProto.layout_unrendered = true;
+ textRegionAnno.$text_inlineAnnotations = new List<string>(annoRects);
+ textRegionAnno.$opacity = 0;
+ textRegionAnno.$layout_unrendered = true;
savedAnnoMap.clear();
return textRegionAnno;
};
@@ -226,9 +225,8 @@ export class MarqueeAnnotator extends ObservableReactComponent<MarqueeAnnotatorP
DragManager.StartAnchorAnnoDrag([ele], new DragManager.AnchorAnnoDragData(this.props.docView(), sourceAnchorCreator, targetCreator), e.pageX, e.pageY, {
dragComplete: dragEx => {
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<Doc>(DocListCast(targetDoc[DocData][fieldKey + '_annotations']).filter(doc => !doc.layout_unrendered));
+ pinDoc.config_annotations = new List<Doc>(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 {
() => <MdTouchApp />,
(dv, doc) => {
const on = !!doc.onPaint;
- doc[DocData].onPaint = on ? undefined : ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, { documentView: 'any' });
- doc[DocData].layout_textPainted = on ? undefined : `<ComparisonBox {...props} fieldKey={'${dv?.LayoutFieldKey ?? 'text'}'}/>`;
+ doc.$onPaint = on ? undefined : ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, { documentView: 'any' });
+ doc.$layout_textPainted = on ? undefined : `<ComparisonBox {...props} fieldKey={'${dv?.LayoutFieldKey ?? 'text'}'}/>`;
}
);
}
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<PropertiesViewProps
const tags = StrListCast(doc.tags);
if (!tags.includes(value)) {
tags.push(value);
- doc[DocData].tags = tags.length ? new List<string>(tags) : undefined;
+ doc.$tags = tags.length ? new List<string>(tags) : undefined;
}
return true;
}
@@ -498,7 +498,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
const individualTableEntries = [];
const usersAdded: string[] = []; // all shared users being added - organized by denormalized email
- const seldoc = this.layoutDocAcls ? this.selectedLayoutDoc : this.selectedDoc?.[DocData];
+ const seldoc = this.layoutDocAcls ? this.selectedLayoutDoc : this.dataDoc;
// adds each user to usersAdded
SharingManager.Instance.users.forEach(eachUser => {
let userOnDoc = true;
@@ -777,7 +777,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
switch (field) {
case 'Xps': selDoc.x = NumCast(this.selectedDoc?.x) + (dirs === 'up' ? 10 : -10); break;
case 'Yps': selDoc.y = NumCast(this.selectedDoc?.y) + (dirs === 'up' ? 10 : -10); break;
- case 'stk': selDoc.stroke_width = NumCast(this.selectedDoc?.[DocData].stroke_width) + (dirs === 'up' ? 0.1 : -0.1); break;
+ case 'stk': selDoc.stroke_width = NumCast(this.selectedDoc?.$stroke_width) + (dirs === 'up' ? 0.1 : -0.1); break;
case 'wid': {
const oldWidth = NumCast(selDoc._width);
const oldHeight = NumCast(selDoc._height);
@@ -825,11 +825,11 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
};
getField(key: string) {
- return Field.toString(this.selectedDoc?.[DocData][key] as FieldType);
+ return Field.toString(this.selectedDoc?.['$' + key] as FieldType);
}
@computed get selectedStrokes() {
- return this.containsInkDoc ? DocListCast(this.selectedDoc[DocData].data) : DocumentView.SelectedSchemaDoc() ? [DocumentView.SelectedSchemaDoc()!] : DocumentView.SelectedDocs().filter(doc => 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<PropertiesViewProps
set shapeWid(value) { this.selectedDoc && (this.selectedDoc._width = Math.round(value * 100) / 100); } // prettier-ignore
@computed get shapeHgt() { return NumCast(this.selectedDoc?._height); } // prettier-ignore
set shapeHgt(value) { this.selectedDoc && (this.selectedDoc._height = Math.round(value * 100) / 100); } // prettier-ignore
- @computed get strokeThk(){ return NumCast(this.selectedStrokes.lastElement()?.[DocData].stroke_width); } // prettier-ignore
+ @computed get strokeThk(){ return NumCast(this.selectedStrokes.lastElement()?.$stroke_width); } // prettier-ignore
set strokeThk(value) {
this.selectedStrokes.forEach(doc => {
- 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<PropertiesViewProps
private _lastDash: string = '2';
- @computed get colorFil() { return StrCast(this.selectedStrokes.lastElement()?.[DocData].fillColor); } // prettier-ignore
+ @computed get colorFil() { return StrCast(this.selectedStrokes.lastElement()?.$fillColor); } // prettier-ignore
set colorFil(value) {
this.selectedStrokes.forEach(doc => {
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<PropertiesViewProps
const layoutDoc = doc ? Doc.Layout(doc) : doc;
return StrCast(layoutDoc.color);
}
- set borderColor(value) { this.selectedDoc && (this.selectedDoc[DocData].color = value || undefined); } // prettier-ignore
+ set borderColor(value) { this.selectedDoc && (this.selectedDoc.$color = value || undefined); } // prettier-ignore
colorButton(value: string, type: string, setter: () => void) {
return (
@@ -1034,41 +1034,41 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
set dashdStk(value) {
value && (this._lastDash = value as string);
this.selectedStrokes.forEach(doc => {
- 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<PropertiesViewProps
* of ink strokes in the properties menu.
*/
containsInk = (selectedDoc: Doc) => {
- 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<PropertiesViewProps
@undoBatch
setDescripValue = action((value: string) => {
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<ScriptBoxProps> {
);
}
// 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<ScriptBoxProps> {
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<ScriptBoxProps> {
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<Doc>();
- dashboardDoc.myPublishedDocs = new List<Doc>();
+ dashboardDoc.$myOverlayDocs = new List<Doc>();
+ dashboardDoc.$myPublishedDocs = new List<Doc>();
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<FieldViewProps & DocumentViewProps & { showAIEditor: boolean }>() {
// 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<FieldViewProps & Document
@computed get highlighting() { return this.style(this.Document, StyleProp.Highlighting); } // prettier-ignore
@computed get borderPath() { return this.style(this.Document, StyleProp.BorderPath); } // prettier-ignore
- @computed get onClickHdlr() { return this._props.onClickScript?.() ?? ScriptCast(this.layoutDoc.onClick ?? this.Document.onClick); } // prettier-ignore
- @computed get onDoubleClickHdlr() { return this._props.onDoubleClickScript?.() ?? ScriptCast(this.layoutDoc.onDoubleClick ?? this.Document.onDoubleClick); } // prettier-ignore
- @computed get onPointerDownHdlr() { return this._props.onPointerDownScript?.() ?? ScriptCast(this.layoutDoc.onPointerDown ?? this.Document.onPointerDown); } // prettier-ignore
- @computed get onPointerUpHdlr() { return this._props.onPointerUpScript?.() ?? ScriptCast(this.layoutDoc.onPointerUp ?? this.Document.onPointerUp); } // prettier-ignore
+ @computed get onClickHdlr() { return this._props.onClickScript?.() ?? ScriptCast(this.Document._onClick ?? this.Document.onClick); } // prettier-ignore
+ @computed get onDoubleClickHdlr() { return this._props.onDoubleClickScript?.() ?? ScriptCast(this.Document._onDoubleClick ?? this.Document.onDoubleClick); } // prettier-ignore
+ @computed get onPointerDownHdlr() { return this._props.onPointerDownScript?.() ?? ScriptCast(this.Document._onPointerDown ?? this.Document.onPointerDown); } // prettier-ignore
+ @computed get onPointerUpHdlr() { return this._props.onPointerUpScript?.() ?? ScriptCast(this.Document._onPointerUp ?? this.Document.onPointerUp); } // prettier-ignore
@computed get disableClickScriptFunc() {
const onScriptDisable = this._props.onClickScriptDisable ?? this._componentView?.onClickScriptDisable?.() ?? this.layoutDoc.onClickScriptDisable;
@@ -322,7 +322,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
DocumentView.DeselectAll();
Doc.UnBrushDoc(this.Document);
} else this._singleClickFunc?.();
- }, 'on double click: ' + this.Document.title)();
+ }, 'on double click: ' + this.Document.$title)();
this._doubleClickTimeout && clearTimeout(this._doubleClickTimeout);
this._doubleClickTimeout = undefined;
this._singleClickFunc = undefined;
@@ -340,7 +340,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
if (this.layoutDoc.onDragStart && !(e.ctrlKey || e.button > 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<FieldViewProps & Document
if (e && !(e.nativeEvent instanceof simMouseEvent ? e.nativeEvent.dash : false)) {
const onDisplay = () => {
- 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<FieldViewProps & Document
cm.addItem({ description: item.label, event: () => (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<FieldViewProps & Document
let documentationDescription: string | undefined;
let documentationLink: string | undefined;
- switch (this.Document.type) {
+ switch (this.Document.$type) {
case DocumentType.COL:
documentationDescription = 'See collection documentation';
documentationLink = 'https://brown-dash.github.io/Dash-Documentation/views/';
@@ -722,9 +722,9 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
private _tagsBtnHeight = 22;
@computed get currentScale() {
const viewXfScale = this._props.DocumentView!().screenToLocalScale();
- const x = NumCast(this.Document.height) / viewXfScale / 80;
+ const x = NumCast(this.Document._height) / viewXfScale / 80;
const xscale = x >= 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<FieldViewProps & Document
/**
* The maximum size a UI widget can be scaled so that it won't be bigger in screen pixels than its normal 35 pixel size.
*/
- @computed get maxWidgetSize() { return Math.min(this._tagsBtnHeight * this.viewScaling, 0.25 * Math.min(NumCast(this.Document.width), NumCast(this.Document.height))); } // prettier-ignore
+ @computed get maxWidgetSize() { return Math.min(this._tagsBtnHeight * this.viewScaling, 0.25 * Math.min(NumCast(this.Document._width), NumCast(this.Document._height))); } // prettier-ignore
/**
* How much to reactively scale a UI element so that it is as big as it can be (up to its normal 35pixel size) without being too big for the Doc content
*/
@@ -746,7 +746,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
@computed get viewBoxContents() {
TraceMobx();
const isInk = this.layoutDoc._layout_isSvg && !this._props.LayoutTemplateString;
- const noBackground = this.Document.isGroup && !this._componentView?.isUnstyledView?.() && (!this.layoutDoc.backgroundColor || this.layoutDoc.backgroundColor === 'transparent');
+ const noBackground = this.Document.$isGroup && !this._componentView?.isUnstyledView?.() && (!this.layoutDoc.backgroundColor || this.layoutDoc.backgroundColor === 'transparent');
return (
<>
<div
@@ -957,7 +957,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
: (this.docContents ?? (
<div
className="documentView-node"
- id={this.Document.type !== DocumentType.LINK ? this._docView?.DocUniqueId : undefined}
+ id={this.Document.$type !== DocumentType.LINK ? this._docView?.DocUniqueId : undefined}
style={{
...style,
background: this.backgroundBoxColor,
@@ -1015,7 +1015,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
borderRadius: this._componentView?.isUnstyledView?.() ? undefined : this.borderRounding,
pointerEvents: this._pointerEvents === 'visiblePainted' ? 'none' : this._pointerEvents, // visible painted means that the underlying doc contents are irregular and will process their own pointer events (otherwise, the contents are expected to fill the entire doc view box so we can handle pointer events here)
}}>
- {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}
</div>
);
@@ -1210,7 +1210,7 @@ export class DocumentView extends DocComponent<DocumentViewProps>() {
}
@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<DocumentViewProps>() {
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<FieldViewProps>() {
@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<FieldViewProps>() {
if (key) target[key] = script.originalScript;
return false;
}
- field === undefined && (field = res.result instanceof Array ? new List<FieldType>(res.result) : (typeof res.result === 'function' ? res.result.name : res.result as FieldType));
+ field === undefined && (field = res.result instanceof Array ? new List<FieldType>(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<FieldViewProps>() {
rowHeight = () => 30;
@computed get createTable() {
- const doc = this.fieldDocToLayout;
+ const doc = this._props.Document;
if (!doc) {
return (
<tr>
@@ -149,25 +145,35 @@ export class KeyValueBox extends ViewBoxBaseComponent<FieldViewProps>() {
</tr>
);
}
- 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<FieldViewProps>() {
sortedKeys.forEach(key => {
rows.push(
<KeyValuePair
- doc={realDoc}
+ doc={doc}
addDocTab={this._props.addDocTab}
PanelWidth={this._props.PanelWidth}
PanelHeight={this.rowHeight}
@@ -299,8 +305,8 @@ export class KeyValueBox extends ViewBoxBaseComponent<FieldViewProps>() {
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<KeyValuePairProps> {
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<KeyValuePairProps> {
</button>
<input className="keyValuePair-td-key-check" type="checkbox" style={hover} onChange={this.handleCheck} ref={this.checkbox} />
<Tooltip title={Object.entries(new DocumentOptions()).find((pair: [string, FInfo]) => pair[0].replace(/^_/, '') === this._props.keyName)?.[1].description ?? ''}>
- <div className="keyValuePair-keyField" style={{ marginLeft: 20 * (this._props.keyName.replace(/__/g, '').match(/_/g)?.length || 0), color: keyStyle }}>
- {'('.repeat(parenCount)}
- {this._props.keyName}
- {')'.repeat(parenCount)}
+ <div className="keyValuePair-keyField" style={{ marginLeft: 20 * (this._props.keyName.replace(/__/g, '').replace(/^_/, '').match(/_/g)?.length || 0), color: keyStyle }}>
+ {(layoutField ? '_' : '$').repeat(parenCount)}
+ {(keyStyle === 'blue' && !layoutField && !parenCount ? '$' : '') + this._props.keyName}
</div>
</Tooltip>
</div>
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<FormattedTextB
if (target) {
anchor.followLinkAudio = true;
let stopFunc: () => 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<FormattedTextB
};
const link = CreateLinkToActiveAudio(textanchorFunc, false).lastElement();
if (link) {
- link[DocData].isDictation = true;
+ link.$isDictation = true;
const audioanchor = Cast(link.link_anchor_2, Doc, null);
const textanchor = Cast(link.link_anchor_1, Doc, null);
if (audioanchor) {
@@ -1077,7 +1076,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
audioId: audioanchor[Id],
textId: textanchor[Id],
});
- textanchor[DocData].title = 'dictation:' + audiotag.attrs.timeCode;
+ textanchor.$title = 'dictation:' + audiotag.attrs.timeCode;
const tr = this.EditorView.state.tr.insert(this.EditorView.state.doc.content.size, audiotag);
const tr2 = tr.setSelection(TextSelection.create(tr.doc, tr.doc.content.size));
this.EditorView.dispatch(tr.setSelection(TextSelection.create(tr2.doc, tr2.doc.content.size)));
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts
index f3ec6cc9d..77c00537b 100644
--- a/src/client/views/nodes/formattedText/RichTextRules.ts
+++ b/src/client/views/nodes/formattedText/RichTextRules.ts
@@ -84,9 +84,8 @@ export class RichTextRules {
// Create annotation to a field on the text document
new InputRule(/>::$/, (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<string>(values) : new List<number>(values.map(v => Number(v)));
+ this.Document['$' + fieldKey] = strs ? new List<string>(values) : new List<number>(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<string>(tags);
+ this.Document.$tags = new List<string>(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<FieldViewProps>() {
}
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<FieldViewProps>() {
return doc;
});
const newList = new List<Doc>([...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<FieldViewProps>() {
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<IViewerProps> {
};
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<number>);
+ public static UniqueFaceDescriptors = (faceDoc: Doc) => DocListCast(faceDoc.$face_annos).map(face => face.faceDescriptor as List<number>);
/**
* 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<Doc>();
+ uniqueFaceDoc.$face = `Face${faceDocNum}`;
+ uniqueFaceDoc.$face_annos = new List<Doc>();
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<Doc>(annos);
+ imgDoc.$data_annotations = new List<Doc>(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<SearchBoxProps>() {
}
});
- // eslint-disable-next-line react/jsx-props-no-spreading
const recommendationsJSX: JSX.Element[] = []; // this._recommendations.map(props => <Recommendation {...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<FieldType> | 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<FieldType>, 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<FieldType>, 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);
}