aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSubView.tsx
diff options
context:
space:
mode:
authorgeireann <60007097+geireann@users.noreply.github.com>2021-07-22 15:25:37 -0400
committergeireann <60007097+geireann@users.noreply.github.com>2021-07-22 15:25:37 -0400
commitb4ad8cc62c51648c41f4b0ea2816f9086ed5c711 (patch)
treea4486669d6850fa0137e15beb1abce4d933cfd7d /src/client/views/collections/CollectionSubView.tsx
parentaf33c5a46f0680dad41532a86557193bf8af3b08 (diff)
parent491fb6fc41792b1dfe7e3f9210b07a6b8e1eb0a7 (diff)
Merge branch 'master' into Ashley
Diffstat (limited to 'src/client/views/collections/CollectionSubView.tsx')
-rw-r--r--src/client/views/collections/CollectionSubView.tsx20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 8d549bd56..ca45536f4 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -241,7 +241,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
@undoBatch
@action
- protected async onExternalDrop(e: React.DragEvent, options: DocumentOptions, completed?: () => void) {
+ protected async onExternalDrop(e: React.DragEvent, options: DocumentOptions, completed?: (docs: Doc[]) => void) {
if (e.ctrlKey) {
e.stopPropagation(); // bcz: this is a hack to stop propagation when dropping an image on a text document with shift+ctrl
return;
@@ -439,7 +439,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
}
this.slowLoadDocuments(files, options, generatedDocuments, text, completed, e.clientX, e.clientY, addDocument).then(batch.end);
}
- slowLoadDocuments = async (files: (File[] | string), options: DocumentOptions, generatedDocuments: Doc[], text: string, completed: (() => void) | undefined, clientX: number, clientY: number, addDocument: (doc: Doc | Doc[]) => boolean) => {
+ slowLoadDocuments = async (files: (File[] | string), options: DocumentOptions, generatedDocuments: Doc[], text: string, completed: ((doc: Doc[]) => void) | undefined, clientX: number, clientY: number, addDocument: (doc: Doc | Doc[]) => boolean) => {
const disposer = OverlayView.Instance.addElement(
<ReactLoading type={"spinningBubbles"} color={"green"} height={250} width={250} />, { x: clientX - 125, y: clientY - 125 });
if (typeof files === "string") {
@@ -448,13 +448,17 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
generatedDocuments.push(...await DocUtils.uploadFilesToDocs(files, options));
}
if (generatedDocuments.length) {
- const set = generatedDocuments.length > 1 && generatedDocuments.map(d => DocUtils.iconify(d));
- if (set) {
- addDocument(DocUtils.pileup(generatedDocuments, options.x!, options.y!)!);
- } else {
- generatedDocuments.forEach(addDocument);
+ const isFreeformView = this.props.Document._viewType === CollectionViewType.Freeform;
+ const set = !isFreeformView ? generatedDocuments :
+ generatedDocuments.length > 1 ? generatedDocuments.map(d => { DocUtils.iconify(d); return d; }) : [];
+ if (completed) completed(set);
+ else {
+ if (isFreeformView) {
+ addDocument(DocUtils.pileup(generatedDocuments, options.x!, options.y!)!);
+ } else {
+ generatedDocuments.forEach(addDocument);
+ }
}
- completed?.();
} else {
if (text && !text.includes("https://")) {
addDocument(Docs.Create.TextDocument(text, { ...options, title: text.substring(0, 20), _width: 400, _height: 315 }));