aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DragManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/DragManager.ts')
-rw-r--r--src/client/util/DragManager.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 043932de5..0ee7ed2b3 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -1,7 +1,5 @@
import { action } from "mobx";
import { Document } from "../../fields/Document";
-import { ImageField } from "../../fields/ImageField";
-import { KeyStore } from "../../fields/KeyStore";
import { CollectionDockingView } from "../views/collections/CollectionDockingView";
import { CollectionView } from "../views/collections/CollectionView";
import { DocumentDecorations } from "../views/DocumentDecorations";
@@ -10,16 +8,19 @@ import { DocumentView } from "../views/nodes/DocumentView";
export function setupDrag(
_reference: React.RefObject<HTMLDivElement>,
docFunc: () => Document,
- removeFunc: (containingCollection: CollectionView) => void = () => { }
+ removeFunc: (containingCollection: CollectionView) => void = () => { },
+ copyOnDrop: boolean = false
) {
let onRowMove = action(
(e: PointerEvent): void => {
e.stopPropagation();
e.preventDefault();
+ // TODO: bcz -- this needs to have a drag threshold so that it doesn't trigger when just selecting.
document.removeEventListener("pointermove", onRowMove);
document.removeEventListener("pointerup", onRowUp);
var dragData = new DragManager.DocumentDragData([docFunc()]);
+ dragData.copyOnDrop = copyOnDrop;
dragData.removeDocument = removeFunc;
DragManager.StartDocumentDrag([_reference.current!], dragData, e.x, e.y);
}
@@ -125,6 +126,7 @@ export namespace DragManager {
xOffset?: number;
yOffset?: number;
aliasOnDrop?: boolean;
+ copyOnDrop?: boolean;
removeDocument?: (collectionDrop: CollectionView) => void;
[id: string]: any;
}
@@ -136,15 +138,12 @@ export namespace DragManager {
downY: number,
options?: DragOptions
) {
- StartDrag(
- eles,
- dragData,
- downX, downY,
- options,
+ StartDrag(eles, dragData, downX, downY, options,
(dropData: { [id: string]: any }) =>
(dropData.droppedDocuments = dragData.aliasOnDrop
? dragData.draggedDocuments.map(d => d.CreateAlias())
- : dragData.draggedDocuments)
+ : dragData.copyOnDrop ? dragData.draggedDocuments.map(d => d.Copy(true) as Document) :
+ dragData.draggedDocuments)
);
}