aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/views/MainView.tsx11
-rw-r--r--src/client/views/nodes/DragBox.tsx5
2 files changed, 13 insertions, 3 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index cc412a609..18e5052b7 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -40,6 +40,7 @@ import PDFMenu from './pdf/PDFMenu';
import { PreviewCursor } from './PreviewCursor';
import { CollectionFreeFormDocumentView } from './nodes/CollectionFreeFormDocumentView';
import { MainViewNotifs } from './MainViewNotifs';
+import { DocumentType } from '../documents/DocumentTypes';
@observer
export class MainView extends React.Component {
@@ -331,7 +332,15 @@ export class MainView extends React.Component {
}
drop = action((e: Event, de: DragManager.DropEvent) => {
- (de.data as DragManager.DocumentDragData).draggedDocuments.map(doc => Doc.AddDocToList(CurrentUserUtils.UserDocument, "docButtons", doc));
+ (de.data as DragManager.DocumentDragData).draggedDocuments.map(doc => {
+ if (doc.type !== DocumentType.DRAGBOX) {
+ let dbox = Docs.Create.DragboxDocument({ nativeWidth: 100, nativeHeight: 100, width: 100, height: 100, backgroundColor: StrCast(doc.backgroundColor), title: "Custom", icon: "bolt" });
+ dbox.factory = doc;
+ dbox.onDragStart = ScriptField.MakeFunction('getCopy(this.factory, true)');
+ doc = dbox;
+ }
+ Doc.AddDocToList(CurrentUserUtils.UserDocument, "docButtons", doc);
+ });
});
onDrop = (e: React.DragEvent<HTMLDivElement>) => {
diff --git a/src/client/views/nodes/DragBox.tsx b/src/client/views/nodes/DragBox.tsx
index ab3368b94..4fca96382 100644
--- a/src/client/views/nodes/DragBox.tsx
+++ b/src/client/views/nodes/DragBox.tsx
@@ -44,7 +44,7 @@ export class DragBox extends DocComponent<FieldViewProps, DragDocument>(DragDocu
}
}
- onDragMove = (e: MouseEvent) => {
+ onDragMove = async (e: MouseEvent) => {
if (!e.cancelBubble && (Math.abs(this._downX - e.clientX) > 5 || Math.abs(this._downY - e.clientY) > 5)) {
document.removeEventListener("pointermove", this.onDragMove);
document.removeEventListener("pointerup", this.onDragUp);
@@ -52,7 +52,7 @@ export class DragBox extends DocComponent<FieldViewProps, DragDocument>(DragDocu
e.stopPropagation();
e.preventDefault();
DragManager.StartDocumentDrag([this._mainCont.current!], new DragManager.DocumentDragData([this.props.Document]), e.clientX, e.clientY, {
- finishDrag: (dropData) => {
+ finishDrag: async (dropData) => {
let res = onDragStart && onDragStart.script.run({ this: this.props.Document }).result;
let doc = (res as Doc) || Docs.Create.FreeformDocument([], { nativeWidth: undefined, nativeHeight: undefined, width: 150, height: 100, title: "freeform" });
dropData.droppedDocuments = [doc];
@@ -60,6 +60,7 @@ export class DragBox extends DocComponent<FieldViewProps, DragDocument>(DragDocu
handlers: { dragComplete: emptyFunction },
hideSource: false
});
+ await this.props.Document.factory; // if there's a factory Doc that is being copied, make sure it's not pending.
}
e.stopPropagation();
e.preventDefault();