From 72dad52c4fea5a2fccabacbb6a49ca1494093954 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 22 Jun 2023 10:14:26 -0400
Subject: cleaned up dragging - abort presItem drags properly, fix naming for
 drag/dropAction, small fix undo of drag removeproperties, dragging in/out of
 headerBar,  fixed isContentActive to avoid SnappingManager.GetIsDragging. 
 fixed resizing videos.

---
 src/client/views/linking/LinkMenuItem.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/client/views/linking/LinkMenuItem.tsx')

diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx
index 5af05e491..9ceac3b8c 100644
--- a/src/client/views/linking/LinkMenuItem.tsx
+++ b/src/client/views/linking/LinkMenuItem.tsx
@@ -78,7 +78,7 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
             e,
             e => {
                 const dragData = new DragManager.DocumentDragData([this.props.linkDoc], 'embed');
-                dragData.removeDropProperties = ['hidden'];
+                dragData.dropPropertiesToRemove = ['hidden'];
                 DragManager.StartDocumentDrag([this._editRef.current!], dragData, e.x, e.y);
                 return true;
             },
-- 
cgit v1.2.3-70-g09d2


From b599b69dd0892de1b98807a7f8b4a8badcd8abe0 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 22 Jun 2023 21:15:24 -0400
Subject: fixed placement of link preview in sidebar to be on screen. got rid
 of transition for display doc border on hover.  fixed showing link targets in
 menu when source is an annotation.  fixed crashes when their is no context
 path for a showDocument

---
 src/client/util/DocumentManager.ts        | 29 ++++++++++++++++-------------
 src/client/util/LinkManager.ts            |  6 ++----
 src/client/views/linking/LinkMenuItem.tsx |  2 +-
 src/client/views/nodes/DocumentView.scss  |  2 +-
 4 files changed, 20 insertions(+), 19 deletions(-)

(limited to 'src/client/views/linking/LinkMenuItem.tsx')

diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 612f16ce9..7e3302067 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -246,16 +246,18 @@ export class DocumentManager {
     ) => {
         const docContextPath = DocumentManager.GetContextPath(targetDoc, true);
         if (docContextPath.some(doc => doc.hidden)) options.toggleTarget = false;
-        let rootContextView = await new Promise<DocumentView>(res => {
-            const viewIndex = docContextPath.findIndex(doc => this.getDocumentView(doc));
-            if (viewIndex !== -1) {
-                viewIndex && docContextPath.splice(0, viewIndex);
-                return res(this.getDocumentView(docContextPath[0])!);
-            }
-            options.didMove = true;
-            docContextPath.some(doc => TabDocView.Activate(doc)) || DocumentViewInternal.addDocTabFunc(docContextPath[0], options.openLocation ?? OpenWhere.addRight);
-            this.AddViewRenderedCb(docContextPath[0], dv => res(dv));
-        });
+        let rootContextView =
+            docContextPath.length &&
+            (await new Promise<DocumentView>(res => {
+                const viewIndex = docContextPath.findIndex(doc => this.getDocumentView(doc));
+                if (viewIndex !== -1) {
+                    viewIndex && docContextPath.splice(0, viewIndex);
+                    return res(this.getDocumentView(docContextPath[0])!);
+                }
+                options.didMove = true;
+                docContextPath.some(doc => TabDocView.Activate(doc)) || DocumentViewInternal.addDocTabFunc(docContextPath[0], options.openLocation ?? OpenWhere.addRight);
+                this.AddViewRenderedCb(docContextPath[0], dv => res(dv));
+            }));
         if (options.openLocation === OpenWhere.lightbox) {
             // even if we found the document view, if the target is a lightbox, we try to open it in the lightbox to preserve lightbox semantics (eg, there's only one active doc in the lightbox)
             const target = DocCast(targetDoc.annotationOn, targetDoc);
@@ -269,9 +271,10 @@ export class DocumentManager {
             const innerDoc = docContextPath.shift();
             return { viewSpec: innerDoc, childDocView: innerDoc && !innerDoc.layout_unrendered ? (await docView.ComponentView?.getView?.(innerDoc)) ?? this.getDocumentView(innerDoc) : undefined };
         };
-        const target = await this.focusViewsInPath(rootContextView, options, childViewIterator);
-        this.restoreDocView(target.viewSpec, target.docView, options, target.contextView ?? target.docView, targetDoc);
-
+        if (rootContextView) {
+            const target = await this.focusViewsInPath(rootContextView, options, childViewIterator);
+            this.restoreDocView(target.viewSpec, target.docView, options, target.contextView ?? target.docView, targetDoc);
+        }
         finished?.();
     };
 
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index 3aa72f501..ce422f849 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -194,10 +194,8 @@ export class LinkManager {
     public static getOppositeAnchor(linkDoc: Doc, anchor: Doc): Doc | undefined {
         const a1 = Cast(linkDoc.link_anchor_1, Doc, null);
         const a2 = Cast(linkDoc.link_anchor_2, Doc, null);
-        if (Doc.AreProtosEqual(anchor, a1)) return a2;
-        if (Doc.AreProtosEqual(anchor, a2)) return a1;
-        if (Doc.AreProtosEqual(anchor, a1.annotationOn as Doc)) return a2;
-        if (Doc.AreProtosEqual(anchor, a2.annotationOn as Doc)) return a1;
+        if (Doc.AreProtosEqual(DocCast(anchor.annotationOn, anchor), DocCast(a1.annotationOn, a1))) return a2;
+        if (Doc.AreProtosEqual(DocCast(anchor.annotationOn, anchor), DocCast(a2.annotationOn, a2))) return a1;
         if (Doc.AreProtosEqual(anchor, linkDoc)) return linkDoc;
     }
 }
diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx
index 9ceac3b8c..737d675aa 100644
--- a/src/client/views/linking/LinkMenuItem.tsx
+++ b/src/client/views/linking/LinkMenuItem.tsx
@@ -170,7 +170,7 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
                                     linkSrc: this.props.sourceDoc,
                                     linkDoc: this.props.linkDoc,
                                     showHeader: false,
-                                    location: [this._drag.current?.getBoundingClientRect().right ?? 100, this._drag.current?.getBoundingClientRect().top ?? e.clientY],
+                                    location: [(this._drag.current?.getBoundingClientRect().left ?? 100) + 40, (this._drag.current?.getBoundingClientRect().top ?? e.clientY) + 25],
                                     noPreview: false,
                                 })
                             }>
diff --git a/src/client/views/nodes/DocumentView.scss b/src/client/views/nodes/DocumentView.scss
index 1265651ad..f1627e1e1 100644
--- a/src/client/views/nodes/DocumentView.scss
+++ b/src/client/views/nodes/DocumentView.scss
@@ -24,7 +24,7 @@
     width: 100%;
     height: 100%;
     border-radius: inherit;
-    transition: outline 0.3s linear;
+    //  transition: outline 0.3s linear;
 
     // background: $white; //overflow: hidden;
     transform-origin: center;
-- 
cgit v1.2.3-70-g09d2

