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.ts47
1 files changed, 13 insertions, 34 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index f5f140ae9..e78686b3e 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -20,7 +20,6 @@ import { YoutubeBox } from '../apis/youtube/YoutubeBox';
import { DocServer } from '../DocServer';
import { Networking } from '../Network';
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';
@@ -30,10 +29,8 @@ import { DimUnit } from '../views/collections/collectionMulticolumn/CollectionMu
import { CollectionView } from '../views/collections/CollectionView';
import { ContextMenu } from '../views/ContextMenu';
import { ContextMenuProps } from '../views/ContextMenuItem';
-import { DFLT_IMAGE_NATIVE_DIM } from '../views/global/globalCssVariables.scss';
import { ActiveArrowEnd, ActiveArrowStart, ActiveDash, ActiveFillColor, ActiveInkBezierApprox, ActiveInkColor, ActiveInkWidth, ActiveIsInkMask, InkingStroke } from '../views/InkingStroke';
import { AudioBox, media_state } from '../views/nodes/AudioBox';
-import { ColorBox } from '../views/nodes/ColorBox';
import { ComparisonBox } from '../views/nodes/ComparisonBox';
import { DataVizBox } from '../views/nodes/DataVizBox/DataVizBox';
import { EquationBox } from '../views/nodes/EquationBox';
@@ -61,6 +58,9 @@ import { VideoBox } from '../views/nodes/VideoBox';
import { WebBox } from '../views/nodes/WebBox';
import { SearchBox } from '../views/search/SearchBox';
import { CollectionViewType, DocumentType } from './DocumentTypes';
+const {
+ default: { DFLT_IMAGE_NATIVE_DIM },
+} = require('../views/global/globalCssVariables.module.scss');
const defaultNativeImageDim = Number(DFLT_IMAGE_NATIVE_DIM.replace('px', ''));
class EmptyBox {
@@ -504,13 +504,6 @@ export namespace Docs {
},
],
[
- DocumentType.COLOR,
- {
- layout: { view: ColorBox, dataField: defaultDataKey },
- options: { _nativeWidth: 220, _nativeHeight: 300 },
- },
- ],
- [
DocumentType.IMG,
{
layout: { view: ImageBox, dataField: defaultDataKey },
@@ -584,13 +577,6 @@ export namespace Docs {
},
],
[
- DocumentType.IMPORT,
- {
- layout: { view: DirectoryImportBox, dataField: defaultDataKey },
- options: { _height: 150 },
- },
- ],
- [
DocumentType.LINK,
{
layout: { view: LinkBox, dataField: 'link' },
@@ -1033,9 +1019,6 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.SEARCH), new List<Doc>([]), options);
}
- export function ColorDocument(options: DocumentOptions = {}) {
- return InstanceFromProto(Prototypes.get(DocumentType.COLOR), '', options);
- }
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, '');
}
@@ -1274,10 +1257,6 @@ export namespace Docs {
return ret;
}
- export function DirectoryImportDocument(options: DocumentOptions = {}) {
- return InstanceFromProto(Prototypes.get(DocumentType.IMPORT), new List<Doc>(), options);
- }
-
export type DocConfig = {
doc: Doc;
initialWidth?: number;
@@ -1326,7 +1305,7 @@ export namespace DocUtils {
// links are not a field value, so handled here. value is an expression of form ([field=]idToDoc("..."))
const allLinks = LinkManager.Instance.getAllRelatedLinks(doc);
const matchLink = (value: string, anchor: Doc) => {
- const linkedToExp = value?.split('=');
+ const linkedToExp = (value ?? '').split('=');
if (linkedToExp.length === 1) return Field.toScriptString(anchor) === value;
return Field.toScriptString(DocCast(anchor[linkedToExp[0]])) === linkedToExp[1];
};
@@ -1664,7 +1643,7 @@ export namespace DocUtils {
options = { ...options, _width: 400, _height: 512, title: path };
}
- return ctor ? ctor(path, options, overwriteDoc) : undefined;
+ return ctor ? ctor(path, overwriteDoc ? { ...options, title: StrCast(overwriteDoc.title, path) } : options, overwriteDoc) : undefined;
}
export function addDocumentCreatorMenuItems(docTextAdder: (d: Doc) => void, docAdder: (d: Doc) => void, x: number, y: number, simpleMenu: boolean = false, pivotField?: string, pivotValue?: string): void {
@@ -1705,7 +1684,7 @@ export namespace DocUtils {
newDoc.x = x;
newDoc.y = y;
EquationBox.SelectOnLoad = newDoc[Id];
- if (newDoc.type === DocumentType.RTF) FormattedTextBox.SelectOnLoad = newDoc[Id];
+ if (newDoc.type === DocumentType.RTF) FormattedTextBox.SetSelectOnLoad(newDoc);
if (pivotField) {
newDoc[pivotField] = pivotValue;
}
@@ -1936,7 +1915,7 @@ export namespace DocUtils {
const generatedDocuments: Doc[] = [];
Networking.UploadYoutubeToServer(videoId, overwriteDoc?.[Id]).then(upfiles => {
const {
- source: { name, type },
+ source: { newFilename, originalFilename, mimetype },
result,
} = upfiles.lastElement();
if ((result as any).message) {
@@ -1945,7 +1924,7 @@ export namespace DocUtils {
overwriteDoc.loadingError = (result as any).message;
LoadingBox.removeCurrentlyLoading(overwriteDoc);
}
- } else name && processFileupload(generatedDocuments, name, type, result, options, overwriteDoc);
+ } else newFilename && processFileupload(generatedDocuments, newFilename, mimetype ?? '', result, options, overwriteDoc);
});
}
@@ -1965,10 +1944,10 @@ export namespace DocUtils {
const upfiles = await Networking.UploadFilesToServer(fileNoGuidPairs);
for (const {
- source: { name, type },
+ source: { newFilename, mimetype },
result,
} of upfiles) {
- name && type && processFileupload(generatedDocuments, name, type, result, options);
+ newFilename && mimetype && processFileupload(generatedDocuments, newFilename, mimetype, result, options);
}
return generatedDocuments;
}
@@ -1978,15 +1957,15 @@ export namespace DocUtils {
// 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 },
+ source: { newFilename, mimetype },
result,
- } = upfiles.lastElement() ?? { source: { name: '', type: '' }, result: { message: 'upload failed' } };
+ } = upfiles.lastElement() ?? { source: { newFilename: '', mimetype: '' }, result: { message: 'upload failed' } };
if ((result as any).message) {
if (overwriteDoc) {
overwriteDoc.loadingError = (result as any).message;
LoadingBox.removeCurrentlyLoading(overwriteDoc);
}
- } else name && type && processFileupload(generatedDocuments, name, type, result, options, overwriteDoc);
+ } else newFilename && mimetype && processFileupload(generatedDocuments, newFilename, mimetype, result, options, overwriteDoc);
});
}