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.ts71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 668725d2b..0e3c614fe 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -4,7 +4,7 @@ import { basename } from 'path';
import { ClientUtils, OmitKeys } from '../../ClientUtils';
import { DateField } from '../../fields/DateField';
import { CreateLinkToActiveAudio, Doc, FieldType, Opt, updateCachedAcls } from '../../fields/Doc';
-import { Initializing } from '../../fields/DocSymbols';
+import { Id } from '../../fields/FieldSymbols';
import { HtmlField } from '../../fields/HtmlField';
import { InkField } from '../../fields/InkField';
import { List } from '../../fields/List';
@@ -18,7 +18,6 @@ import { PointData } from '../../pen-gestures/GestureTypes';
import { DocServer } from '../DocServer';
import { dropActionType } from '../util/DropActionTypes';
import { CollectionViewType, DocumentType } from './DocumentTypes';
-import { Id } from '../../fields/FieldSymbols';
class EmptyBox {
public static LayoutString() {
@@ -43,7 +42,6 @@ export class FInfo {
readOnly: boolean = false;
fieldType?: FInfoFieldType;
values?: FieldType[];
- onLayout?: boolean;
filterable?: boolean = true; // can be used as a Filter in FilterPanel
// format?: string; // format to display values (e.g, decimal places, $, etc)
// parse?: ScriptField; // parse a value from a string
@@ -156,12 +154,16 @@ type DROPt = DAInfo | dropActionType;
type DATEt = DateInfo | number;
type DTYPEt = DTypeInfo | string;
export class DocumentOptions {
+ [key: string]: FInfo | FieldType | undefined;
// coordinate and dimensions depending on view
x?: NUMt = new NumInfo('horizontal coordinate in freeform view', false);
y?: NUMt = new NumInfo('vertical coordinate in freeform view', false);
z?: NUMt = new NumInfo('whether document is in overlay (1) or not (0)', false, false, [1, 0]);
+ zIndex?: NUMt = new NumInfo('stacking index of documents in freeform view (higher numbers are towards the top');
overlayX?: NUMt = new NumInfo('horizontal coordinate in overlay view', false);
overlayY?: NUMt = new NumInfo('vertical coordinate in overlay view', false);
+ embedContainer?: DOCt = new DocInfo('document that displays (contains) this document', false);
+
text?: RTFt = new RtfInfo('plain or rich text', true);
text_html?: STRt = new StrInfo('plain text or html', true);
_dimMagnitude?: NUMt = new NumInfo("magnitude of collectionMulti{row,col} element's width or height", false);
@@ -215,11 +217,11 @@ export class DocumentOptions {
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', false);
- _embedContainer?: DOCt = new DocInfo('document that displays (contains) this document', false);
rootDocument?: DOCt = new DocInfo('document that supplies the information needed for a rendering template (eg, pres slide for PresElement)');
color?: STRt = new StrInfo('foreground color data doc', false);
hidden?: BOOLt = new BoolInfo('whether the document is not rendered by its collection', false);
backgroundColor?: STRt = new StrInfo('background color for data doc', false);
+ _override_backgroundColor?: BOOLt = new BoolInfo("whether the layout template overrides the data doc's background color");
opacity?: NUMt = new NumInfo('document opacity', false);
viewTransitionTime?: NUMt = new NumInfo('transition duration for view parameters', false);
dontRegisterView?: BOOLt = new BoolInfo('are views of this document registered so that they can be found when following links, etc', false);
@@ -281,7 +283,6 @@ export class DocumentOptions {
_layout_autoHeightMargins?: NUMt = new NumInfo('Margin heights to be added to the computed auto height of a Doc');
_layout_curPage?: NUMt = new NumInfo('current page of a PDF or other? paginated document', false);
_layout_currentTimecode?: NUMt = new NumInfo('the current timecode of a time-based document (e.g., current time of a video) value is in seconds', false);
- _layout_centered?: BOOLt = new BoolInfo('whether text should be vertically centered in Doc');
_layout_fitWidth?: BOOLt = new BoolInfo('whether document should scale its contents to fit its rendered width or not (e.g., for PDFviews)');
_layout_fieldKey?: STRt = new StrInfo('the field key containing the current layout definition', false);
_layout_enableAltContentUI?: BOOLt = new BoolInfo('whether to show alternate content button');
@@ -307,6 +308,7 @@ export class DocumentOptions {
text_fontSize?: string;
text_fontFamily?: string;
text_fontWeight?: string;
+ text_centered?: BOOLt = new BoolInfo('whether text should be vertically centered in Doc');
text_fitBox?: BOOLt = new BoolInfo("whether text box should be scaled to fit it's containing render box");
text_align?: STRt = new StrInfo('horizontal text alignment default', undefined, undefined, ['left', 'center', 'right']);
title_align?: STRt = new StrInfo('horizontal title alignment in label box', undefined, undefined, ['left', 'center', 'right']);
@@ -366,7 +368,7 @@ export class DocumentOptions {
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');
+ 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');
cloneOnCopy?: BOOLt = new BoolInfo('if this Doc is a field of another Doc, then it should be copied when the other Doc is copied');
mapPin?: DOCt = new DocInfo('pin associated with a config anchor', false);
@@ -686,10 +688,11 @@ export namespace Docs {
layout: layout.view?.LayoutString(layout.dataField),
};
Object.entries(options)
- .filter(pair => typeof pair[1] === 'string' && pair[1].startsWith('@'))
- .forEach(pair => {
- if (!existing || ScriptCast(existing[pair[0]])?.script.originalScript !== pair[1].substring(1)) {
- (options as { [key: string]: unknown })[pair[0]] = ComputedField.MakeFunction(pair[1].substring(1));
+ .filter(([, val]) => (val as string)?.startsWith?.('@'))
+ .map(([key, val]) => [key, val as string])
+ .forEach(([key, val]) => {
+ if (!existing || ScriptCast(existing[key])?.script.originalScript !== val.substring(1)) {
+ options[key] = ComputedField.MakeFunction(val.substring(1));
}
});
return Doc.assign(existing ?? new Doc(prototypeId, true), OmitKeys(options, Object.keys(existing ?? {})).omit as { [key: string]: FieldType }, undefined, true);
@@ -722,7 +725,7 @@ export namespace Docs {
*/
function InstanceFromProto(proto: Doc, data: FieldType | undefined, options: DocumentOptions, delegId?: string, fieldKey: string = 'data', protoId?: string, placeholderDocIn?: Doc, noView?: boolean) {
const placeholderDoc = placeholderDocIn;
- const viewKeys = ['x', 'y', 'isSystem']; // keys that should be addded to the view document even though they don't begin with an "_"
+ const viewKeys = ['x', 'y', 'isSystem', 'overlayX', 'overlayY', 'zIndex', 'embedContainer']; // 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, '^_') as { omit: { [key: string]: FieldType | undefined }; extract: { [key: string]: FieldType | undefined } };
// dataProps.acl_Override = SharingPermissions.Unset;
@@ -837,7 +840,7 @@ export namespace Docs {
return TextDocument(RichTextField.textToRtf(text, img?.[Id]), {
title, //
_layout_autoHeight: true,
- _layout_centered: true,
+ text_centered: true,
text_align: 'center',
_layout_fitWidth: true,
...opts,
@@ -947,9 +950,9 @@ export namespace Docs {
return InstanceFromProto(
Prototypes.get(DocumentType.JOURNAL),
- "",
+ '',
{
- title: "",
+ title: '',
...options,
},
undefined,
@@ -979,26 +982,22 @@ export namespace Docs {
export function InkDocument(points: PointData[], options: DocumentOptions = {}, strokeWidth: number, color: string, strokeBezier: string, fillColor: string, arrowStart: string, arrowEnd: string, dash: string, isInkMask: boolean) {
const ink = InstanceFromProto(Prototypes.get(DocumentType.INK), '', { title: 'ink', ...options });
- const I = Doc.GetProto(ink);
- // I.layout_hideOpenButton = true; // don't show open full screen button when selected
- I.color = color;
- I.fillColor = fillColor && fillColor !== 'transparent' ? fillColor : undefined;
- I.stroke = new InkField(points);
- I.stroke_width = strokeWidth;
- I.stroke_bezier = strokeBezier;
- I.stroke_startMarker = arrowStart;
- I.stroke_endMarker = arrowEnd;
- I.stroke_dash = dash;
- I.stroke_isInkMask = isInkMask;
- I.text_align = 'center';
- I.rotation = 0;
- I.width_min = 1;
- I.height_min = 1;
- I.defaultDoubleClick = 'ignore';
- I.author_date = new DateField();
- I.acl_Guest = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View;
- // I.acl_Override = SharingPermissions.Unset;
- I[Initializing] = false;
+ ink.$color = color;
+ ink.$fillColor = fillColor && fillColor !== 'transparent' ? fillColor : undefined;
+ ink.$stroke = new InkField(points);
+ ink.$stroke_width = strokeWidth;
+ ink.$stroke_bezier = strokeBezier;
+ ink.$stroke_startMarker = arrowStart;
+ ink.$stroke_endMarker = arrowEnd;
+ ink.$stroke_dash = dash;
+ ink.$stroke_isInkMask = isInkMask;
+ ink.$text_align = 'center';
+ ink.$rotation = 0;
+ ink.$width_min = 1;
+ ink.$height_min = 1;
+ ink.$defaultDoubleClick = 'ignore';
+ ink.$author_date = new DateField();
+ ink.$acl_Guest = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View;
return ink;
}
@@ -1073,10 +1072,6 @@ export namespace Docs {
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, _type_collection: CollectionViewType.Map });
- }
-
export function CarouselDocument(documents: Array<Doc>, options: DocumentOptions) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Carousel });
}