aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DragManager.ts
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-07-11 15:10:46 -0400
committerbob <bcz@cs.brown.edu>2019-07-11 15:10:46 -0400
commit6060e67bcf08089b826685c512e3aa181c714446 (patch)
treee54f84a576e471e72bcbba02dc3b7286a22a9415 /src/client/util/DragManager.ts
parentd5acf6672b5b7cedf7b6d65293d671faf9bf4a4f (diff)
parent7006f67b7cf15734fb0b63d917ae392758704f75 (diff)
Merge branch 'master' into extensionFields
Diffstat (limited to 'src/client/util/DragManager.ts')
-rw-r--r--src/client/util/DragManager.ts35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index cb71db2c5..8e44631a3 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -61,16 +61,18 @@ export function SetupDrag(
export async function DragLinkAsDocument(dragEle: HTMLElement, x: number, y: number, linkDoc: Doc, sourceDoc: Doc) {
let draggeddoc = LinkManager.Instance.getOppositeAnchor(linkDoc, sourceDoc);
- let moddrag = await Cast(draggeddoc.annotationOn, Doc);
- let dragdocs = moddrag ? [moddrag] : [draggeddoc];
- let dragData = new DragManager.DocumentDragData(dragdocs, dragdocs);
- dragData.dropAction = "alias" as dropActionType;
- DragManager.StartLinkedDocumentDrag([dragEle], sourceDoc, dragData, x, y, {
- handlers: {
- dragComplete: action(emptyFunction),
- },
- hideSource: false
- });
+ if (draggeddoc) {
+ let moddrag = await Cast(draggeddoc.annotationOn, Doc);
+ let dragdocs = moddrag ? [moddrag] : [draggeddoc];
+ let dragData = new DragManager.DocumentDragData(dragdocs, dragdocs);
+ dragData.dropAction = "alias" as dropActionType;
+ DragManager.StartLinkedDocumentDrag([dragEle], sourceDoc, dragData, x, y, {
+ handlers: {
+ dragComplete: action(emptyFunction),
+ },
+ hideSource: false
+ });
+ }
}
export async function DragLinksAsDocuments(dragEle: HTMLElement, x: number, y: number, sourceDoc: Doc) {
@@ -80,9 +82,16 @@ export async function DragLinksAsDocuments(dragEle: HTMLElement, x: number, y: n
if (srcTarg) {
let linkDocs = LinkManager.Instance.getAllRelatedLinks(srcTarg);
if (linkDocs) {
- draggedDocs = linkDocs.map(link => {
- return LinkManager.Instance.getOppositeAnchor(link, sourceDoc);
- });
+ linkDocs.forEach((doc) => {
+ let opp = LinkManager.Instance.getOppositeAnchor(doc, sourceDoc);
+ if (opp) {
+ draggedDocs.push(opp);
+ }
+ }
+ )
+ // draggedDocs = linkDocs.map(link => {
+ // return LinkManager.Instance.getOppositeAnchor(link, sourceDoc);
+ // });
}
}
if (draggedDocs.length) {