aboutsummaryrefslogtreecommitdiff
path: root/src/fields/documentSchemas.ts
blob: b27816f55548b05642b6bf31395f448d4e81318a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { DateField } from './DateField';
import { Doc } from './Doc';
import { createSchema, listSpec, makeInterface } from './Schema';
import { ScriptField } from './ScriptField';

export const documentSchema = createSchema({
    // content properties
    type: 'string', // enumerated type of document -- should be template-specific (ie, start with an '_')
    title: 'string', // document title (can be on either data document or layout)
    isTemplateForField: 'string', // if specified, it indicates the document is a template that renders the specified field
    author_date: DateField, // when the document was created
    links: listSpec(Doc), // computed (readonly) list of links associated with this document

    // "Location" properties in a very general sense
    _layout_curPage: 'number', // current page of a page based document
    _currentFrame: 'number', // current frame of a frame based collection (e.g., a progressive slide)
    lastFrame: 'number', // last frame of a frame based collection (e.g., a progressive slide)
    activeFrame: 'number', // the active frame of a frame based animated document
    _layout_currentTimecode: 'number', // current play back time of a temporal document (video / audio)
    _timecodeToShow: 'number', // the time that a document should be displayed (e.g., time an annotation should be displayed on a video)
    _timecodeToHIde: 'number', // the time that a document should be hidden
    markers: listSpec(Doc), // list of markers for audio / video
    x: 'number', // x coordinate when in a freeform view
    y: 'number', // y coordinate when in a freeform view
    z: 'number', // z "coordinate" - non-zero specifies the overlay layer of a freeformview
    zIndex: 'number', // zIndex of a document in a freeform view
    _layout_scrollTop: 'number', // scroll position of a scrollable document (pdf, text, web)
    latitude: 'number',
    longitude: 'number',

    // appearance properties on the layout
    '_backgroundGrid-spacing': 'number', // the size of the grid for collection views
    _layout_autoHeight: 'boolean', // whether the height of the document should be computed automatically based on its contents
    _nativeWidth: 'number', // native width of document which determines how much document contents are scaled when the document's width is set
    _nativeHeight: 'number', // "
    _width: 'number', // width of document in its container's coordinate system
    _height: 'number', // "
    _xPadding: 'number', // pixels of padding on left/right of collectionfreeformview contents when freeform_fitContentsToBox is set
    _yPadding: 'number', // pixels of padding on top/bottom of collectionfreeformview contents when freeform_fitContentsToBox is set
    _xMargin: 'number', // margin added on left/right of most documents to add separation from their container
    _yMargin: 'number', // margin added on top/bottom of most documents to add separation from their container
    _overflow: 'string', // sets overflow behvavior for CollectionFreeForm views
    _layout_showCaption: 'string', // whether editable caption text is overlayed at the bottom of the document
    _layout_showTitle: 'string', // the fieldkey(s) whose contents should be displayed at the top of the document. separate multiple keys with ";".  Use :hover suffix to indicate title should be shown on hover
    _pivotField: 'string', // specifies which field key should be used as the timeline/pivot axis
    _columnsFill: 'boolean', // whether documents in a stacking view column should be sized to fill the column
    _columnsSort: 'string', // how a document should be sorted "ascending", "descending", undefined (none)
    _columnsHideIfEmpty: 'boolean', // whether empty stacking view column headings should be hidden
    // _columnHeaders: listSpec(SchemaHeaderField), // header descriptions for stacking/masonry
    // _schemaHeaders: listSpec(SchemaHeaderField), // header descriptions for schema views
    text_fontSize: 'string',
    text_fontFamily: 'string',
    _layout_sidebarWidthPercent: 'string', // percent of text window width taken up by sidebar

    // appearance properties on the data document
    backgroundColor: 'string', // background color of document
    layout_borderRounding: 'string', // border radius rounding of document
    layout_boxShadow: 'string', // the amount of shadow around the perimeter of a document
    color: 'string', // foreground color of document
    freeform_fitContentsToBox: 'boolean', // whether freeform view contents should be zoomed/panned to fill the area of the document view box
    fontSize: 'string',
    hidden: 'boolean', // whether a document should not be displayed
    stroke_isInkMask: 'boolean', // is the document a mask (ie, sits on top of other documents, has an unbounded width/height that is dark, and content uses 'hard-light' mix-blend-mode to let other documents pop through)
    layout: 'string', // this is the native layout string for the document.  templates can be added using other fields and setting layout_fieldKey below
    layout_fieldKey: 'string', // holds the field key for the field that actually holds the current lyoat
    letterSpacing: 'string',
    opacity: 'number', // opacity of document
    stroke_width: 'number',
    stroke_bezier: 'number',
    stroke_startMarker: 'string',
    stroke_endMarker: 'string',
    stroke_dash: 'string',
    text_transform: 'string',
    treeView_Open: 'boolean', //  flag denoting whether the documents sub-tree (contents) is visible or hidden
    treeView_ExpandedView: 'string', // name of field whose contents are being displayed as the document's subtree
    treeView_ExpandedViewLock: 'boolean', // whether the expanded view can be changed
    treeView_OpenIsTransient: 'boolean', // ignores the treeView_Open flag (for allowing a view to not be slaved to other views of the document)
    treeView_Type: 'string', // whether tree view is an outline, file syste or (default) hierarchy. For outline, clicks edit document titles immediately since double-click opening is turned off

    // interaction and linking properties
    ignoreClick: 'boolean', // whether documents ignores input clicks (but does not ignore manipulation and other events)
    onClick: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop)
    onPointerDown: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop)
    onPointerUp: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop)
    onDragStart: ScriptField, // script to run when document is dragged (without being selected).  the script should return the Doc to be dropped.
    followLinkLocation: 'string', // flag for where to place content when following a click interaction (e.g., add:right, lightbox, default, )
    hideLinkButton: 'boolean', // whether the blue link counter button should be hidden
    layout_hideAllLinks: 'boolean', // whether all individual blue anchor dots should be hidden
    isLightbox: 'boolean', // whether the marked object will display addDocTab() calls that target "lightbox" destinations
    layers: listSpec('string'), // which layers the document is part of
    _lockedPosition: 'boolean', // whether the document can be moved (dragged)
    _lockedTransform: 'boolean', // whether a freeformview can pan/zoom
    link_displayArrow: 'boolean', // toggles directed arrows

    // drag drop properties
    _dragOnlyWithinContainer: 'boolean', // whether document can be dropped into a different collection
    dragFactory: Doc, // the document that serves as the "template" for the onDragStart script.  ie, to drag out copies of the dragFactory document.
    dropAction: 'string', // override specifying what should happen when something is dropped on this document (dropActionType)
    dragAction: 'string', // override specifying what should happen when this document s dragged (dropActionType)
    childDragAction: 'string', // specify the override for what should happen when the child of a collection is dragged from it and dropped (dropActionType)
    dropPropertiesToRemove: listSpec('string'), // properties that should be removed from the embed/copy/etc of this document when it is dropped
});

export const collectionSchema = createSchema({
    childLayoutTemplate: Doc, // layout template to use to render children of a collecion
    childLayoutString: 'string', // layout string to use to render children of a collection
    childClickedOpenTemplateView: Doc, // layout template to apply to a child when its clicked on in a collection and opened (requires onChildClick or other script to read this value and apply template)
    childDontRegisterViews: 'boolean', // whether views made of this document are registered so that they can be found when drawing links
    onChildClick: ScriptField, // script to run for each child when its clicked
    onChildDoubleClick: ScriptField, // script to run for each child when its clicked
    onCheckedClick: ScriptField, // script to run when a checkbox is clicked next to a child in a tree view
});

export type Document = makeInterface<[typeof documentSchema]>;
export const Document = makeInterface(documentSchema);