aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2022-10-28 10:10:04 -0400
committerbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2022-10-28 10:10:04 -0400
commitceb338752aacc383c97a0e3a9b608365a1cf39b6 (patch)
treed2f355b726a9b21950f332c0f65931d7d6eef515 /src/client/documents/Documents.ts
parent5d6a0458b9d4f35e0c568a4d76d4fcab4e22f698 (diff)
parent2fc88a931cb2fc3408297b000208990633445585 (diff)
merge
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 57a24b304..bbb896d6e 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -169,6 +169,7 @@ export class DocumentOptions {
_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
@@ -334,7 +335,6 @@ export class DocumentOptions {
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.
- treeViewGrowsHorizontally?: boolean; // whether an embedded tree view of the document can grow horizontally without growing vertically
treeViewChildDoubleClick?: ScriptField; //
// Action Button
buttonMenu?: boolean; // whether a action button should be displayed
@@ -394,7 +394,7 @@ export namespace Docs {
_xMargin: 10,
_yMargin: 10,
nativeDimModifiable: true,
- treeViewGrowsHorizontally: true,
+ nativeHeightUnfrozen: true,
forceReflow: true,
links: '@links(self)',
},
@@ -568,7 +568,7 @@ export namespace Docs {
DocumentType.SLIDER,
{
layout: { view: SliderBox, dataField: defaultDataKey },
- options: { links: '@links(self)', treeViewGrowsHorizontally: true },
+ options: { links: '@links(self)' },
},
],
[
@@ -596,6 +596,7 @@ export namespace Docs {
DocumentType.PRESELEMENT,
{
layout: { view: PresElementBox, dataField: defaultDataKey },
+ options: { title: 'pres element template', _fitWidth: true, _xMargin: 0, isTemplateDoc: true, isTemplateForField: 'data' },
},
],
[
@@ -906,7 +907,7 @@ export namespace Docs {
export function ColorDocument(options: DocumentOptions = {}) {
return InstanceFromProto(Prototypes.get(DocumentType.COLOR), '', options);
}
- export function LoadingDocument(file: File | string, options: DocumentOptions, ytString?: string) {
+ export function LoadingDocument(file: File | string, options: DocumentOptions) {
return InstanceFromProto(Prototypes.get(DocumentType.LOADING), undefined, { _height: 150, _width: 200, title: typeof file == 'string' ? file : file.name, ...options }, undefined, '');
}
@@ -981,6 +982,7 @@ export namespace Docs {
I.strokeEndMarker = arrowEnd;
I.strokeDash = dash;
I.tool = tool;
+ I.fitWidth = true;
I['text-align'] = 'center';
I.title = 'ink';
I.x = options.x as number;
@@ -1132,8 +1134,8 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.FILTER), undefined, { ...(options || {}) });
}
- export function PresElementBoxDocument(options?: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.PRESELEMENT), undefined, { ...(options || {}) });
+ export function PresElementBoxDocument() {
+ return Prototypes.get(DocumentType.PRESELEMENT);
}
export function DataVizDocument(url: string, options?: DocumentOptions, overwriteDoc?: Doc) {
@@ -1141,7 +1143,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, dockingConfig: config }, id);
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { freezeChildren: 'remove|add', ...options, viewType: CollectionViewType.Docking, _viewType: CollectionViewType.Docking, dockingConfig: config }, id);
}
export function DirectoryImportDocument(options: DocumentOptions = {}) {
@@ -1305,7 +1307,7 @@ export namespace DocUtils {
});
}
- export function DefaultFocus(doc: Doc, options?: DocFocusOptions) {
+ export function DefaultFocus(doc: Doc, options: DocFocusOptions) {
options?.afterFocus?.(false);
}
@@ -1396,14 +1398,17 @@ export namespace DocUtils {
heading: Doc.name,
checked: 'boolean',
containingTreeView: Doc.name,
+ altKey: 'boolean',
+ ctrlKey: 'boolean',
+ shiftKey: 'boolean',
});
}
});
funcs &&
Object.keys(funcs).map(key => {
const cfield = ComputedField.WithoutComputed(() => FieldValue(doc[key]));
- if (ScriptCast(cfield)?.script.originalScript !== funcs[key] && funcs[key]) {
- doc[key] = ComputedField.MakeFunction(funcs[key], { dragData: DragManager.DocumentDragData.name }, { _readOnly_: true });
+ if (ScriptCast(cfield)?.script.originalScript !== funcs[key]) {
+ doc[key] = funcs[key] ? ComputedField.MakeFunction(funcs[key], { dragData: DragManager.DocumentDragData.name }, { _readOnly_: true }) : undefined;
}
});
return doc;
@@ -1563,7 +1568,7 @@ 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().emptyPresentation)
+ .filter(doc => doc && doc !== Doc.UserDoc().emptyTrail)
.map((dragDoc, i) => ({
description: ':' + StrCast(dragDoc.title).replace('Untitled ', ''),
event: undoBatch((args: { x: number; y: number }) => {
@@ -1756,7 +1761,6 @@ export namespace DocUtils {
const full = { ...options, _width: 400, title: name };
const pathname = Utils.prepend(result.accessPaths.agnostic.client);
const doc = await DocUtils.DocumentFromType(type, pathname, full, rootDoc);
- rootDoc && (rootDoc.isLoading = undefined);
if (doc) {
const proto = Doc.GetProto(doc);
proto.text = result.rawText;
@@ -1788,6 +1792,9 @@ export namespace DocUtils {
if (Upload.isVideoInformation(result)) {
proto['data-duration'] = result.duration;
}
+ if (rootDoc) {
+ Doc.removeCurrentlyLoading(rootDoc);
+ }
generatedDocuments.push(doc);
}
}
@@ -1816,17 +1823,6 @@ export namespace DocUtils {
return tbox;
}
- export async function uploadYoutubeVideo(videoId: string, options: DocumentOptions) {
- const generatedDocuments: Doc[] = [];
- for (const {
- source: { name, type },
- result,
- } of await Networking.UploadYoutubeToServer(videoId)) {
- name && processFileupload(generatedDocuments, name, type, result, options);
- }
- return generatedDocuments;
- }
-
export function uploadYoutubeVideoLoading(videoId: string, options: DocumentOptions, overwriteDoc?: Doc) {
const generatedDocuments: Doc[] = [];
Networking.UploadYoutubeToServer(videoId).then(upfiles => {
@@ -1837,7 +1833,8 @@ export namespace DocUtils {
if ((result as any).message) {
if (overwriteDoc) {
overwriteDoc.isLoading = false;
- overwriteDoc.errorMessage = (result as any).message;
+ overwriteDoc.loadingError = (result as any).message;
+ Doc.removeCurrentlyLoading(overwriteDoc);
}
} else name && processFileupload(generatedDocuments, name, type, result, options, overwriteDoc);
});
@@ -1861,11 +1858,11 @@ export namespace DocUtils {
const {
source: { name, type },
result,
- } = upfiles.lastElement();
+ } = upfiles.lastElement() ?? { source: { name: '', type: '' }, result: { message: 'upload failed' } };
if ((result as any).message) {
if (overwriteDoc) {
- overwriteDoc.isLoading = false;
- overwriteDoc.errorMessage = (result as any).message;
+ overwriteDoc.loadingError = (result as any).message;
+ Doc.removeCurrentlyLoading(overwriteDoc);
}
} else name && type && processFileupload(generatedDocuments, name, type, result, options, overwriteDoc);
});
@@ -1907,8 +1904,8 @@ ScriptingGlobals.add(function makeDelegate(proto: any) {
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 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}`;
});