aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-06-17 11:32:38 -0400
committerFawn <fangrui_tong@brown.edu>2019-06-17 11:32:38 -0400
commit70eaadb2773ae78f99d856c4986b8f27ebbb36ad (patch)
tree1c6aa95a886fb8e20de71214825bdf99d4383890 /src
parent14ae66aec1879386c130567496597db9105e4f99 (diff)
single link can be dragged from link menu
Diffstat (limited to 'src')
-rw-r--r--src/client/util/DragManager.ts12
-rw-r--r--src/client/views/nodes/LinkBox.tsx4
2 files changed, 14 insertions, 2 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index b32c25b0a..82d30e0e6 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -43,6 +43,18 @@ export function SetupDrag(_reference: React.RefObject<HTMLElement>, docFunc: ()
return onItemDown;
}
+export async function DragLinkAsDocument(dragEle: HTMLElement, x: number, y: number, linkDoc: Doc, sourceDoc: Doc) {
+ let draggeddoc = LinkManager.Instance.findOppositeAnchor(linkDoc, sourceDoc);
+ let moddrag = await Cast(draggeddoc.annotationOn, Doc);
+ let dragData = new DragManager.DocumentDragData(moddrag ? [moddrag] : [draggeddoc]);
+ DragManager.StartDocumentDrag([dragEle], dragData, x, y, {
+ handlers: {
+ dragComplete: action(emptyFunction),
+ },
+ hideSource: false
+ });
+}
+
export async function DragLinksAsDocuments(dragEle: HTMLElement, x: number, y: number, sourceDoc: Doc) {
let srcTarg = sourceDoc.proto;
let draggedDocs: Doc[] = [];
diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx
index 09df1eac5..8d07547ed 100644
--- a/src/client/views/nodes/LinkBox.tsx
+++ b/src/client/views/nodes/LinkBox.tsx
@@ -10,7 +10,7 @@ import { Doc } from '../../../new_fields/Doc';
import { StrCast, Cast } from '../../../new_fields/Types';
import { observable, action } from 'mobx';
import { LinkManager } from '../../util/LinkManager';
-import { DragLinksAsDocuments } from '../../util/DragManager';
+import { DragLinksAsDocuments, DragLinkAsDocument } from '../../util/DragManager';
import { SelectionManager } from '../../util/SelectionManager';
library.add(faEye, faEdit, faTimes, faArrowRight, faChevronDown, faChevronUp);
@@ -76,7 +76,7 @@ export class LinkBox extends React.Component<Props> {
document.removeEventListener("pointermove", this.onLinkButtonMoved);
document.removeEventListener("pointerup", this.onLinkButtonUp);
- DragLinksAsDocuments(this._drag.current, e.x, e.y, SelectionManager.SelectedDocuments()[0].props.Document);
+ DragLinkAsDocument(this._drag.current, e.x, e.y, this.props.linkDoc, this.props.sourceDoc);
}
e.stopPropagation();
}