aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts1016
1 files changed, 499 insertions, 517 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index d789d4ee3..acd323eca 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -2,17 +2,17 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { action, runInAction } from 'mobx';
import { basename } from 'path';
import { DateField } from '../../fields/DateField';
-import { Doc, DocListCast, DocListCastAsync, Field, Initializing, Opt, updateCachedAcls } from '../../fields/Doc';
+import { Doc, DocListCast, Field, Opt, updateCachedAcls } from '../../fields/Doc';
+import { Initializing } from '../../fields/DocSymbols';
import { Id } from '../../fields/FieldSymbols';
import { HtmlField } from '../../fields/HtmlField';
import { InkField, PointData } from '../../fields/InkField';
import { List } from '../../fields/List';
-import { ProxyField } from '../../fields/Proxy';
import { RichTextField } from '../../fields/RichTextField';
import { SchemaHeaderField } from '../../fields/SchemaHeaderField';
import { ComputedField, ScriptField } from '../../fields/ScriptField';
-import { Cast, DocCast, FieldValue, NumCast, ScriptCast, StrCast } from '../../fields/Types';
-import { AudioField, CsvField, ImageField, MapField, PdfField, RecordingField, VideoField, WebField, YoutubeField } from '../../fields/URLField';
+import { BoolCast, Cast, DocCast, FieldValue, NumCast, ScriptCast, StrCast } from '../../fields/Types';
+import { AudioField, CsvField, ImageField, PdfField, VideoField, WebField, YoutubeField } from '../../fields/URLField';
import { inheritParentAcls, SharingPermissions } from '../../fields/util';
import { Upload } from '../../server/SharedMediaTypes';
import { aggregateBounds, OmitKeys, Utils } from '../../Utils';
@@ -22,9 +22,10 @@ import { Networking } from '../Network';
import { DocumentManager } from '../util/DocumentManager';
import { DragManager, dropActionType } from '../util/DragManager';
import { DirectoryImportBox } from '../util/Import & Export/DirectoryImportBox';
+import { FollowLinkScript } from '../util/LinkFollower';
import { LinkManager } from '../util/LinkManager';
import { ScriptingGlobals } from '../util/ScriptingGlobals';
-import { undoBatch, UndoManager } from '../util/UndoManager';
+import { undoable, UndoManager } from '../util/UndoManager';
import { CollectionDockingView } from '../views/collections/CollectionDockingView';
import { DimUnit } from '../views/collections/collectionMulticolumn/CollectionMulticolumnView';
import { CollectionView } from '../views/collections/CollectionView';
@@ -37,10 +38,8 @@ import { FontIconBox } from '../views/nodes/button/FontIconBox';
import { ColorBox } from '../views/nodes/ColorBox';
import { ComparisonBox } from '../views/nodes/ComparisonBox';
import { DataVizBox } from '../views/nodes/DataVizBox/DataVizBox';
-import { DocFocusOptions } from '../views/nodes/DocumentView';
import { EquationBox } from '../views/nodes/EquationBox';
import { FieldViewProps } from '../views/nodes/FieldView';
-import { FilterBox } from '../views/nodes/FilterBox';
import { FormattedTextBox } from '../views/nodes/formattedText/FormattedTextBox';
import { FunctionPlotBox } from '../views/nodes/FunctionPlotBox';
import { ImageBox } from '../views/nodes/ImageBox';
@@ -51,6 +50,7 @@ import { LinkDescriptionPopup } from '../views/nodes/LinkDescriptionPopup';
import { LoadingBox } from '../views/nodes/LoadingBox';
import { MapBox } from '../views/nodes/MapBox/MapBox';
import { PDFBox } from '../views/nodes/PDFBox';
+import { PhysicsSimulationBox } from '../views/nodes/PhysicsBox/PhysicsSimulationBox';
import { RecordingBox } from '../views/nodes/RecordingBox/RecordingBox';
import { ScreenshotBox } from '../views/nodes/ScreenshotBox';
import { ScriptingBox } from '../views/nodes/ScriptingBox';
@@ -69,14 +69,16 @@ class EmptyBox {
return '';
}
}
-export abstract class FInfo {
+export class FInfo {
description: string = '';
- fieldType?: string;
+ readOnly: boolean = false;
+ fieldType?: string = '';
values?: Field[];
// format?: string; // format to display values (e.g, decimal places, $, etc)
// parse?: ScriptField; // parse a value from a string
- constructor(d: string) {
+ constructor(d: string, readOnly?: boolean) {
this.description = d;
+ this.readOnly = readOnly ?? false;
}
}
class BoolInfo extends FInfo {
@@ -86,16 +88,16 @@ class BoolInfo extends FInfo {
class NumInfo extends FInfo {
fieldType? = 'number';
values?: number[] = [];
- constructor(d: string, values?: number[]) {
- super(d);
+ constructor(d: string, readOnly?: boolean, values?: number[]) {
+ super(d, readOnly);
this.values = values;
}
}
class StrInfo extends FInfo {
fieldType? = 'string';
values?: string[] = [];
- constructor(d: string, values?: string[]) {
- super(d);
+ constructor(d: string, readOnly?: boolean, values?: string[]) {
+ super(d, readOnly);
this.values = values;
}
}
@@ -103,21 +105,38 @@ class DocInfo extends FInfo {
fieldType? = 'Doc';
values?: Doc[] = [];
constructor(d: string, values?: Doc[]) {
- super(d);
+ super(d, true);
this.values = values;
}
}
class DimInfo extends FInfo {
- fieldType? = 'DimUnit';
+ fieldType? = 'enumeration';
values? = [DimUnit.Pixel, DimUnit.Ratio];
+ readOnly = false;
}
class PEInfo extends FInfo {
- fieldType? = 'pointerEvents';
+ fieldType? = 'enumeration';
values? = ['all', 'none'];
+ readOnly = false;
}
class DAInfo extends FInfo {
- fieldType? = 'dropActionType';
- values? = ['alias', 'copy', 'move', 'same', 'proto', 'none'];
+ fieldType? = 'enumeration';
+ values? = ['embed', 'copy', 'move', 'same', 'proto', 'none'];
+ readOnly = false;
+}
+class CTypeInfo extends FInfo {
+ fieldType? = 'enumeration';
+ values? = Array.from(Object.keys(CollectionViewType));
+ readOnly = false;
+}
+class DTypeInfo extends FInfo {
+ fieldType? = 'enumeration';
+ values? = Array.from(Object.keys(DocumentType));
+ readOnly = true;
+}
+class DateInfo extends FInfo {
+ fieldType? = 'date';
+ values?: DateField[] = [];
}
type BOOLt = BoolInfo | boolean;
type NUMt = NumInfo | number;
@@ -125,246 +144,268 @@ type STRt = StrInfo | string;
type DOCt = DocInfo | Doc;
type DIMt = DimInfo | typeof DimUnit.Pixel | typeof DimUnit.Ratio;
type PEVt = PEInfo | 'none' | 'all';
+type COLLt = CTypeInfo | CollectionViewType;
type DROPt = DAInfo | dropActionType;
+type DATEt = DateInfo | number;
+type DTYPEt = DTypeInfo | string;
export class DocumentOptions {
+ // coordinate and dimensions depending on view
x?: NUMt = new NumInfo('x coordinate of document in a freeform view');
y?: NUMt = new NumInfo('y coordinage of document in a freeform view');
- z?: NUMt = new NumInfo('whether document is in overlay (1) or not (0)', [1, 0]);
- system?: BOOLt = new BoolInfo('is this a system created/owned doc');
- type?: STRt = new StrInfo('type of document', Array.from(Object.keys(DocumentType)));
- title?: string;
- _dropAction?: DROPt = new DAInfo("what should happen to this document when it's dropped somewhere else");
- allowOverlayDrop?: BOOLt = new BoolInfo('can documents be dropped onto this document without using dragging title bar or holding down embed key (ctrl)?');
- childDropAction?: DROPt = new DAInfo("what should happen to the source document when it's dropped onto a child of a collection ");
- targetDropAction?: DROPt = new DAInfo('what should happen to the source document when ??? ');
- userColor?: STRt = new StrInfo('color associated with a Dash user (seen in header fields of shared documents)');
- color?: STRt = new StrInfo('foreground color data doc');
- backgroundColor?: STRt = new StrInfo('background color for data doc');
- _autoHeight?: BOOLt = new BoolInfo('whether document automatically resizes vertically to display contents');
- _headerHeight?: NUMt = new NumInfo('height of document header used for displaying title');
- _headerFontSize?: NUMt = new NumInfo('font size of header of custom notes');
- _headerPointerEvents?: PEVt = new PEInfo('types of events the header of a custom text document can consume');
- _panX?: NUMt = new NumInfo('horizontal pan location of a freeform view');
- _panY?: NUMt = new NumInfo('vertical pan location of a freeform view');
+ z?: NUMt = new NumInfo('whether document is in overlay (1) or not (0)', false, [1, 0]);
+ _dimMagnitude?: NUMt = new NumInfo("magnitude of collectionMulti{row,col} element's width or height");
+ _dimUnit?: DIMt = new DimInfo("units of collectionMulti{row,col} element's width or height - 'px' or '*' for pixels or relative units");
+ lat?: NUMt = new NumInfo('latitude coordinate for map views');
+ lng?: NUMt = new NumInfo('longitude coordinate for map views');
+ _timecodeToShow?: NUMt = new NumInfo('the time that a document should be displayed (e.g., when an annotation shows up as a video plays)');
+ _timecodeToHide?: NUMt = new NumInfo('the time that a document should be hidden');
_width?: NUMt = new NumInfo('displayed width of a document');
_height?: NUMt = new NumInfo('displayed height of document');
+ data_nativeWidth?: NUMt = new NumInfo('native width of data field contents (e.g., the pixel width of an image)');
+ data_nativeHeight?: NUMt = new NumInfo('native height of data field contents (e.g., the pixel height of an image)');
+ linearBtnWidth?: NUMt = new NumInfo('unexpanded width of a linear menu button (button "width" changes when it expands)');
_nativeWidth?: NUMt = new NumInfo('native width of document contents (e.g., the pixel width of an image)');
_nativeHeight?: NUMt = new NumInfo('native height of document contents (e.g., the pixel height of an image)');
- _dimMagnitude?: NUMt = new NumInfo("magnitude of collectionMulti{row,col} element's width or height");
- _dimUnit?: DIMt = new DimInfo("units of collectionMulti{row,col} element's width or height - 'px' or '*' for pixels or relative units");
- _fitWidth?: BOOLt = new BoolInfo('whether document should scale its contents to fit its rendered width or not (e.g., for PDFviews)');
- _fitContentsToBox?: BOOLt = new BoolInfo('whether a freeformview should zoom/scale to create a shrinkwrapped view of its content');
- _contentBounds?: List<number>; // the (forced) bounds of the document to display. format is: [left, top, right, bottom]
- _lockedPosition?: boolean; // lock the x,y coordinates of the document so that it can't be dragged
- _lockedTransform?: boolean; // lock the panx,pany and scale parameters of the document so that it be panned/zoomed
- _isPushpin?: boolean; // whether document, when clicked, toggles display of its link target
- _showTitle?: string; // field name to display in header (:hover is an optional suffix)
- _showCaption?: string; // which field to display in the caption area. leave empty to have no caption
- _scrollTop?: number; // scroll location for pdfs
- _noAutoscroll?: boolean; // whether collections autoscroll when this item is dragged
- _chromeHidden?: boolean; // whether the editing chrome for a document is hidden
- _searchDoc?: boolean; // is this a search document (used to change UI for search results in schema view)
- _forceActive?: boolean; // flag to handle pointer events when not selected (or otherwise active)
- _stayInCollection?: boolean; // whether the document should remain in its collection when someone tries to drag and drop it elsewhere
- _raiseWhenDragged?: boolean; // whether a document is brought to front when dragged.
- _hideContextMenu?: boolean; // whether the context menu can be shown
- _viewType?: string; // sub type of a collection
- viewType?: string; // sub type of a collection
- _gridGap?: number; // gap between items in masonry view
- _viewScale?: number; // how much a freeform view has been scaled (zoomed)
- _overflow?: string; // set overflow behavior
- _xMargin?: number; // gap between left edge of document and start of masonry/stacking layouts
- _yMargin?: number; // gap between top edge of dcoument and start of masonry/stacking layouts
- _xPadding?: number;
- _yPadding?: number;
- _itemIndex?: number; // which item index the carousel viewer is showing
- _showSidebar?: boolean; //whether an annotationsidebar should be displayed for text docuemnts
- _singleLine?: boolean; // whether text document is restricted to a single line (carriage returns make new document)
- _minFontSize?: number; // minimum font size for labelBoxes
- _maxFontSize?: number; // maximum font size for labelBoxes
- _columnWidth?: number;
- _columnsHideIfEmpty?: boolean; // whether stacking view column headings should be hidden
- _fontSize?: string;
- _fontFamily?: string;
- _fontWeight?: string;
- _pivotField?: string; // field key used to determine headings for sections in stacking, masonry, pivot views
- _curPage?: number; // current page of a PDF or other? paginated document
- _currentTimecode?: number; // the current timecode of a time-based document (e.g., current time of a video) value is in seconds
- _currentFrame?: number; // the current frame of a frame-based collection (e.g., progressive slide)
- _timecodeToShow?: number; // the time that a document should be displayed (e.g., when an annotation shows up as a video plays)
- _timecodeToHide?: number; // the time that a document should be hidden
- _timelineLabel?: boolean; // whether the document exists on a timeline
- '_carousel-caption-xMargin'?: NUMt = new NumInfo('x margin of caption inside of a carouself collection');
- '_carousel-caption-yMargin'?: NUMt = new NumInfo('y margin of caption inside of a carouself collection');
- 'icon-nativeWidth'?: NUMt = new NumInfo('native width of icon view');
- 'icon-nativeHeight'?: NUMt = new NumInfo('native height of icon view');
- 'dragFactory-count'?: NUMt = new NumInfo('number of items created from a drag button (used for setting title with incrementing index)');
- lat?: number;
- lng?: number;
- infoWindowOpen?: boolean;
- author?: string;
- _layoutKey?: string;
- fieldValues?: List<any>; // possible field values used by fieldInfos
- fieldType?: string; // type of afield used by fieldInfos
- unrendered?: boolean; // denotes an annotation that is not rendered with a DocumentView (e.g, rtf/pdf text selections and links to scroll locations in web/pdf)
+ _nativeDimModifiable?: BOOLt = new BoolInfo('native dimensions can be modified using document decoration reizers');
+ _nativeHeightUnfrozen?: BOOLt = new BoolInfo('native height can be changed independent of width by dragging decoration resizers');
+
'acl-Public'?: string; // public permissions
'_acl-Public'?: string; // public permissions
- version?: string; // version identifier for a document
- label?: string;
- hidden?: boolean;
- _hidden?: boolean;
- pointerEvents?: string; // pointer events that the documentview should have
- mediaState?: string; // status of audio/video media document: "pendingRecording", "recording", "paused", "playing"
- recording?: boolean; // whether WebCam is recording or not
- autoPlayAnchors?: boolean; // whether to play audio/video when an anchor is clicked in a stackedTimeline.
- dontPlayLinkOnSelect?: boolean; // whether an audio/video should start playing when a link is followed to it.
+ type?: DTYPEt = new DTypeInfo('type of document', true);
+ _type_collection?: COLLt = new CTypeInfo('how collection is rendered'); // sub type of a collection
+ title?: STRt = new StrInfo('title of document');
+ caption?: RichTextField;
+ author?: string; // STRt = new StrInfo('creator of document'); // bcz: don't change this. Otherwise, the userDoc's field Infos will have a FieldInfo assigned to its author field which will render it unreadable
+ author_date?: DATEt = new DateInfo('date the document was created', true);
+ annotationOn?: DOCt = new DocInfo('document annotated by this document');
+ color?: STRt = new StrInfo('foreground color data doc');
+ hidden?: BOOLt = new BoolInfo('whether the document is not rendered by its collection');
+ backgroundColor?: STRt = new StrInfo('background color for data doc');
+ opacity?: NUMt = new NumInfo('document opacity');
+ viewTransitionTime?: NUMt = new NumInfo('transition duration for view parameters');
+ dontRegisterView?: BOOLt = new BoolInfo('are views of this document registered so that they can be found when following links, etc');
+ _undoIgnoreFields?: List<string>; //'fields that should not be added to the undo stack (opacity for Undo/Redo/and sidebar) AND whether modifications to document are undoable (true for linearview menu buttons to prevent open/close from entering undo stack)'
+ undoIgnoreFields?: List<string>; //'fields that should not be added to the undo stack (opacity for Undo/Redo/and sidebar) AND whether modifications to document are undoable (true for linearview menu buttons to prevent open/close from entering undo stack)'
+ _headerHeight?: NUMt = new NumInfo('height of document header used for displaying title');
+ _headerFontSize?: NUMt = new NumInfo('font size of header of custom notes');
+ _headerPointerEvents?: PEVt = new PEInfo('types of events the header of a custom text document can consume');
+ _lockedPosition?: BOOLt = new BoolInfo("lock the x,y coordinates of the document so that it can't be dragged");
+ _lockedTransform?: BOOLt = new BoolInfo('lock the freeform_panx,freeform_pany and scale parameters of the document so that it be panned/zoomed');
+
+ layout?: string | Doc; // default layout string or template document
+ layout_keyValue?: STRt = new StrInfo('layout definition for showing keyValue view of document');
+ layout_explainer?: STRt = new StrInfo('explanation displayed at top of a collection to describe its purpose');
+ layout_headerButton?: DOCt = new DocInfo('the (button) Doc to display at the top of a collection.');
+ layout_disableBrushing?: BOOLt = new BoolInfo('whether to suppress border highlighting');
+ layout_unrendered?: BOOLt = new BoolInfo('denotes an annotation that is not rendered with a DocumentView (e.g, rtf/pdf text selections and links to scroll locations in web/pdf)');
+ layout_hideOpenButton?: BOOLt = new BoolInfo('whether to hide the open full screen button when selected');
+ layout_hideDocumentButtonBar?: BOOLt = new BoolInfo('whether to hide the document decorations lower button bar when selected');
+ layout_hideLinkAnchors?: BOOLt = new BoolInfo('suppresses link anchor dots from being displayed');
+ layout_hideAllLinks?: BOOLt = new BoolInfo('whether all individual blue anchor dots should be hidden');
+ layout_hideResizeHandles?: BOOLt = new BoolInfo('whether to hide the resize handles when selected');
+ layout_hideLinkButton?: BOOLt = new BoolInfo('whether the blue link counter button should be hidden');
+ layout_hideDecorationTitle?: BOOLt = new BoolInfo('whether to suppress the document decortations title when selected');
+ layout_borderRounding?: string;
+ layout_boxShadow?: string; // box-shadow css string OR "standard" to use dash standard box shadow
+ layout_maxAutoHeight?: NUMt = new NumInfo('maximum height for newly created (eg, from pasting) text documents');
+ _layout_autoHeight?: BOOLt = new BoolInfo('whether document automatically resizes vertically to display contents');
+ _layout_curPage?: NUMt = new NumInfo('current page of a PDF or other? paginated document');
+ _layout_currentTimecode?: NUMt = new NumInfo('the current timecode of a time-based document (e.g., current time of a video) value is in seconds');
+ _layout_hideContextMenu?: BOOLt = new BoolInfo('whether the context menu can be shown');
+ _layout_fitWidth?: BOOLt = new BoolInfo('whether document should scale its contents to fit its rendered width or not (e.g., for PDFviews)');
+ _layout_fitContentsToBox?: BOOLt = new BoolInfo('whether a freeformview should zoom/scale to create a shrinkwrapped view of its content');
+ _layout_fieldKey?: STRt = new StrInfo('the field key containing the current layout definition');
+ _layout_enableAltContentUI?: BOOLt = new BoolInfo('whether to show alternate content button');
+ _layout_showTitle?: string; // field name to display in header (:hover is an optional suffix)
+ _layout_showSidebar?: BOOLt = new BoolInfo('whether an annotationsidebar should be displayed for text docuemnts');
+ _layout_showCaption?: string; // which field to display in the caption area. leave empty to have no caption
+
+ _chromeHidden?: BOOLt = new BoolInfo('whether the editing chrome for a document is hidden');
+ _gridGap?: NUMt = new NumInfo('gap between items in masonry view');
+ _xMargin?: NUMt = new NumInfo('gap between left edge of document and start of masonry/stacking layouts');
+ _yMargin?: NUMt = new NumInfo('gap between top edge of dcoument and start of masonry/stacking layouts');
+ _xPadding?: NUMt = new NumInfo('x padding');
+ _yPadding?: NUMt = new NumInfo('y padding');
+ _singleLine?: boolean; // whether label box is restricted to one line of text
+ _createDocOnCR?: boolean; // whether carriage returns and tabs create new text documents
+ _columnWidth?: NUMt = new NumInfo('width of table column');
+ _columnsHideIfEmpty?: BOOLt = new BoolInfo('whether stacking view column headings should be hidden');
+ _caption_xMargin?: NUMt = new NumInfo('x margin of caption inside of a carousel collection', true);
+ _caption_yMargin?: NUMt = new NumInfo('y margin of caption inside of a carousel collection', true);
+ icon_nativeWidth?: NUMt = new NumInfo('native width of icon view', true);
+ icon_nativeHeight?: NUMt = new NumInfo('native height of icon view', true);
+ _text_fontSize?: string;
+ _text_fontFamily?: string;
+ _text_fontWeight?: string;
+ _pivotField?: string; // field key used to determine headings for sections in stacking, masonry, pivot views
+
+ infoWindowOpen?: BOOLt = new BoolInfo('whether info window corresponding to pin is open (on MapDocuments)');
+ _carousel_index?: NUMt = new NumInfo('which item index the carousel viewer is showing');
+ _label_minFontSize?: NUMt = new NumInfo('minimum font size for labelBoxes');
+ _label_maxFontSize?: NUMt = new NumInfo('maximum font size for labelBoxes');
+ stroke_width?: NUMt = new NumInfo('width of an ink stroke');
+ icon_label?: STRt = new StrInfo('label to use for a fontIcon doc (otherwise, the title is used)');
+ mediaState?: STRt = new StrInfo('status of audio/video media document: "pendingRecording", "recording", "paused", "playing"');
+ recording?: BOOLt = new BoolInfo('whether WebCam is recording or not');
+ autoPlayAnchors?: BOOLt = new BoolInfo('whether to play audio/video when an anchor is clicked in a stackedTimeline.');
+ dontPlayLinkOnSelect?: BOOLt = new BoolInfo('whether an audio/video should start playing when a link is followed to it.');
+ updateContentsScript?: ScriptField; // reactive script invoked when viewing a document that can update contents of a collection (or do anything)
toolTip?: string; // tooltip to display on hover
+ toolType?: string; // type of pen tool
+ expertMode?: BOOLt = new BoolInfo('something available only in expert (not novice) mode');
+
+ contentPointerEvents?: string; // pointer events allowed for content of a document view. eg. set to "none" in menuSidebar for sharedDocs so that you can select a document, but not interact with its contents
contextMenuFilters?: List<ScriptField>;
contextMenuScripts?: List<ScriptField>;
contextMenuLabels?: List<string>;
contextMenuIcons?: List<string>;
- dontUndo?: boolean; // whether button clicks should be undoable (this is set to true for Undo/Redo/and sidebar buttons that open the siebar panel)
- description?: string; // added for links
- layout?: string | Doc; // default layout string for a document
- contentPointerEvents?: string; // pointer events allowed for content of a document view. eg. set to "none" in menuSidebar for sharedDocs so that you can select a document, but not interact with its contents
- childLimitHeight?: number; // whether to limit the height of collection children. 0 - means height can be no bigger than width
+ childFilters_boolean?: string;
+ childFilters?: List<string>;
+ childLimitHeight?: NUMt = new NumInfo('whether to limit the height of collection children. 0 - means height can be no bigger than width');
childLayoutTemplate?: Doc; // template for collection to use to render its children (see PresBox layout in tree view)
childLayoutString?: string; // template string for collection to use to render its children
- childDocumentsActive?: boolean; // whether child documents are active when parent is document active
- childDontRegisterViews?: boolean;
- childHideLinkButton?: boolean; // hide link buttons on all children
+ childDocumentsActive?: BOOLt = new BoolInfo('whether child documents are active when parent is document active');
+ childDontRegisterViews?: BOOLt = new BoolInfo('whether child document views should be registered so that they can be found when following links, etc');
+ childHideLinkButton?: BOOLt = new BoolInfo('hide link buttons on all children');
childContextMenuFilters?: List<ScriptField>;
childContextMenuScripts?: List<ScriptField>;
childContextMenuLabels?: List<string>;
childContextMenuIcons?: List<string>;
- hideLinkButton?: boolean; // whether the blue link counter button should be hidden
- hideDecorationTitle?: boolean;
- hideOpenButton?: boolean;
- hideResizeHandles?: boolean;
- hideDocumentButtonBar?: boolean;
- hideAllLinks?: boolean; // whether all individual blue anchor dots should be hidden
- isTemplateForField?: string; // the field key for which the containing document is a rendering template
- isTemplateDoc?: boolean;
targetScriptKey?: string; // where to write a template script (used by collections with click templates which need to target onClick, onDoubleClick, etc)
- templates?: List<string>;
- hero?: ImageField; // primary image that best represents a compound document (e.g., for a buxton device document that has multiple images)
- caption?: RichTextField;
- opacity?: number;
- defaultBackgroundColor?: string;
- _isLinkButton?: boolean; // marks a document as a button that will follow its primary link when clicked
- _linkAutoMove?: boolean; // whether link endpoint should move around the edges of a document to make shortest path to other link endpoint
- isFolder?: boolean;
- lastFrame?: number; // the last frame of a frame-based collection (e.g., progressive slide)
- activeFrame?: number; // the active frame of a document in a frame base collection
- appearFrame?: number; // the frame in which the document appears
- presTransition?: number; //the time taken for the transition TO a document
- presDuration?: number; //the duration of the slide in presentation view
- presProgressivize?: boolean;
- borderRounding?: string;
- boxShadow?: string; // box-shadow css string OR "standard" to use dash standard box shadow
+
+ lastFrame?: NUMt = new NumInfo('the last frame of a frame-based collection (e.g., progressive slide)');
+ activeFrame?: NUMt = new NumInfo('the active frame of a document in a frame base collection');
+ appearFrame?: NUMt = new NumInfo('the frame in which the document appears');
+ _currentFrame?: NUMt = new NumInfo('the current frame of a frame-based collection (e.g., progressive slide)');
+
+ isSystem?: BOOLt = new BoolInfo('is this a system created/owned doc', true);
+ isBaseProto?: BOOLt = new BoolInfo('is doc a base level prototype for data documents as opposed to data documents which are prototypes for layout documents. base protos are not cloned during a deep');
+ isTemplateForField?: string; // the field key for which the containing document is a rendering template
+ isTemplateDoc?: BOOLt = new BoolInfo('is the document a template for creating other documents');
+ isGroup?: BOOLt = new BoolInfo('should collection use a grouping UI behavior');
+ isFolder?: BOOLt = new BoolInfo('is document a tree view folder');
+ _isTimelineLabel?: BOOLt = new BoolInfo('is document a timeline label');
+ _isLightbox?: BOOLt = new BoolInfo('whether a collection acts as a lightbox by opening lightbox links by hiding all other documents in collection besides link target');
+
+ presPanX?: NUMt = new NumInfo('panX saved as a view spec');
+ presPanY?: NUMt = new NumInfo('panY saved as a view spec');
+ presViewScale?: NUMt = new NumInfo('viewScale saved as a view Spec');
+ presTransition?: NUMt = new NumInfo('the time taken for the transition TO a document');
+ presDuration?: NUMt = new NumInfo('the duration of the slide in presentation view');
+ presZoomText?: BOOLt = new BoolInfo('whether text anchors should shown in a larger box when following links to make them stand out');
+
data?: any;
- baseProto?: boolean; // is this a base prototoype
- dontRegisterView?: boolean;
- lookupField?: ScriptField; // script that returns the value of a field. This script is passed the rootDoc, layoutDoc, field, and container of the document. see PresBox.
+ data_useCors?: BOOLt = new BoolInfo('whether CORS protocol should be used for web page');
columnHeaders?: List<SchemaHeaderField>; // headers for stacking views
schemaHeaders?: List<SchemaHeaderField>; // headers for schema view
- clipWidth?: number; // percent transition from before to after in comparisonBox
- dockingConfig?: string;
- annotationOn?: Doc;
- isPushpin?: boolean;
- isGroup?: boolean; // whether a collection should use a grouping UI behavior
- _removeDropProperties?: List<string>; // list of properties that should be removed from a document when it is dropped. e.g., a creator button may be forceActive to allow it be dragged, but the forceActive property can be removed from the dropped document
+ dockingConfig?: STRt = new StrInfo('configuration of golden layout windows (applies only if doc is rendered as a CollectionDockingView)');
+ icon?: string; // icon used by fonticonbox to render button
noteType?: string;
- // BACKGROUND GRID
- _backgroundGridShow?: boolean;
+
+ // freeform properties
+ _freeform_backgroundGrid?: boolean;
+ _freeform_scale?: NUMt = new NumInfo('how much a freeform view has been scaled (zoomed)');
+ _freeform_panX?: NUMt = new NumInfo('horizontal pan location of a freeform view');
+ _freeform_panY?: NUMt = new NumInfo('vertical pan location of a freeform view');
+ _freeform_noAutoPan?: BOOLt = new BoolInfo('disables autopanning when this item is dragged');
+ _freeform_noZoom?: BOOLt = new BoolInfo('disables zooming');
//BUTTONS
buttonText?: string;
- iconShape?: string; // shapes of the fonticon border
btnType?: string;
btnList?: List<string>;
docColorBtn?: string;
userColorBtn?: string;
- canClick?: string;
script?: ScriptField;
- numBtnType?: string;
- numBtnMax?: number;
- numBtnMin?: number;
+ numBtnMax?: NUMt = new NumInfo('maximum value of a number button');
+ numBtnMin?: NUMt = new NumInfo('minimum value of a number button');
switchToggle?: boolean;
badgeValue?: ScriptField;
//LINEAR VIEW
- linearViewIsExpanded?: boolean; // is linear view expanded
- linearViewExpandable?: boolean; // can linear view be expanded
- linearViewToggleButton?: string; // button to open close linear view group
- linearViewSubMenu?: boolean;
- flexGap?: number; // Linear view flex gap
+ linearView_IsExpanded?: BOOLt = new BoolInfo('is linear view expanded');
+ linearView_Expandable?: BOOLt = new BoolInfo('can linear view be expanded');
+ linearView_SubMenu?: BOOLt = new BoolInfo('is doc a sub menu of more linear views');
+ flexGap?: NUMt = new NumInfo('Linear view flex gap');
flexDirection?: 'unset' | 'row' | 'column' | 'row-reverse' | 'column-reverse';
- layout_linkView?: Doc; // view template for a link document
- layout_keyValue?: string; // view tempalte for key value docs
- linkRelationship?: string; // type of relatinoship a link represents
- linkDisplay?: boolean; // whether a link line should be dipslayed between the two link anchors
- anchor1?: Doc;
- anchor2?: Doc;
- 'anchor1-useLinkSmallAnchor'?: boolean; // whether anchor1 of a link should use a miniature anchor dot (as when the anchor is a text selection)
- 'anchor2-useLinkSmallAnchor'?: boolean; // whether anchor1 of a link should use a miniature anchor dot (as when the anchor is a text selection)
- ignoreClick?: boolean;
+ link_description?: string; // added for links
+ link_relationship?: string; // type of relatinoship a link represents
+ link_displayLine?: BOOLt = new BoolInfo('whether a link line should be dipslayed between the two link anchors');
+ link_displayArrow?: BOOLt = new BoolInfo("whether to display link's directional arrowhead");
+ link_anchor_1?: Doc;
+ link_anchor_2?: Doc;
+ link_autoMoveAnchors?: BOOLt = new BoolInfo('whether link endpoint should move around the edges of a document to make shortest path to other link endpoint');
+ link_anchor_1_useSmallAnchor?: BOOLt = new BoolInfo('whether link_anchor_1 of a link should use a miniature anchor dot (as when the anchor is a text selection)');
+ link_anchor_2_useSmallAnchor?: BOOLt = new BoolInfo('whether link_anchor_1 of a link should use a miniature anchor dot (as when the anchor is a text selection)');
+ link_relationshipList?: List<string>; // for storing different link relationships (when set by user in the link editor)
+ link_relationshipSizes?: List<number>; //stores number of links contained in each relationship
+ link_colorList?: List<string>; // colors of links corresponding to specific link relationships
+ followLinkZoom?: BOOLt = new BoolInfo('whether to zoom to the target of a link');
+ followLinkToggle?: BOOLt = new BoolInfo('whether target of link should be toggled on and off when following a link to it');
+ followLinkLocation?: STRt = new StrInfo('where to open link target when following link');
+ followLinkAnimEffect?: STRt = new StrInfo('animation effect triggered on target of link');
+ followLinkAnimDirection?: STRt = new StrInfo('direction modifier for animation effect');
+
+ ignoreClick?: BOOLt = new BoolInfo('whether clicks on document should be ignored');
onClick?: ScriptField;
onDoubleClick?: ScriptField;
onChildClick?: ScriptField; // script given to children of a collection to execute when they are clicked
onChildDoubleClick?: ScriptField; // script given to children of a collection to execute when they are double clicked
+ defaultDoubleClick?: 'ignore' | 'default'; // ignore double clicks, or deafult (undefined) means open document full screen
+ waitForDoubleClickToClick?: 'always' | 'never' | 'default'; // whether a click function wait for double click to expire. 'default' undefined = wait only if there's a click handler, "never" = never wait, "always" = alway wait
onPointerDown?: ScriptField;
onPointerUp?: ScriptField;
+ openFactoryLocation?: string; // an OpenWhere value to place the factory created document
+ openFactoryAsDelegate?: BOOLt = new BoolInfo('create a delegate of the factory');
+ _forceActive?: BOOLt = new BoolInfo('flag to handle pointer events when not selected (or otherwise active)');
+ _dragOnlyWithinContainer?: BOOLt = new BoolInfo('whether the document should remain in its collection when someone tries to drag and drop it elsewhere');
+ _raiseWhenDragged?: BOOLt = new BoolInfo('whether a document is brought to front when dragged.');
+ childDragAction?: DROPt = new DAInfo('what should happen to the child documents when they are dragged from the collection');
dropConverter?: ScriptField; // script to run when documents are dropped on this Document.
+ dropAction?: DROPt = new DAInfo("what should happen to this document when it's dropped somewhere else");
+ _dropAction?: DROPt = new DAInfo("what should happen to this document when it's dropped somewhere else");
+ _dropPropertiesToRemove?: List<string>; // list of properties that should be removed from a document when it is dropped. e.g., a creator button may be forceActive to allow it be dragged, but the forceActive property can be removed from the dropped document
+ cloneFieldFilter?: List<string>; // fields not to copy when the document is clonedclipboard?: Doc;
+ dragWhenActive?: BOOLt = new BoolInfo('should document drag when it is active - e.g., pileView, group');
+ dragAction?: DROPt = new DAInfo('how to drag document when it is active (e.g., tree, groups)');
+ dragFactory_count?: NUMt = new NumInfo('number of items created from a drag button (used for setting title with incrementing index)', true);
dragFactory?: Doc; // document to create when dragging with a suitable onDragStart script
clickFactory?: Doc; // document to create when clicking on a button with a suitable onClick script
onDragStart?: ScriptField; //script to execute at start of drag operation -- e.g., when a "creator" button is dragged this script generates a different document to drop
- cloneFieldFilter?: List<string>; // fields not to copy when the document is clonedclipboard?: Doc;
- filterBoolean?: string;
- useCors?: boolean;
- icon?: string;
- target?: Doc; // available for use in scripts as the primary target document
- sourcePanel?: Doc; // panel to display in 'targetContainer' as the result of a button onClick script
- targetContainer?: Doc; // document whose proto will be set to 'panel' as the result of a onClick click script
- searchFileTypes?: List<string>; // file types allowed in a search query
- strokeWidth?: number;
- freezeChildren?: string; // whether children are now allowed to be added and or removed from a collection
- treeViewHideTitle?: boolean; // whether to hide the top document title of a tree view
- treeViewHideHeaderIfTemplate?: boolean; // whether to hide the header for a document in a tree view only if a childLayoutTemplate is provided (presBox)
- treeViewHideHeader?: boolean; // whether to hide the header for a document in a tree view
- treeViewHideHeaderFields?: boolean; // whether to hide the drop down options for tree view items.
+ target?: Doc; // available for use in scripts. used to provide a document parameter to the script (Note, this is a convenience entry since any field could be used for parameterizing a script)
+
+ treeViewHideTitle?: BOOLt = new BoolInfo('whether to hide the top document title of a tree view');
+ treeViewHideUnrendered?: BOOLt = new BoolInfo("tells tree view not to display documents that have an 'layout_unrendered' tag unless they also have a treeViewFieldKey tag (presBox)");
+ treeViewHideHeaderIfTemplate?: BOOLt = new BoolInfo('whether to hide the header for a document in a tree view only if a childLayoutTemplate is provided (presBox)');
+ treeViewHideHeader?: BOOLt = new BoolInfo('whether to hide the header for a document in a tree view');
+ treeViewHideHeaderFields?: BOOLt = new BoolInfo('whether to hide the drop down options for tree view items.');
treeViewChildDoubleClick?: ScriptField; //
- // Action Button
- buttonMenu?: boolean; // whether a action button should be displayed
- buttonMenuDoc?: Doc;
- explainer?: string;
-
- treeViewOpenIsTransient?: boolean; // ignores the treeViewOpen Doc flag, allowing a treeViewItem's expand/collapse state to be independent of other views of the same document in the same or any other tree view
- _treeViewOpen?: boolean; // whether this document is expanded in a tree view (note: need _ and regular versions since this can be specified for both proto and layout docs)
- treeViewOpen?: boolean; // whether this document is expanded in a tree view
+ treeViewOpenIsTransient?: BOOLt = new BoolInfo("ignores the treeViewOpen Doc flag, allowing a treeViewItem's expand/collapse state to be independent of other views of the same document in the same or any other tree view");
+ treeViewOpen?: BOOLt = new BoolInfo('whether this document is expanded in a tree view');
treeViewExpandedView?: string; // which field/thing is displayed when this item is opened in tree view
- treeViewExpandedViewLock?: boolean; // whether the expanded view can be changed
+ treeViewExpandedViewLock?: BOOLt = new BoolInfo('whether the expanded view can be changed');
treeViewChecked?: ScriptField; // script to call when a tree view checkbox is checked
- treeViewTruncateTitleWidth?: number;
- treeViewHasOverlay?: boolean; // whether the treeview has an overlay for freeform annotations
+ treeViewTruncateTitleWidth?: NUMt = new NumInfo('maximum width of a treew view title before truncation');
+ treeViewHasOverlay?: BOOLt = new BoolInfo('whether the treeview has an overlay for freeform annotations');
treeViewType?: string; // whether treeview is a Slide, file system, or (default) collection hierarchy
- sidebarColor?: string; // background color of text sidebar
- sidebarViewType?: string; // collection type of text sidebar
- docMaxAutoHeight?: number; // maximum height for newly created (eg, from pasting) text documents
+ treeViewFreezeChildren?: STRt = new StrInfo('set (add, remove, add|remove) to disable adding, removing or both from collection');
+
+ sidebar_color?: string; // background color of text sidebar
+ sidebar_collectionType?: string; // collection type of text sidebar
+
text?: string;
- textTransform?: string; // is linear view expanded
- letterSpacing?: string; // is linear view expanded
+ textTransform?: string;
+ letterSpacing?: string;
iconTemplate?: string; // name of icon template style
- selectedIndex?: number; // which item in a linear view has been selected using the "thumb doc" ui
+ selectedIndex?: NUMt = new NumInfo("which item in a linear view has been selected using the 'thumb doc' ui");
+
+ fieldValues?: List<any>; // possible values a field can have (used by FieldInfo's only)
+ fieldType?: string; // display type of a field, e.g. string, number, enumeration (used by FieldInfo's only)
+
clipboard?: Doc;
- searchQuery?: string; // for quersyBox
- useLinkSmallAnchor?: boolean; // whether links to this document should use a miniature linkAnchorBox
- border?: string; //for searchbox
hoverBackgroundColor?: string; // background color of a label when hovered
- linkRelationshipList?: List<string>; // for storing different link relationships (when set by user in the link editor)
- linkRelationshipSizes?: List<number>; //stores number of links contained in each relationship
- linkColorList?: List<string>; // colors of links corresponding to specific link relationships
+ userColor?: STRt = new StrInfo('color associated with a Dash user (seen in header fields of shared documents)');
}
export namespace Docs {
export let newAccount: boolean = false;
@@ -394,8 +435,8 @@ export namespace Docs {
_yMargin: 10,
nativeDimModifiable: true,
nativeHeightUnfrozen: true,
- forceReflow: true,
- links: '@links(self)',
+ layout_forceReflow: true,
+ defaultDoubleClick: 'ignore',
},
},
],
@@ -403,84 +444,77 @@ export namespace Docs {
DocumentType.SEARCH,
{
layout: { view: SearchBox, dataField: defaultDataKey },
- options: { _width: 400, links: '@links(self)' },
- },
- ],
- [
- DocumentType.FILTER,
- {
- layout: { view: FilterBox, dataField: defaultDataKey },
- options: { _width: 400, links: '@links(self)' },
+ options: { _width: 400 },
},
],
[
DocumentType.COLOR,
{
layout: { view: ColorBox, dataField: defaultDataKey },
- options: { _nativeWidth: 220, _nativeHeight: 300, links: '@links(self)' },
+ options: { _nativeWidth: 220, _nativeHeight: 300 },
},
],
[
DocumentType.IMG,
{
layout: { view: ImageBox, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ options: { freeform: '' },
},
],
[
DocumentType.WEB,
{
layout: { view: WebBox, dataField: defaultDataKey },
- options: { _height: 300, _fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true, links: '@links(self)' },
+ options: { _height: 300, _layout_fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true, waitForDoubleClickToClick: 'always' },
},
],
[
DocumentType.COL,
{
layout: { view: CollectionView, dataField: defaultDataKey },
- options: { _fitWidth: true, _panX: 0, _panY: 0, _viewScale: 1, links: '@links(self)' },
+ options: { _layout_fitWidth: true, freeform: '', _freeform_panX: 0, _freeform_panY: 0, _freeform_scale: 1 },
},
],
[
DocumentType.KVP,
{
layout: { view: KeyValueBox, dataField: defaultDataKey },
- options: { _fitWidth: true, _height: 150 },
+ options: { _layout_fitWidth: true, _height: 150 },
},
],
[
DocumentType.VID,
{
layout: { view: VideoBox, dataField: defaultDataKey },
- options: { _currentTimecode: 0, links: '@links(self)' },
+ options: { _layout_currentTimecode: 0 },
},
],
[
DocumentType.AUDIO,
{
layout: { view: AudioBox, dataField: defaultDataKey },
- options: { _height: 100, backgroundColor: 'lightGray', _fitWidth: true, forceReflow: true, nativeDimModifiable: true, links: '@links(self)' },
+ options: { _height: 100, layout_fitWidth: true, layout_forceReflow: true, nativeDimModifiable: true },
},
],
[
DocumentType.REC,
{
layout: { view: VideoBox, dataField: defaultDataKey },
- options: { _height: 100, backgroundColor: 'pink', links: '@links(self)' },
+ options: { _height: 100, backgroundColor: 'pink' },
},
],
[
DocumentType.PDF,
{
layout: { view: PDFBox, dataField: defaultDataKey },
- options: { _curPage: 1, _fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true, links: '@links(self)' },
+ options: { _layout_curPage: 1, _layout_fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true },
},
],
[
DocumentType.MAP,
{
layout: { view: MapBox, dataField: defaultDataKey },
- options: { _height: 600, _width: 800, nativeDimModifiable: true, links: '@links(self)' },
+ options: { _height: 600, _width: 800, nativeDimModifiable: true },
},
],
[
@@ -493,16 +527,17 @@ export namespace Docs {
[
DocumentType.LINK,
{
- layout: { view: LinkBox, dataField: defaultDataKey },
+ layout: { view: LinkBox, dataField: 'link' },
options: {
childDontRegisterViews: true,
- _isLinkButton: true,
+ onClick: FollowLinkScript(),
+ layout_hideLinkAnchors: true,
_height: 150,
- description: '',
- showCaption: 'description',
+ link: '',
+ link_description: '',
+ layout_showCaption: 'link_description',
backgroundColor: 'lightblue', // lightblue is default color for linking dot and link documents text comment area
- links: '@links(self)',
- _removeDropProperties: new List(['isLinkButton']),
+ _dropPropertiesToRemove: new List(['onClick']),
},
},
],
@@ -511,7 +546,7 @@ export namespace Docs {
{
data: new List<Doc>(),
layout: { view: EmptyBox, dataField: defaultDataKey },
- options: { childDropAction: 'alias', title: 'Global Link Database' },
+ options: { title: 'Global Link Database' },
},
],
[
@@ -519,14 +554,14 @@ export namespace Docs {
{
data: new List<Doc>(),
layout: { view: EmptyBox, dataField: defaultDataKey },
- options: { childDropAction: 'alias', title: 'Global Script Database' },
+ options: { title: 'Global Script Database' },
},
],
[
DocumentType.SCRIPTING,
{
layout: { view: ScriptingBox, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ options: {},
},
],
[
@@ -539,92 +574,93 @@ export namespace Docs {
DocumentType.LABEL,
{
layout: { view: LabelBox, dataField: defaultDataKey },
- options: { links: '@links(self)', _singleLine: true },
+ options: { _singleLine: true },
},
],
[
DocumentType.EQUATION,
{
- layout: { view: EquationBox, dataField: defaultDataKey },
- options: { links: '@links(self)', nativeDimModifiable: true, hideResizeHandles: true, hideDecorationTitle: true },
+ layout: { view: EquationBox, dataField: 'text' },
+ options: { nativeDimModifiable: true, fontSize: '14px', layout_hideResizeHandles: true, layout_hideDecorationTitle: true },
},
],
[
DocumentType.FUNCPLOT,
{
layout: { view: FunctionPlotBox, dataField: defaultDataKey },
- options: { nativeDimModifiable: true, links: '@links(self)' },
+ options: { nativeDimModifiable: true },
},
],
[
DocumentType.BUTTON,
{
layout: { view: LabelBox, dataField: 'onClick' },
- options: { links: '@links(self)' },
+ options: {},
},
],
[
DocumentType.SLIDER,
{
layout: { view: SliderBox, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ options: {},
},
],
[
DocumentType.PRES,
{
layout: { view: PresBox, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ options: { defaultDoubleClick: 'ignore', layout_hideLinkAnchors: true },
},
],
[
DocumentType.FONTICON,
{
- layout: { view: FontIconBox, dataField: defaultDataKey },
- options: { hideLinkButton: true, _width: 40, _height: 40, borderRounding: '100%', links: '@links(self)' },
+ layout: { view: FontIconBox, dataField: 'icon' },
+ options: { defaultDoubleClick: 'ignore', waitForDoubleClickToClick: 'never', layout_hideLinkButton: true, _width: 40, _height: 40 },
},
],
[
DocumentType.WEBCAM,
{
layout: { view: RecordingBox, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ options: {},
},
],
[
DocumentType.PRESELEMENT,
{
layout: { view: PresElementBox, dataField: defaultDataKey },
- options: { title: 'pres element template', _fitWidth: true, _xMargin: 0, isTemplateDoc: true, isTemplateForField: 'data' },
+ options: { title: 'pres element template', _layout_fitWidth: true, _xMargin: 0, isTemplateDoc: true, isTemplateForField: 'data' },
},
],
[
- DocumentType.MARKER,
+ DocumentType.CONFIG,
{
layout: { view: CollectionView, dataField: defaultDataKey },
- options: { links: '@links(self)', hideLinkButton: true, pointerEvents: 'none' },
+ options: { layout_hideLinkButton: true, pointerEvents: 'none', layout_unrendered: true },
},
],
[
DocumentType.INK,
{
// NOTE: this is unused!! ink fields are filled in directly within the InkDocument() method
- layout: { view: InkingStroke, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ layout: { view: InkingStroke, dataField: 'stroke' },
+ options: {},
},
],
[
DocumentType.SCREENSHOT,
{
layout: { view: ScreenshotBox, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ options: { nativeDimModifiable: true, nativeHeightUnfrozen: true },
},
],
[
DocumentType.COMPARISON,
{
+ data: '',
layout: { view: ComparisonBox, dataField: defaultDataKey },
- options: { clipWidth: 50, nativeDimModifiable: true, backgroundColor: 'gray', targetDropAction: 'alias', links: '@links(self)' },
+ options: { backgroundColor: 'gray', dropAction: 'move', waitForDoubleClickToClick: 'always' },
},
],
[
@@ -632,28 +668,36 @@ export namespace Docs {
{
data: new List<Doc>(),
layout: { view: EmptyBox, dataField: defaultDataKey },
- options: { childDropAction: 'alias', title: 'Global Group Database' },
+ options: { title: 'Global Group Database' },
},
],
[
DocumentType.GROUP,
{
layout: { view: EmptyBox, dataField: defaultDataKey },
- options: { links: '@links(self)' },
+ options: {},
},
],
[
DocumentType.DATAVIZ,
{
layout: { view: DataVizBox, dataField: defaultDataKey },
- options: { _fitWidth: true, nativeDimModifiable: true, links: '@links(self)' },
+ options: { _layout_fitWidth: true, nativeDimModifiable: true },
},
],
[
DocumentType.LOADING,
{
layout: { view: LoadingBox, dataField: '' },
- options: { _fitWidth: true, _fitHeight: true, nativeDimModifiable: true, links: '@links(self)' },
+ options: { _layout_fitWidth: true, _fitHeight: true, nativeDimModifiable: true },
+ },
+ ],
+ [
+ DocumentType.SIMULATION,
+ {
+ data: '',
+ layout: { view: PhysicsSimulationBox, dataField: defaultDataKey, _width: 1000, _height: 800 },
+ options: { _height: 100, layout_forceReflow: true, nativeHeightUnfrozen: true, mass1: '', mass2: '', nativeDimModifiable: true, position: '', acceleration: '', pendulum: '', spring: '', wedge: '', simulation: '', review: '' },
},
],
]);
@@ -661,7 +705,7 @@ export namespace Docs {
const suffix = 'Proto';
/**
- * This function loads or initializes the prototype for each docment type.
+ * This function loads or initializes the prototype for each document type.
*
* This is an asynchronous function because it has to attempt
* to fetch the prototype documents from the server.
@@ -672,8 +716,6 @@ export namespace Docs {
* haven't been initialized, the newly initialized prototype document.
*/
export async function initialize(): Promise<void> {
- ProxyField.initPlugin();
- ComputedField.initPlugin();
// non-guid string ids for each document prototype
const prototypeIds = Object.values(DocumentType)
.filter(type => type !== DocumentType.NONE)
@@ -749,18 +791,17 @@ export namespace Docs {
// synthesize the default options, the type and title from computed values and
// whatever options pertain to this specific prototype
const options: DocumentOptions = {
- system: true,
- _layoutKey: 'layout',
+ isSystem: true,
+ _layout_fieldKey: 'layout',
title,
type,
- baseProto: true,
+ isBaseProto: true,
x: 0,
y: 0,
_width: 300,
...(template.options || {}),
layout: layout.view?.LayoutString(layout.dataField),
data: template.data,
- layout_keyValue: KeyValueBox.LayoutString(''),
};
Object.entries(options).map(pair => {
if (typeof pair[1] === 'string' && pair[1].startsWith('@')) {
@@ -795,24 +836,24 @@ export namespace Docs {
* main document.
*/
function InstanceFromProto(proto: Doc, data: Field | undefined, options: DocumentOptions, delegId?: string, fieldKey: string = 'data', protoId?: string, placeholderDoc?: Doc) {
- const viewKeys = ['x', 'y', 'system']; // keys that should be addded to the view document even though they don't begin with an "_"
+ const viewKeys = ['x', 'y', 'isSystem']; // keys that should be addded to the view document even though they don't begin with an "_"
const { omit: dataProps, extract: viewProps } = OmitKeys(options, viewKeys, '^_');
- dataProps['acl-Override'] = 'None';
+ // dataProps['acl-Override'] = SharingPermissions.Unset;
dataProps['acl-Public'] = options['acl-Public'] ? options['acl-Public'] : Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Augment;
- dataProps.system = viewProps.system;
- dataProps.isPrototype = true;
+ dataProps.isSystem = viewProps.isSystem;
+ dataProps.isDataDoc = true;
dataProps.author = Doc.CurrentUserEmail;
- dataProps.creationDate = new DateField();
+ dataProps.author_date = new DateField();
if (fieldKey) {
- dataProps[`${fieldKey}-lastModified`] = new DateField();
+ dataProps[`${fieldKey}_modificationDate`] = new DateField();
dataProps[fieldKey] = data;
// so that the list of annotations is already initialised, prevents issues in addonly.
// without this, if a doc has no annotations but the user has AddOnly privileges, they won't be able to add an annotation because they would have needed to create the field's list which they don't have permissions to do.
- dataProps[fieldKey + '-annotations'] = new List<Doc>();
- dataProps[fieldKey + '-sidebar'] = new List<Doc>();
+ dataProps[fieldKey + '_annotations'] = new List<Doc>();
+ dataProps[fieldKey + '_sidebar'] = new List<Doc>();
}
// users placeholderDoc as proto if it exists
@@ -824,7 +865,7 @@ export namespace Docs {
const viewFirstProps: { [id: string]: any } = {};
viewFirstProps['acl-Public'] = options['_acl-Public'] ? options['_acl-Public'] : Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Augment;
- viewFirstProps['acl-Override'] = 'None';
+ // viewFirstProps['acl-Override'] = SharingPermissions.Unset;
viewFirstProps.author = Doc.CurrentUserEmail;
let viewDoc: Doc;
// determines whether viewDoc should be created using placeholder Doc or default
@@ -836,13 +877,11 @@ export namespace Docs {
viewDoc = Doc.assign(Doc.MakeDelegate(dataDoc, delegId), viewFirstProps, true, true);
}
Doc.assign(viewDoc, viewProps, true, true);
- ![DocumentType.LINK, DocumentType.MARKER, DocumentType.LABEL].includes(viewDoc.type as any) && DocUtils.MakeLinkToActiveAudio(() => viewDoc);
+ if (![DocumentType.LINK, DocumentType.CONFIG, DocumentType.LABEL].includes(viewDoc.type as any)) {
+ DocUtils.MakeLinkToActiveAudio(() => viewDoc);
+ }
- !Doc.IsSystem(dataDoc) &&
- ![DocumentType.MARKER, DocumentType.KVP, DocumentType.LINK, DocumentType.LINKANCHOR].includes(proto.type as any) &&
- !dataDoc.isFolder &&
- !dataProps.annotationOn &&
- Doc.AddDocToList(Doc.MyFileOrphans, undefined, dataDoc);
+ Doc.AddFileOrphan(dataDoc);
updateCachedAcls(dataDoc);
updateCachedAcls(viewDoc);
@@ -852,7 +891,7 @@ export namespace Docs {
export function ImageDocument(url: string | ImageField, options: DocumentOptions = {}, overwriteDoc?: Doc) {
const imgField = url instanceof ImageField ? url : new ImageField(url);
- return InstanceFromProto(Prototypes.get(DocumentType.IMG), imgField, { title: basename(imgField.url.href), ...options }, undefined, undefined, undefined, overwriteDoc);
+ return InstanceFromProto(Prototypes.get(DocumentType.IMG), imgField, { _nativeDimModifiable: false, _nativeHeightUnfrozen: false, title: basename(imgField.url.href), ...options }, undefined, undefined, undefined, overwriteDoc);
}
export function PresDocument(options: DocumentOptions = {}) {
@@ -880,19 +919,11 @@ export namespace Docs {
}
export function ComparisonDocument(options: DocumentOptions = { title: 'Comparison Box' }) {
- return InstanceFromProto(Prototypes.get(DocumentType.COMPARISON), '', options);
+ return InstanceFromProto(Prototypes.get(DocumentType.COMPARISON), undefined, options);
}
export function AudioDocument(url: string, options: DocumentOptions = {}, overwriteDoc?: Doc) {
- return InstanceFromProto(
- Prototypes.get(DocumentType.AUDIO),
- new AudioField(url),
- { ...options, backgroundColor: ComputedField.MakeFunction("this._mediaState === 'playing' ? 'green':'gray'") as any },
- undefined,
- undefined,
- undefined,
- overwriteDoc
- );
+ return InstanceFromProto(Prototypes.get(DocumentType.AUDIO), new AudioField(url), options, undefined, undefined, undefined, overwriteDoc);
}
export function RecordingDocument(url: string, options: DocumentOptions = {}) {
@@ -936,16 +967,17 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.RTF), field, options, undefined, fieldKey);
}
- export function LinkDocument(source: { doc: Doc; ctx?: Doc }, target: { doc: Doc; ctx?: Doc }, options: DocumentOptions = {}, id?: string) {
+ export function LinkDocument(source: Doc, target: Doc, options: DocumentOptions = {}, id?: string) {
const linkDoc = InstanceFromProto(
Prototypes.get(DocumentType.LINK),
undefined,
{
- anchor1: source.doc,
- anchor2: target.doc,
+ link_anchor_1: source,
+ link_anchor_2: target,
...options,
},
- id
+ id,
+ 'link'
);
LinkManager.Instance.addLink(linkDoc);
@@ -953,49 +985,35 @@ export namespace Docs {
return linkDoc;
}
- export function InkDocument(
- color: string,
- tool: string,
- strokeWidth: number,
- strokeBezier: string,
- fillColor: string,
- arrowStart: string,
- arrowEnd: string,
- dash: string,
- points: PointData[],
- isInkMask: boolean,
- options: DocumentOptions = {}
- ) {
+ export function InkDocument(color: string, strokeWidth: number, stroke_bezier: string, fillColor: string, arrowStart: string, arrowEnd: string, dash: string, points: PointData[], isInkMask: boolean, options: DocumentOptions = {}) {
const I = new Doc();
I[Initializing] = true;
- I.isInkMask = isInkMask;
I.type = DocumentType.INK;
- I.layout = InkingStroke.LayoutString('data');
+ I.layout = InkingStroke.LayoutString('stroke');
+ I.layout_fitWidth = true;
+ I.layout_hideDecorationTitle = true; // don't show title when selected
+ // I.layout_hideOpenButton = true; // don't show open full screen button when selected
I.color = color;
- I.hideDecorationTitle = true; // don't show title when selected
- // I.hideOpenButton = true; // don't show open full screen button when selected
I.fillColor = fillColor;
- I.strokeWidth = strokeWidth;
- I.strokeBezier = strokeBezier;
- I.strokeStartMarker = arrowStart;
- I.strokeEndMarker = arrowEnd;
- I.strokeDash = dash;
- I.tool = tool;
- I.fitWidth = true;
- I['text-align'] = 'center';
+ I.stroke = new InkField(points);
+ I.stroke_width = strokeWidth;
+ I.stroke_bezier = stroke_bezier;
+ I.stroke_startMarker = arrowStart;
+ I.stroke_endMarker = arrowEnd;
+ I.stroke_dash = dash;
+ I.stroke_isInkMask = isInkMask;
+ I.text_align = 'center';
I.title = 'ink';
I.x = options.x as number;
I.y = options.y as number;
I._width = options._width as number;
I._height = options._height as number;
- I._fontFamily = 'cursive';
I.author = Doc.CurrentUserEmail;
I.rotation = 0;
- I.data = new InkField(points);
- I.creationDate = new DateField();
+ I.defaultDoubleClick = 'click';
+ I.author_date = new DateField();
I['acl-Public'] = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Augment;
- I['acl-Override'] = 'None';
- I.links = ComputedField.MakeFunction('links(self)');
+ //I['acl-Override'] = SharingPermissions.Unset;
I[Initializing] = false;
return I;
}
@@ -1026,69 +1044,65 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.MAP), new List(documents), options);
}
- export function MapMarkerDocument(lat: number, lng: number, infoWindowOpen: boolean, documents: Array<Doc>, options: DocumentOptions, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.MARKER), new List(documents), { lat, lng, infoWindowOpen, ...options }, id);
- }
-
- export function KVPDocument(document: Doc, options: DocumentOptions = {}) {
- return InstanceFromProto(Prototypes.get(DocumentType.KVP), document, { title: document.title + '.kvp', ...options });
- }
+ // shouldn't ever need to create a KVP document-- instead set the LayoutTemplateString to be a KeyValueBox for the DocumentView (see addDocTab in TabDocView)
+ // export function KVPDocument(document: Doc, options: DocumentOptions = {}) {
+ // return InstanceFromProto(Prototypes.get(DocumentType.KVP), document, { title: document.title + '.kvp', ...options });
+ // }
export function FreeformDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
- const inst = InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _xPadding: 20, _yPadding: 20, ...options, _viewType: CollectionViewType.Freeform }, id);
- documents.map(d => (d.context = inst));
+ const inst = InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _xPadding: 20, _yPadding: 20, ...options, _type_collection: CollectionViewType.Freeform }, id);
+ documents.forEach(d => (d.embedContainer = inst));
return inst;
}
- export function WebanchorDocument(url?: string, options: DocumentOptions = {}, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.MARKER), url, options, id);
+ export function ConfigDocument(options: DocumentOptions, id?: string) {
+ return InstanceFromProto(Prototypes.get(DocumentType.CONFIG), options?.data, options, id);
}
- export function TextanchorDocument(options: DocumentOptions = {}, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.MARKER), options?.data, options, id);
+ export function HTMLMarkerDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Freeform }, id);
}
-
- export function HTMLAnchorDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.MARKER), new List(documents), options, id);
+ export function MapMarkerDocument(lat: number, lng: number, infoWindowOpen: boolean, documents: Array<Doc>, options: DocumentOptions, id?: string) {
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { lat, lng, infoWindowOpen, ...options, _type_collection: CollectionViewType.Freeform }, id);
}
export function PileDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _overflow: 'visible', _forceActive: true, _noAutoscroll: true, ...options, _viewType: CollectionViewType.Pile }, id);
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { dropAction: 'move', _forceActive: true, _freeform_noZoom: true, _freeform_noAutoPan: true, ...options, _type_collection: CollectionViewType.Pile }, id);
}
export function LinearDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Linear }, id);
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Linear }, id);
}
export function MapCollectionDocument(documents: Array<Doc>, options: DocumentOptions = {}) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Map });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Map });
}
export function CarouselDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Carousel });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Carousel });
}
export function Carousel3DDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Carousel3D });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Carousel3D });
}
export function SchemaDocument(schemaHeaders: SchemaHeaderField[], documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaHeaders: new List(schemaHeaders), ...options, _viewType: CollectionViewType.Schema });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaHeaders: new List(schemaHeaders), ...options, _type_collection: CollectionViewType.Schema });
}
export function TreeDocument(documents: Array<Doc>, options: DocumentOptions, id?: string, protoId?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _xMargin: 5, _yMargin: 5, ...options, _viewType: CollectionViewType.Tree }, id, undefined, protoId);
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _xMargin: 5, _yMargin: 5, ...options, _type_collection: CollectionViewType.Tree }, id, undefined, protoId);
}
export function StackingDocument(documents: Array<Doc>, options: DocumentOptions, id?: string, protoId?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Stacking }, id, undefined, protoId);
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Stacking }, id, undefined, protoId);
}
export function NoteTakingDocument(documents: Array<Doc>, options: DocumentOptions, id?: string, protoId?: string) {
return InstanceFromProto(
Prototypes.get(DocumentType.COL),
new List(documents),
- { columnHeaders: new List<SchemaHeaderField>([new SchemaHeaderField('Untitled')]), ...options, _viewType: CollectionViewType.NoteTaking },
+ { columnHeaders: new List<SchemaHeaderField>([new SchemaHeaderField('Untitled')]), ...options, _type_collection: CollectionViewType.NoteTaking },
id,
undefined,
protoId
@@ -1096,14 +1110,14 @@ export namespace Docs {
}
export function MulticolumnDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Multicolumn });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Multicolumn });
}
export function MultirowDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Multirow });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Multirow });
}
export function MasonryDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Masonry });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Masonry });
}
export function LabelDocument(options?: DocumentOptions) {
@@ -1111,7 +1125,7 @@ export namespace Docs {
}
export function EquationDocument(options?: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.EQUATION), undefined, { ...(options || {}) });
+ return InstanceFromProto(Prototypes.get(DocumentType.EQUATION), undefined, { ...(options || {}) }, undefined, 'text');
}
export function FunctionPlotDocument(documents: Array<Doc>, options?: DocumentOptions) {
@@ -1142,7 +1156,7 @@ export namespace Docs {
}
export function DockDocument(documents: Array<Doc>, config: string, options: DocumentOptions, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { freezeChildren: 'remove|add', ...options, viewType: CollectionViewType.Docking, _viewType: CollectionViewType.Docking, dockingConfig: config }, id);
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { treeViewFreezeChildren: 'remove|add', ...options, _type_collection: CollectionViewType.Docking, dockingConfig: config }, id);
}
export function DirectoryImportDocument(options: DocumentOptions = {}) {
@@ -1164,36 +1178,41 @@ export namespace Docs {
},
],
};
- return DockDocument(
+ const doc = DockDocument(
configs.map(c => c.doc),
JSON.stringify(layoutConfig),
options,
id
);
+ configs.map(c => (c.doc.embedContainer = doc));
+ return doc;
}
export function DelegateDocument(proto: Doc, options: DocumentOptions = {}) {
return InstanceFromProto(proto, undefined, options);
}
+
+ export function SimulationDocument(options?: DocumentOptions) {
+ return InstanceFromProto(Prototypes.get(DocumentType.SIMULATION), undefined, { ...(options || {}) });
+ }
}
}
export namespace DocUtils {
/**
* @param docs
- * @param docFilters
- * @param docRangeFilters
- * @param viewSpecScript
- * Given a list of docs and docFilters, @returns the list of Docs that match those filters
+ * @param childFilters
+ * @param childFiltersByRanges
+ * @param parentCollection
+ * Given a list of docs and childFilters, @returns the list of Docs that match those filters
*/
- export function FilterDocs(docs: Doc[], docFilters: string[], docRangeFilters: string[], viewSpecScript?: ScriptField, parentCollection?: Doc) {
- const childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
- if (!docFilters?.length && !docRangeFilters?.length) {
+ export function FilterDocs(childDocs: Doc[], childFilters: string[], childFiltersByRanges: string[], parentCollection?: Doc) {
+ if (!childFilters?.length && !childFiltersByRanges?.length) {
return childDocs.filter(d => !d.cookies); // remove documents that need a cookie if there are no filters to provide one
}
const filterFacets: { [key: string]: { [value: string]: string } } = {}; // maps each filter key to an object with value=>modifier fields
- docFilters.forEach(filter => {
+ childFilters.forEach(filter => {
const fields = filter.split(':');
const key = fields[0];
const value = fields[1];
@@ -1204,7 +1223,7 @@ export namespace DocUtils {
filterFacets[key][value] = modifiers;
});
- const filteredDocs = docFilters.length
+ const filteredDocs = childFilters.length
? childDocs.filter(d => {
if (d.z) return true;
// if the document needs a cookie but no filter provides the cookie, then the document does not pass the filter
@@ -1239,7 +1258,7 @@ export namespace DocUtils {
? true
: matches.some(value => {
if (facetKey.startsWith('*')) {
- // fields starting with a '*' are used to match families of related fields. ie, *lastModified will match text-lastModified, data-lastModified, etc
+ // fields starting with a '*' are used to match families of related fields. ie, *modificationDate will match text_modificationDate, data_modificationDate, etc
const allKeys = Array.from(Object.keys(d));
allKeys.push(...Object.keys(Doc.GetProto(d)));
const keys = allKeys.filter(key => key.includes(facetKey.substring(1)));
@@ -1248,7 +1267,7 @@ export namespace DocUtils {
return Field.toString(d[facetKey] as Field).includes(value);
});
// if we're ORing them together, the default return is false, and we return true for a doc if it satisfies any one set of criteria
- if ((parentCollection?.currentFilter as Doc)?.filterBoolean === 'OR') {
+ if (parentCollection?.childFilters_boolean === 'OR') {
if (satisfiesUnsetsFacets && satisfiesExistsFacets && satisfiesCheckFacets && !failsNotEqualFacets && satisfiesMatchFacets) return true;
}
// if we're ANDing them together, the default return is true, and we return false for a doc if it doesn't satisfy any set of criteria
@@ -1256,14 +1275,14 @@ export namespace DocUtils {
if (!satisfiesUnsetsFacets || !satisfiesExistsFacets || !satisfiesCheckFacets || failsNotEqualFacets || (matches.length && !satisfiesMatchFacets)) return false;
}
}
- return (parentCollection?.currentFilter as Doc)?.filterBoolean === 'OR' ? false : true;
+ return (parentCollection?.currentFilter as Doc)?.childFilters_boolean === 'OR' ? false : true;
})
: childDocs;
const rangeFilteredDocs = filteredDocs.filter(d => {
- for (let i = 0; i < docRangeFilters.length; i += 3) {
- const key = docRangeFilters[i];
- const min = Number(docRangeFilters[i + 1]);
- const max = Number(docRangeFilters[i + 2]);
+ for (let i = 0; i < childFiltersByRanges.length; i += 3) {
+ const key = childFiltersByRanges[i];
+ const min = Number(childFiltersByRanges[i + 1]);
+ const max = Number(childFiltersByRanges[i + 2]);
const val = typeof d[key] === 'string' ? (Number(StrCast(d[key])).toString() === StrCast(d[key]) ? Number(StrCast(d[key])) : undefined) : Cast(d[key], 'number', null);
if (val === undefined) {
//console.log("Should 'undefined' pass range filter or not?")
@@ -1274,58 +1293,19 @@ export namespace DocUtils {
return rangeFilteredDocs;
}
- export function Publish(promoteDoc: Doc, targetID: string, addDoc: any, remDoc: any) {
- targetID = targetID.replace(/^-/, '').replace(/\([0-9]*\)$/, '');
- DocServer.GetRefField(targetID).then(doc => {
- if (promoteDoc !== doc) {
- let copy = doc as Doc;
- if (copy) {
- Doc.Overwrite(promoteDoc, copy, true);
- } else {
- copy = Doc.MakeCopy(promoteDoc, true, targetID);
- }
- !doc && (copy.title = undefined) && (Doc.GetProto(copy).title = targetID);
- addDoc && addDoc(copy);
- remDoc && remDoc(promoteDoc);
- if (!doc) {
- DocListCastAsync(promoteDoc.links).then(links => {
- links &&
- links.map(async link => {
- if (link) {
- const a1 = await Cast(link.anchor1, Doc);
- if (a1 && Doc.AreProtosEqual(a1, promoteDoc)) link.anchor1 = copy;
- const a2 = await Cast(link.anchor2, Doc);
- if (a2 && Doc.AreProtosEqual(a2, promoteDoc)) link.anchor2 = copy;
- LinkManager.Instance.deleteLink(link);
- LinkManager.Instance.addLink(link);
- }
- });
- });
- }
- }
- });
- }
-
- export function DefaultFocus(doc: Doc, options: DocFocusOptions) {
- options?.afterFocus?.(false);
- }
-
- export let ActiveRecordings: { props: FieldViewProps; getAnchor: () => Doc }[] = [];
+ export let ActiveRecordings: { props: FieldViewProps; getAnchor: (addAsAnnotation: boolean) => Doc }[] = [];
export function MakeLinkToActiveAudio(getSourceDoc: () => Doc | undefined, broadcastEvent = true) {
broadcastEvent && runInAction(() => (DocumentManager.Instance.RecordingEvent = DocumentManager.Instance.RecordingEvent + 1));
return DocUtils.ActiveRecordings.map(audio => {
const sourceDoc = getSourceDoc();
- const link = sourceDoc && DocUtils.MakeLink({ doc: sourceDoc }, { doc: audio.getAnchor() || audio.props.Document }, 'recording annotation:linked recording', 'recording timeline');
- link && (link.followLinkLocation = 'add:right');
- return link;
+ return sourceDoc && DocUtils.MakeLink(sourceDoc, audio.getAnchor(true) || audio.props.Document, { link_displayLine: false, link_relationship: 'recording annotation:linked recording', link_description: 'recording timeline' });
});
}
- export function MakeLink(source: { doc: Doc }, target: { doc: Doc }, linkRelationship: string = '', description: string = '', id?: string, allowParCollectionLink?: boolean, showPopup?: number[]) {
- if (!linkRelationship) linkRelationship = target.doc.type === DocumentType.RTF ? 'Commentary:Comments On' : 'link';
- const sv = DocumentManager.Instance.getDocumentView(source.doc);
- if (!allowParCollectionLink && sv?.props.ContainingCollectionDoc === target.doc) return;
+ export function MakeLink(source: Doc, target: Doc, linkSettings: { link_relationship?: string; link_description?: string; link_displayLine?: boolean }, id?: string, showPopup?: number[]) {
+ if (!linkSettings.link_relationship) linkSettings.link_relationship = target.type === DocumentType.RTF ? 'Commentary:Comments On' : 'link';
+ const sv = DocumentManager.Instance.getDocumentView(source);
if (target.doc === Doc.UserDoc()) return undefined;
const makeLink = action((linkDoc: Doc, showPopup?: number[]) => {
@@ -1364,18 +1344,17 @@ export namespace DocUtils {
source,
target,
{
- title: ComputedField.MakeFunction('generateLinkTitle(self)') as any,
- 'anchor1-useLinkSmallAnchor': source.doc.useLinkSmallAnchor ? true : undefined,
- 'anchor2-useLinkSmallAnchor': target.doc.useLinkSmallAnchor ? true : undefined,
'acl-Public': SharingPermissions.Augment,
'_acl-Public': SharingPermissions.Augment,
- linkDisplay: true,
- _hidden: true,
- _linkAutoMove: true,
- linkRelationship,
- _showCaption: 'description',
- _showTitle: 'linkRelationship',
- description,
+ title: ComputedField.MakeFunction('generateLinkTitle(self)') as any,
+ link_anchor_1_useSmallAnchor: source.useSmallAnchor ? true : undefined,
+ link_anchor_2_useSmallAnchor: target.useSmallAnchor ? true : undefined,
+ link_displayLine: linkSettings.link_displayLine,
+ link_relationship: linkSettings.link_relationship,
+ link_description: linkSettings.link_description,
+ link_autoMoveAnchors: true,
+ _layout_showCaption: 'link_description',
+ _layout_showTitle: 'link_relationship',
},
id
),
@@ -1389,11 +1368,12 @@ export namespace DocUtils {
const script = scripts[key];
if (ScriptCast(doc[key])?.script.originalScript !== scripts[key] && script) {
doc[key] = ScriptField.MakeScript(script, {
+ self: Doc.name,
+ this: Doc.name,
dragData: DragManager.DocumentDragData.name,
value: 'any',
_readOnly_: 'boolean',
scriptContext: 'any',
- thisContainer: Doc.name,
documentView: Doc.name,
heading: Doc.name,
checked: 'boolean',
@@ -1405,12 +1385,15 @@ export namespace DocUtils {
}
});
funcs &&
- Object.keys(funcs).map(key => {
- const cfield = ComputedField.WithoutComputed(() => FieldValue(doc[key]));
- if (ScriptCast(cfield)?.script.originalScript !== funcs[key]) {
- doc[key] = funcs[key] ? ComputedField.MakeFunction(funcs[key], { dragData: DragManager.DocumentDragData.name }, { _readOnly_: true }) : undefined;
- }
- });
+ Object.keys(funcs)
+ .filter(key => !key.endsWith('-setter'))
+ .map(key => {
+ const cfield = ComputedField.WithoutComputed(() => FieldValue(doc[key]));
+ if (ScriptCast(cfield)?.script.originalScript !== funcs[key]) {
+ const setFunc = Cast(funcs[key + '-setter'], 'string', null);
+ doc[key] = funcs[key] ? ComputedField.MakeFunction(funcs[key], { dragData: DragManager.DocumentDragData.name }, { _readOnly_: true }, setFunc) : undefined;
+ }
+ });
return doc;
}
export function AssignOpts(doc: Doc | undefined, reqdOpts: DocumentOptions, items?: Doc[]) {
@@ -1438,41 +1421,33 @@ export namespace DocUtils {
export function DocumentFromField(target: Doc, fieldKey: string, proto?: Doc, options?: DocumentOptions): Doc | undefined {
let created: Doc | undefined;
- let layout: ((fieldKey: string) => string) | undefined;
const field = target[fieldKey];
- const resolved = options || {};
+ const resolved = options ?? {};
if (field instanceof ImageField) {
created = Docs.Create.ImageDocument(field.url.href, resolved);
- layout = ImageBox.LayoutString;
+ created.layout = ImageBox.LayoutString(fieldKey);
} else if (field instanceof Doc) {
created = field;
} else if (field instanceof VideoField) {
created = Docs.Create.VideoDocument(field.url.href, resolved);
- layout = VideoBox.LayoutString;
+ created.layout = VideoBox.LayoutString(fieldKey);
} else if (field instanceof PdfField) {
created = Docs.Create.PdfDocument(field.url.href, resolved);
- layout = PDFBox.LayoutString;
+ created.layout = PDFBox.LayoutString(fieldKey);
} else if (field instanceof AudioField) {
created = Docs.Create.AudioDocument(field.url.href, resolved);
- layout = AudioBox.LayoutString;
- } else if (field instanceof RecordingField) {
- created = Docs.Create.RecordingDocument(field.url.href, resolved);
- layout = RecordingBox.LayoutString;
+ created.layout = AudioBox.LayoutString(fieldKey);
} else if (field instanceof InkField) {
- created = Docs.Create.InkDocument(ActiveInkColor(), Doc.ActiveTool, ActiveInkWidth(), ActiveInkBezierApprox(), ActiveFillColor(), ActiveArrowStart(), ActiveArrowEnd(), ActiveDash(), field.inkData, ActiveIsInkMask(), resolved);
- layout = InkingStroke.LayoutString;
+ created = Docs.Create.InkDocument(ActiveInkColor(), ActiveInkWidth(), ActiveInkBezierApprox(), ActiveFillColor(), ActiveArrowStart(), ActiveArrowEnd(), ActiveDash(), field.inkData, ActiveIsInkMask(), resolved);
+ created.layout = InkingStroke.LayoutString(fieldKey);
} else if (field instanceof List && field[0] instanceof Doc) {
created = Docs.Create.StackingDocument(DocListCast(field), resolved);
- layout = CollectionView.LayoutString;
- } else if (field instanceof MapField) {
- created = Docs.Create.MapDocument(DocListCast(field), resolved);
- layout = MapBox.LayoutString;
+ created.layout = CollectionView.LayoutString(fieldKey);
} else {
- created = Docs.Create.TextDocument('', { ...{ _width: 200, _height: 25, _autoHeight: true }, ...resolved });
- layout = FormattedTextBox.LayoutString;
+ created = Docs.Create.TextDocument('', { ...{ _width: 200, _height: 25, _layout_autoHeight: true }, ...resolved });
+ created.layout = FormattedTextBox.LayoutString(fieldKey);
}
if (created) {
- created.layout = layout?.(fieldKey);
created.title = fieldKey;
proto && created.proto && (created.proto = Doc.GetProto(proto));
}
@@ -1523,12 +1498,12 @@ export namespace DocUtils {
const id = s[s.length - 1];
return DocServer.GetRefField(id).then(field => {
if (field instanceof Doc) {
- const alias = Doc.MakeAlias(field);
- alias.x = (options.x as number) || 0;
- alias.y = (options.y as number) || 0;
- alias._width = (options._width as number) || 300;
- alias._height = (options._height as number) || (options._width as number) || 300;
- return alias;
+ const embedding = Doc.MakeEmbedding(field);
+ embedding.x = (options.x as number) || 0;
+ embedding.y = (options.y as number) || 0;
+ embedding._width = (options._width as number) || 300;
+ embedding._height = (options._height as number) || (options._width as number) || 300;
+ return embedding;
}
return undefined;
});
@@ -1544,23 +1519,23 @@ export namespace DocUtils {
!simpleMenu &&
ContextMenu.Instance.addItem({
description: 'Quick Notes',
- subitems: DocListCast((Doc.UserDoc()['template-notes'] as Doc).data).map((note, i) => ({
+ subitems: DocListCast((Doc.UserDoc()['template_notes'] as Doc).data).map((note, i) => ({
description: ':' + StrCast(note.title),
- event: undoBatch((args: { x: number; y: number }) => {
+ event: undoable((args: { x: number; y: number }) => {
const textDoc = Docs.Create.TextDocument('', {
_width: 200,
x,
y,
- _autoHeight: note._autoHeight !== false,
- title: StrCast(note.title) + '#' + (note.aliasCount = NumCast(note.aliasCount) + 1),
+ _layout_autoHeight: note._layout_autoHeight !== false,
+ title: StrCast(note.title) + '#' + (note.embeddingCount = NumCast(note.embeddingCount) + 1),
});
- textDoc.layoutKey = 'layout_' + note.title;
- textDoc[textDoc.layoutKey] = note;
+ textDoc.layout_fieldKey = 'layout_' + note.title;
+ textDoc[textDoc.layout_fieldKey] = note;
if (pivotField) {
textDoc[pivotField] = pivotValue;
}
docTextAdder(textDoc);
- }),
+ }, 'create quick note'),
icon: StrCast(note.icon) as IconProp,
})) as ContextMenuProps[],
icon: 'sticky-note',
@@ -1568,10 +1543,10 @@ export namespace DocUtils {
const documentList: ContextMenuProps[] = DocListCast(DocListCast(Doc.MyTools?.data)[0]?.data)
.filter(btnDoc => !btnDoc.hidden)
.map(btnDoc => Cast(btnDoc?.dragFactory, Doc, null))
- .filter(doc => doc && doc !== Doc.UserDoc().emptyTrail)
+ .filter(doc => doc && doc !== Doc.UserDoc().emptyTrail && doc !== Doc.UserDoc().emptyDataViz)
.map((dragDoc, i) => ({
description: ':' + StrCast(dragDoc.title).replace('Untitled ', ''),
- event: undoBatch((args: { x: number; y: number }) => {
+ event: undoable((args: { x: number; y: number }) => {
const newDoc = DocUtils.copyDragFactory(dragDoc);
if (newDoc) {
newDoc.author = Doc.CurrentUserEmail;
@@ -1584,7 +1559,7 @@ export namespace DocUtils {
}
docAdder?.(newDoc);
}
- }),
+ }, StrCast(dragDoc.title)),
icon: Doc.toIcon(dragDoc),
})) as ContextMenuProps[];
ContextMenu.Instance.addItem({
@@ -1596,7 +1571,7 @@ export namespace DocUtils {
export function makeCustomViewClicked(doc: Doc, creator: Opt<(documents: Array<Doc>, options: DocumentOptions, id?: string) => Doc>, templateSignature: string = 'custom', docLayoutTemplate?: Doc) {
const batch = UndoManager.StartBatch('makeCustomViewClicked');
runInAction(() => {
- doc.layoutKey = 'layout_' + templateSignature;
+ doc.layout_fieldKey = 'layout_' + templateSignature;
createCustomView(doc, creator, templateSignature, docLayoutTemplate);
});
batch.end();
@@ -1604,10 +1579,10 @@ export namespace DocUtils {
}
export function findTemplate(templateName: string, type: string, signature: string) {
let docLayoutTemplate: Opt<Doc>;
- const iconViews = DocListCast(Cast(Doc.UserDoc()['template-icons'], Doc, null)?.data);
- const templBtns = DocListCast(Cast(Doc.UserDoc()['template-buttons'], Doc, null)?.data);
- const noteTypes = DocListCast(Cast(Doc.UserDoc()['template-notes'], Doc, null)?.data);
- const clickFuncs = DocListCast(Cast(Doc.UserDoc().clickFuncs, Doc, null)?.data);
+ const iconViews = DocListCast(Cast(Doc.UserDoc()['template_icons'], Doc, null)?.data);
+ const templBtns = DocListCast(Cast(Doc.UserDoc()['template_buttons'], Doc, null)?.data);
+ const noteTypes = DocListCast(Cast(Doc.UserDoc()['template_notes'], Doc, null)?.data);
+ const clickFuncs = DocListCast(Cast(Doc.UserDoc()['template_clickFuncs'], Doc, null)?.data);
const allTemplates = iconViews
.concat(templBtns)
.concat(noteTypes)
@@ -1627,7 +1602,7 @@ export namespace DocUtils {
const customName = 'layout_' + templateSignature;
const _width = NumCast(doc._width);
const _height = NumCast(doc._height);
- const options = { title: 'data', backgroundColor: StrCast(doc.backgroundColor), _autoHeight: true, _width, x: -_width / 2, y: -_height / 2, _showSidebar: false };
+ const options = { title: 'data', backgroundColor: StrCast(doc.backgroundColor), _layout_autoHeight: true, _width, x: -_width / 2, y: -_height / 2, _layout_showSidebar: false };
if (docLayoutTemplate) {
if (docLayoutTemplate !== doc[customName]) {
@@ -1658,9 +1633,9 @@ export namespace DocUtils {
}
}
export function iconify(doc: Doc) {
- const layoutKey = Cast(doc.layoutKey, 'string', null);
+ const layout_fieldKey = Cast(doc.layout_fieldKey, 'string', null);
DocUtils.makeCustomViewClicked(doc, Docs.Create.StackingDocument, 'icon', undefined);
- if (layoutKey && layoutKey !== 'layout' && layoutKey !== 'layout_icon') doc.deiconifyLayout = layoutKey.replace('layout_', '');
+ if (layout_fieldKey && layout_fieldKey !== 'layout' && layout_fieldKey !== 'layout_icon') doc.deiconifyLayout = layout_fieldKey.replace('layout_', '');
}
export function pileup(docList: Doc[], x?: number, y?: number, size: number = 55, create: boolean = true) {
@@ -1689,7 +1664,7 @@ export namespace DocUtils {
});
});
if (create) {
- const newCollection = Docs.Create.PileDocument(docList, { title: 'pileup', x: (x || 0) - size, y: (y || 0) - size, _width: size * 2, _height: size * 2 });
+ const newCollection = Docs.Create.PileDocument(docList, { title: 'pileup', x: (x || 0) - size, y: (y || 0) - size, _width: size * 2, _height: size * 2, dragWhenActive: true });
newCollection.x = NumCast(newCollection.x) + NumCast(newCollection._width) / 2 - size;
newCollection.y = NumCast(newCollection.y) + NumCast(newCollection._height) / 2 - size;
newCollection._width = newCollection._height = size * 2;
@@ -1699,27 +1674,28 @@ export namespace DocUtils {
}
export function LeavePushpin(doc: Doc, annotationField: string) {
- if (doc.isPushpin) return undefined;
- const context = Cast(doc.context, Doc, null) ?? Cast(doc.annotationOn, Doc, null);
- const hasContextAnchor = DocListCast(doc.links).some(l => (l.anchor2 === doc && Cast(l.anchor1, Doc, null)?.annotationOn === context) || (l.anchor1 === doc && Cast(l.anchor2, Doc, null)?.annotationOn === context));
+ if (doc.followLinkToggle) return undefined;
+ const context = Cast(doc.embedContainer, Doc, null) ?? Cast(doc.annotationOn, Doc, null);
+ const hasContextAnchor = LinkManager.Links(doc).some(l => (l.link_anchor_2 === doc && Cast(l.link_anchor_1, Doc, null)?.annotationOn === context) || (l.link_anchor_1 === doc && Cast(l.link_anchor_2, Doc, null)?.annotationOn === context));
if (context && !hasContextAnchor && (context.type === DocumentType.VID || context.type === DocumentType.WEB || context.type === DocumentType.PDF || context.type === DocumentType.IMG)) {
const pushpin = Docs.Create.FontIconDocument({
title: 'pushpin',
- label: '',
+ icon_label: '',
annotationOn: Cast(doc.annotationOn, Doc, null),
- isPushpin: true,
+ followLinkToggle: true,
icon: 'map-pin',
x: Cast(doc.x, 'number', null),
y: Cast(doc.y, 'number', null),
backgroundColor: '#ACCEF7',
+ layout_hideAllLinks: true,
_width: 15,
_height: 15,
_xPadding: 0,
- _isLinkButton: true,
+ onClick: FollowLinkScript(),
_timecodeToShow: Cast(doc._timecodeToShow, 'number', null),
});
Doc.AddDocToList(context, annotationField, pushpin);
- const pushpinLink = DocUtils.MakeLink({ doc: pushpin }, { doc: doc }, 'pushpin', '');
+ const pushpinLink = DocUtils.MakeLink(pushpin, doc, { link_relationship: 'pushpin' }, '');
doc._timecodeToShow = undefined;
return pushpin;
}
@@ -1753,32 +1729,28 @@ export namespace DocUtils {
return dd;
}
- async function processFileupload(generatedDocuments: Doc[], name: string, type: string, result: Error | Upload.FileInformation, options: DocumentOptions, rootDoc?: Doc) {
+ async function processFileupload(generatedDocuments: Doc[], name: string, type: string, result: Error | Upload.FileInformation, options: DocumentOptions, overwriteDoc?: Doc) {
if (result instanceof Error) {
alert(`Upload failed: ${result.message}`);
return;
}
const full = { ...options, _width: 400, title: name };
const pathname = Utils.prepend(result.accessPaths.agnostic.client);
- const doc = await DocUtils.DocumentFromType(type, pathname, full, rootDoc);
+ const doc = await DocUtils.DocumentFromType(type, pathname, full, overwriteDoc);
if (doc) {
const proto = Doc.GetProto(doc);
proto.text = result.rawText;
- proto.fileUpload = pathname
- .replace(/.*\//, '')
- .replace('upload_', '')
- .replace(/\.[a-z0-9]*$/, '');
if (Upload.isImageInformation(result)) {
const maxNativeDim = Math.min(Math.max(result.nativeHeight, result.nativeWidth), defaultNativeImageDim);
const exifRotation = StrCast((result.exifData?.data as any)?.Orientation).toLowerCase();
proto['data-nativeOrientation'] = result.exifData?.data?.image?.Orientation ?? (exifRotation.includes('rotate 90') || exifRotation.includes('rotate 270') ? 5 : undefined);
- proto['data-nativeWidth'] = result.nativeWidth < result.nativeHeight ? (maxNativeDim * result.nativeWidth) / result.nativeHeight : maxNativeDim;
- proto['data-nativeHeight'] = result.nativeWidth < result.nativeHeight ? maxNativeDim : maxNativeDim / (result.nativeWidth / result.nativeHeight);
+ proto['data_nativeWidth'] = result.nativeWidth < result.nativeHeight ? (maxNativeDim * result.nativeWidth) / result.nativeHeight : maxNativeDim;
+ proto['data_nativeHeight'] = result.nativeWidth < result.nativeHeight ? maxNativeDim : maxNativeDim / (result.nativeWidth / result.nativeHeight);
if (NumCast(proto['data-nativeOrientation']) >= 5) {
- proto['data-nativeHeight'] = result.nativeWidth < result.nativeHeight ? (maxNativeDim * result.nativeWidth) / result.nativeHeight : maxNativeDim;
- proto['data-nativeWidth'] = result.nativeWidth < result.nativeHeight ? maxNativeDim : maxNativeDim / (result.nativeWidth / result.nativeHeight);
+ proto['data_nativeHeight'] = result.nativeWidth < result.nativeHeight ? (maxNativeDim * result.nativeWidth) / result.nativeHeight : maxNativeDim;
+ proto['data_nativeWidth'] = result.nativeWidth < result.nativeHeight ? maxNativeDim : maxNativeDim / (result.nativeWidth / result.nativeHeight);
}
- proto.contentSize = result.contentSize;
+ proto.data_contentSize = result.contentSize;
// exif gps data coordinates are stored in DMS (Degrees Minutes Seconds), the following operation converts that to decimal coordinates
const latitude = result.exifData?.data?.GPSLatitude;
const latitudeDirection = result.exifData?.data?.GPSLatitudeRef;
@@ -1790,10 +1762,12 @@ export namespace DocUtils {
}
}
if (Upload.isVideoInformation(result)) {
- proto['data-duration'] = result.duration;
+ proto.data_duration = result.duration;
}
- if (rootDoc) {
- Doc.removeCurrentlyLoading(rootDoc);
+ if (overwriteDoc) {
+ Doc.removeCurrentlyLoading(overwriteDoc);
+ // loading doc icons are just labels. so any icon views of loading docs need to be replaced with the proper icon view.
+ DocumentManager.Instance.getAllDocumentViews(overwriteDoc).forEach(dv => StrCast(dv.rootDoc.layout_fieldKey) === 'layout_icon' && dv.iconify(() => dv.iconify()));
}
generatedDocuments.push(doc);
}
@@ -1804,21 +1778,22 @@ export namespace DocUtils {
_xMargin: noMargins ? 0 : undefined,
_yMargin: noMargins ? 0 : undefined,
annotationOn,
- docMaxAutoHeight: maxHeight,
- backgroundColor: backgroundColor,
+ layout_maxAutoHeight: maxHeight,
+ backgroundColor,
_width: width || 200,
_height: 35,
x: x,
y: y,
- _fitWidth: true,
- _autoHeight: true,
+ _layout_fitWidth: true,
+ _layout_autoHeight: true,
+ _layout_enableAltContentUI: BoolCast(Doc.UserDoc().defaultToFlashcards),
title,
});
const template = Doc.UserDoc().defaultTextLayout;
if (template instanceof Doc) {
tbox._width = NumCast(template._width);
- tbox.layoutKey = 'layout_' + StrCast(template.title);
- Doc.GetProto(tbox)[StrCast(tbox.layoutKey)] = template;
+ tbox.layout_fieldKey = 'layout_' + StrCast(template.title);
+ Doc.GetProto(tbox)[StrCast(tbox.layout_fieldKey)] = template;
}
return tbox;
}
@@ -1840,9 +1815,21 @@ export namespace DocUtils {
});
}
+ /**
+ * uploadFilesToDocs will take in an array of Files, and creates documents for the
+ * new files.
+ *
+ * @param files an array of files that will be uploaded
+ * @param options options to use while uploading
+ * @returns
+ */
export async function uploadFilesToDocs(files: File[], options: DocumentOptions) {
const generatedDocuments: Doc[] = [];
- const upfiles = await Networking.UploadFilesToServer(files);
+
+ // These files do not have overwriteDocs, so we do not set the guid and let the client generate one.
+ const fileNoGuidPairs: Networking.FileGuidPair[] = files.map(file => ({ file }));
+
+ const upfiles = await Networking.UploadFilesToServer(fileNoGuidPairs);
for (const {
source: { name, type },
result,
@@ -1854,7 +1841,8 @@ export namespace DocUtils {
export function uploadFileToDoc(file: File, options: DocumentOptions, overwriteDoc: Doc) {
const generatedDocuments: Doc[] = [];
- Networking.UploadFilesToServer([file]).then(upfiles => {
+ // Since this file has an overwriteDoc, we can set the client tracking guid to the overwriteDoc's guid.
+ Networking.UploadFilesToServer([{ file, guid: overwriteDoc[Id] }]).then(upfiles => {
const {
source: { name, type },
result,
@@ -1872,10 +1860,10 @@ export namespace DocUtils {
export function copyDragFactory(dragFactory: Doc) {
if (!dragFactory) return undefined;
const ndoc = dragFactory.isTemplateDoc ? Doc.ApplyTemplate(dragFactory) : Doc.MakeCopy(dragFactory, true);
- ndoc && Doc.AddDocToList(Doc.MyFileOrphans, 'data', Doc.GetProto(ndoc));
- if (ndoc && dragFactory['dragFactory-count'] !== undefined) {
- dragFactory['dragFactory-count'] = NumCast(dragFactory['dragFactory-count']) + 1;
- Doc.SetInPlace(ndoc, 'title', ndoc.title + ' ' + NumCast(dragFactory['dragFactory-count']).toString(), true);
+ ndoc && Doc.AddFileOrphan(Doc.GetProto(ndoc));
+ if (ndoc && dragFactory['dragFactory_count'] !== undefined) {
+ dragFactory['dragFactory_count'] = NumCast(dragFactory['dragFactory_count']) + 1;
+ Doc.SetInPlace(ndoc, 'title', ndoc.title + ' ' + NumCast(dragFactory['dragFactory_count']).toString(), true);
}
if (ndoc && Doc.ActiveDashboard) inheritParentAcls(Doc.ActiveDashboard, ndoc);
@@ -1884,31 +1872,25 @@ export namespace DocUtils {
}
export function delegateDragFactory(dragFactory: Doc) {
const ndoc = Doc.MakeDelegateWithProto(dragFactory);
- if (ndoc && dragFactory['dragFactory-count'] !== undefined) {
- dragFactory['dragFactory-count'] = NumCast(dragFactory['dragFactory-count']) + 1;
- Doc.GetProto(ndoc).title = ndoc.title + ' ' + NumCast(dragFactory['dragFactory-count']).toString();
+ if (ndoc && dragFactory['dragFactory_count'] !== undefined) {
+ dragFactory['dragFactory_count'] = NumCast(dragFactory['dragFactory_count']) + 1;
+ Doc.GetProto(ndoc).title = ndoc.title + ' ' + NumCast(dragFactory['dragFactory_count']).toString();
}
return ndoc;
}
}
ScriptingGlobals.add('Docs', Docs);
-ScriptingGlobals.add(function copyDragFactory(dragFactory: Doc) {
- return DocUtils.copyDragFactory(dragFactory);
-});
-ScriptingGlobals.add(function delegateDragFactory(dragFactory: Doc) {
- return DocUtils.delegateDragFactory(dragFactory);
+ScriptingGlobals.add(function copyDragFactory(dragFactory: Doc, asDelegate?: boolean) {
+ return dragFactory instanceof Doc ? (asDelegate ? DocUtils.delegateDragFactory(dragFactory) : DocUtils.copyDragFactory(dragFactory)) : dragFactory;
});
ScriptingGlobals.add(function makeDelegate(proto: any) {
const d = Docs.Create.DelegateDocument(proto, { title: 'child of ' + proto.title });
return d;
});
ScriptingGlobals.add(function generateLinkTitle(self: Doc) {
- const anchor1title = self.anchor1 && self.anchor1 !== self ? Cast(self.anchor1, Doc, null)?.title : '<?>';
- const anchor2title = self.anchor2 && self.anchor2 !== self ? Cast(self.anchor2, Doc, null)?.title : '<?>';
- const relation = self.linkRelationship || 'to';
- return `${anchor1title} (${relation}) ${anchor2title}`;
-});
-ScriptingGlobals.add(function openTabAlias(tab: Doc) {
- CollectionDockingView.AddSplit(Doc.MakeAlias(tab), 'right');
+ const link_anchor_1title = self.link_anchor_1 && self.link_anchor_1 !== self ? Cast(self.link_anchor_1, Doc, null)?.title : '<?>';
+ const link_anchor_2title = self.link_anchor_2 && self.link_anchor_2 !== self ? Cast(self.link_anchor_2, Doc, null)?.title : '<?>';
+ const relation = self.link_relationship || 'to';
+ return `${link_anchor_1title} (${relation}) ${link_anchor_2title}`;
});