aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorSophie Zhang <sophie_zhang@brown.edu>2024-02-22 10:22:58 -0500
committerSophie Zhang <sophie_zhang@brown.edu>2024-02-22 10:22:58 -0500
commit3f33a680af31a04b58c6163fda53a80a737837c6 (patch)
treeb84da40da1c13c8ab8ab8cd763b69ac5b39ce93c /src/client/documents/Documents.ts
parent70cf5ad795055c1f628c918b08a13a96e4ab89a6 (diff)
parentcf85ee4ea73985529a16321d671d893ddb862439 (diff)
Merge branch 'master' into sophie-ai-images
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts81
1 files changed, 68 insertions, 13 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index a0870ba43..2d2f5fe4a 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -59,6 +59,7 @@ import { WebBox } from '../views/nodes/WebBox';
import { SearchBox } from '../views/search/SearchBox';
import { CollectionViewType, DocumentType } from './DocumentTypes';
import { CalendarBox } from '../views/nodes/calendarBox/CalendarBox';
+import { OpenWhere } from '../views/nodes/DocumentView';
const { default: { DFLT_IMAGE_NATIVE_DIM } } = require('../views/global/globalCssVariables.module.scss'); // prettier-ignore
const defaultNativeImageDim = Number(DFLT_IMAGE_NATIVE_DIM.replace('px', ''));
@@ -80,6 +81,7 @@ export class FInfo {
this.description = d;
this.readOnly = readOnly ?? false;
}
+ searchable = () => true;
}
class BoolInfo extends FInfo {
fieldType? = 'boolean';
@@ -88,6 +90,7 @@ class BoolInfo extends FInfo {
super(d);
this.filterable = filterable;
}
+ override searchable = () => false;
}
class NumInfo extends FInfo {
fieldType? = 'number';
@@ -97,6 +100,7 @@ class NumInfo extends FInfo {
this.values = values;
this.filterable = filterable;
}
+ override searchable = () => false;
}
class StrInfo extends FInfo {
fieldType? = 'string';
@@ -115,34 +119,40 @@ class DocInfo extends FInfo {
this.values = values;
this.filterable = filterable;
}
+ override searchable = () => false;
}
class DimInfo extends FInfo {
fieldType? = 'enumeration';
values? = [DimUnit.Pixel, DimUnit.Ratio];
readOnly = false;
filterable = false;
+ override searchable = () => false;
}
class PEInfo extends FInfo {
fieldType? = 'enumeration';
values? = ['all', 'none'];
readOnly = false;
filterable = false;
+ override searchable = () => false;
}
class DAInfo extends FInfo {
fieldType? = 'enumeration';
values? = ['embed', 'copy', 'move', 'same', 'proto', 'none'];
readOnly = false;
filterable = false;
+ override searchable = () => false;
}
class CTypeInfo extends FInfo {
fieldType? = 'enumeration';
values? = Array.from(Object.keys(CollectionViewType));
readOnly = false;
filterable = false;
+ override searchable = () => false;
}
class DTypeInfo extends FInfo {
fieldType? = 'enumeration';
values? = Array.from(Object.keys(DocumentType));
+ override searchable = () => false;
}
class DateInfo extends FInfo {
fieldType? = 'date';
@@ -210,7 +220,7 @@ 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 discument', 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);
@@ -242,6 +252,7 @@ export class DocumentOptions {
layout_hideDecorationTitle?: BOOLt = new BoolInfo('whether to suppress the document decortations title when selected');
_layout_hideContextMenu?: BOOLt = new BoolInfo('whether the context menu can be shown');
layout_borderRounding?: string;
+ _layout_modificationDate?: DATEt = new DateInfo('last modification date of doc layout', false);
_layout_nativeDimEditable?: BOOLt = new BoolInfo('native dimensions can be modified using document decoration reizers', false);
_layout_reflowVertical?: BOOLt = new BoolInfo('native height can be changed independent of width by dragging decoration resizers');
_layout_reflowHorizontal?: BOOLt = new BoolInfo('whether a doc with a native size can be horizonally resized, causing some form of reflow');
@@ -407,7 +418,7 @@ export class DocumentOptions {
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
onClickScriptDisable?: STRt = new StrInfo('"always" disable click script, "never" disable click script, or default');
- defaultDoubleClick?: 'ignore' | 'default'; // ignore double clicks, or deafult (undefined) means open document full screen
+ defaultDoubleClick?: 'ignore' | 'default'; // ignore double clicks, or default (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;
@@ -427,7 +438,7 @@ export class DocumentOptions {
clickFactory?: DOCt = new DocInfo('document to create when clicking on a button with a suitable onClick script', false);
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
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)
-
+ tags?: LISTt = new ListInfo('hashtags added to document, typically using a text view', true);
treeView_HideTitle?: BOOLt = new BoolInfo('whether to hide the top document title of a tree view');
treeView_HideUnrendered?: BOOLt = new BoolInfo("tells tree view not to display documents that have an 'layout_unrendered' tag unless they also have a treeView_FieldKey tag (presBox)");
treeView_HideHeaderIfTemplate?: BOOLt = new BoolInfo('whether to hide the header for a document in a tree view only if a childLayoutTemplate is provided (presBox)');
@@ -584,13 +595,12 @@ export namespace Docs {
layout: { view: LinkBox, dataField: 'link' },
options: {
childDontRegisterViews: true,
- onClick: FollowLinkScript(),
layout_hideLinkAnchors: true,
_height: 1,
_width: 1,
link: '',
link_description: '',
- backgroundColor: 'lightblue', // lightblue is default color for linking dot and link documents text comment area
+ color: 'lightBlue', // lightblue is default color for linking dot and link documents text comment area
_dropPropertiesToRemove: new List(['onClick']),
},
},
@@ -1102,7 +1112,7 @@ export namespace Docs {
I.stroke_isInkMask = isInkMask;
I.text_align = 'center';
I.rotation = 0;
- I.defaultDoubleClick = 'click';
+ I.defaultDoubleClick = 'ignore';
I.author_date = new DateField();
I['acl-Guest'] = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View;
//I['acl-Override'] = SharingPermissions.Unset;
@@ -1449,7 +1459,7 @@ export namespace DocUtils {
const makeLink = action((linkDoc: Doc, showPopup?: number[]) => {
if (showPopup) {
- LinkManager.currentLink = linkDoc;
+ LinkManager.Instance.currentLink = linkDoc;
TaskCompletionBox.textDisplayed = 'Link Created';
TaskCompletionBox.popupX = showPopup[0];
@@ -1657,10 +1667,37 @@ export namespace DocUtils {
}
export function addDocumentCreatorMenuItems(docTextAdder: (d: Doc) => void, docAdder: (d: Doc) => void, x: number, y: number, simpleMenu: boolean = false, pivotField?: string, pivotValue?: string): void {
+ 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 && doc.title)
+ .map((dragDoc, i) => ({
+ description: ':' + StrCast(dragDoc.title).replace('Untitled ', ''),
+ event: undoable((args: { x: number; y: number }) => {
+ const newDoc = DocUtils.copyDragFactory(dragDoc);
+ if (newDoc) {
+ newDoc.author = Doc.CurrentUserEmail;
+ newDoc.x = x;
+ newDoc.y = y;
+ EquationBox.SelectOnLoad = newDoc[Id];
+ if (newDoc.type === DocumentType.RTF) FormattedTextBox.SetSelectOnLoad(newDoc);
+ if (pivotField) {
+ newDoc[pivotField] = pivotValue;
+ }
+ docAdder?.(newDoc);
+ }
+ }, StrCast(dragDoc.title)),
+ icon: Doc.toIcon(dragDoc),
+ })) as ContextMenuProps[];
+ ContextMenu.Instance.addItem({
+ description: 'Create document',
+ subitems: documentList,
+ icon: 'file',
+ });
!simpleMenu &&
ContextMenu.Instance.addItem({
- description: 'Quick Notes',
- subitems: DocListCast((Doc.UserDoc()['template_notes'] as Doc).data).map((note, i) => ({
+ description: 'Styled Notes',
+ subitems: DocListCast((Doc.UserDoc().template_notes as Doc).data).map((note, i) => ({
description: ':' + StrCast(note.title),
event: undoable((args: { x: number; y: number }) => {
const textDoc = Docs.Create.TextDocument('', {
@@ -1681,14 +1718,14 @@ export namespace DocUtils {
})) as ContextMenuProps[],
icon: 'sticky-note',
});
- const documentList: ContextMenuProps[] = DocListCast(DocListCast(Doc.MyTools?.data)[0]?.data)
+ const userDocList: ContextMenuProps[] = DocListCast(DocListCast(Doc.MyTools?.data)[1]?.data)
.filter(btnDoc => !btnDoc.hidden)
.map(btnDoc => Cast(btnDoc?.dragFactory, Doc, null))
.filter(doc => doc && doc !== Doc.UserDoc().emptyTrail && doc !== Doc.UserDoc().emptyNote && doc.title)
.map((dragDoc, i) => ({
description: ':' + StrCast(dragDoc.title).replace('Untitled ', ''),
event: undoable((args: { x: number; y: number }) => {
- const newDoc = DocUtils.copyDragFactory(dragDoc);
+ const newDoc = DocUtils.delegateDragFactory(dragDoc);
if (newDoc) {
newDoc.author = Doc.CurrentUserEmail;
newDoc.x = x;
@@ -1704,8 +1741,8 @@ export namespace DocUtils {
icon: Doc.toIcon(dragDoc),
})) as ContextMenuProps[];
ContextMenu.Instance.addItem({
- description: 'Create document',
- subitems: documentList,
+ description: 'User Templates',
+ subitems: userDocList,
icon: 'file',
});
} // applies a custom template to a document. the template is identified by it's short name (e.g, slideView not layout_slideView)
@@ -1796,6 +1833,24 @@ export namespace DocUtils {
return newCollection;
}
}
+ export function makeIntoPortal(doc: Doc, layoutDoc: Doc, allLinks: Doc[]) {
+ const portalLink = allLinks.find(d => d.link_anchor_1 === doc && d.link_relationship === 'portal to:portal from');
+ if (!portalLink) {
+ DocUtils.MakeLink(
+ doc,
+ Docs.Create.FreeformDocument([], {
+ _width: NumCast(layoutDoc._width) + 10,
+ _height: Math.max(NumCast(layoutDoc._height), NumCast(layoutDoc._width) + 10),
+ _isLightbox: true,
+ _layout_fitWidth: true,
+ title: StrCast(doc.title) + ' [Portal]',
+ }),
+ { link_relationship: 'portal to:portal from' }
+ );
+ }
+ doc.followLinkLocation = OpenWhere.lightbox;
+ doc.onClick = FollowLinkScript();
+ }
export function LeavePushpin(doc: Doc, annotationField: string) {
if (doc.followLinkToggle) return undefined;