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.ts47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 11530ef09..2abcff4f7 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -48,12 +48,10 @@ export function SetupDrag(_reference: React.RefObject<HTMLElement>, docFunc: ()
export async function DragLinkAsDocument(dragEle: HTMLElement, x: number, y: number, linkDoc: Doc, sourceDoc: Doc) {
let draggeddoc = LinkManager.Instance.findOppositeAnchor(linkDoc, sourceDoc);
- // TODO: if not in same context then don't drag
-
let moddrag = await Cast(draggeddoc.annotationOn, Doc);
let dragData = new DragManager.DocumentDragData(moddrag ? [moddrag] : [draggeddoc]);
dragData.dropAction = "alias" as dropActionType;
- DragManager.StartDocumentDrag([dragEle], dragData, x, y, {
+ DragManager.StartLinkedDocumentDrag([dragEle], dragData, x, y, {
handlers: {
dragComplete: action(emptyFunction),
},
@@ -83,11 +81,21 @@ export async function DragLinksAsDocuments(dragEle: HTMLElement, x: number, y: n
if (doc) moddrag.push(doc);
}
let dragData = new DragManager.DocumentDragData(moddrag.length ? moddrag : draggedDocs);
- dragData.dropAction = "alias" as dropActionType;
// dragData.moveDocument = (document, targetCollection, addDocument) => {
// return false;
// };
- DragManager.StartDocumentDrag([dragEle], dragData, x, y, {
+
+ // runInAction(() => StartDragFunctions.map(func => func()));
+ // (eles, dragData, downX, downY, options,
+ // (dropData: { [id: string]: any }) => {
+ // (dropData.droppedDocuments = dragData.userDropAction === "alias" || (!dragData.userDropAction && dragData.dropAction === "alias") ?
+ // dragData.draggedDocuments.map(d => Doc.MakeAlias(d)) :
+ // dragData.userDropAction === "copy" || (!dragData.userDropAction && dragData.dropAction === "copy") ?
+ // dragData.draggedDocuments.map(d => Doc.MakeCopy(d, true)) :
+ // dragData.draggedDocuments
+ // );
+ // });
+ DragManager.StartLinkedDocumentDrag([dragEle], dragData, x, y, {
handlers: {
dragComplete: action(emptyFunction),
},
@@ -215,6 +223,35 @@ export namespace DragManager {
});
}
+ export function StartLinkedDocumentDrag(eles: HTMLElement[], dragData: DocumentDragData, downX: number, downY: number, options?: DragOptions) {
+
+ runInAction(() => StartDragFunctions.map(func => func()));
+ StartDrag(eles, dragData, downX, downY, options,
+ (dropData: { [id: string]: any }) => {
+ dropData.droppedDocuments = dragData.draggedDocuments.map(d => {
+ let dv = DocumentManager.Instance.getDocumentView(d);
+ // console.log("DRAG", StrCast(d.title));
+
+ if (dv) {
+ console.log("DRAG", StrCast(d.title), "has view");
+ if (dv.props.ContainingCollectionView === SelectionManager.SelectedDocuments()[0].props.ContainingCollectionView) {
+ console.log("DRAG", StrCast(d.title), "same");
+ return d;
+ } else {
+ console.log("DRAG", StrCast(d.title), "diff");
+ return Doc.MakeAlias(d);
+ }
+ } else {
+ console.log("DRAG", StrCast(d.title), "has no view");
+ return Doc.MakeAlias(d);
+ }
+ // return (dv && dv.props.ContainingCollectionView !== SelectionManager.SelectedDocuments()[0].props.ContainingCollectionView) || !dv ?
+ // Doc.MakeAlias(d) : d;
+ });
+
+ });
+ }
+
export function StartAnnotationDrag(eles: HTMLElement[], dragData: AnnotationDragData, downX: number, downY: number, options?: DragOptions) {
StartDrag(eles, dragData, downX, downY, options);
}