From cfef23fbe4f3c3fee33a6b6cc5e970fe13c7d7b6 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 27 Feb 2023 15:49:26 -0500
Subject: fixed ink anchor restoration by saving width/height with dataview

---
 src/client/views/nodes/trails/PresBox.tsx | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(limited to 'src/client/views/nodes/trails/PresBox.tsx')

diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index 45d386436..486c941e9 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -344,7 +344,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
     @action
     static restoreTargetDocView(bestTargetView: Opt<DocumentView>, activeItem: Doc, transTime: number, pinDocLayout: boolean = BoolCast(activeItem.presPinLayout), pinDataTypes?: pinDataTypes, targetDoc?: Doc) {
         const bestTarget = bestTargetView?.rootDoc ?? (targetDoc?.unrendered ? DocCast(targetDoc?.annotationOn) : targetDoc);
-        if (!bestTarget) return;
+        if (!bestTarget || activeItem === bestTarget) return;
         let changed = false;
         if (pinDocLayout) {
             if (
@@ -385,6 +385,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
                 Doc.GetProto(bestTarget).color = activeItem.color;
                 changed = true;
             }
+            if (bestTarget.width !== activeItem.width) {
+                bestTarget._width = NumCast(activeItem.presWidth, NumCast(bestTarget.width));
+                changed = true;
+            }
+            if (bestTarget.height !== activeItem.height) {
+                bestTarget._height = NumCast(activeItem.presHeight, NumCast(bestTarget.height));
+                changed = true;
+            }
         }
         if ((pinDataTypes?.viewType && activeItem.presPinViewType !== undefined) || (!pinDataTypes && activeItem.presPinViewType !== undefined)) {
             if (bestTarget._viewType !== activeItem.presPinViewType) {
@@ -535,6 +543,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
             if (pinProps.pinData.inkable) {
                 pinDoc.presFillColor = targetDoc.fillColor;
                 pinDoc.presColor = targetDoc.color;
+                pinDoc.presWidth = targetDoc._width;
+                pinDoc.presHeight = targetDoc._height;
             }
             if (pinProps.pinData.scrollable) pinDoc.presPinViewScroll = targetDoc._scrollTop;
             if (pinProps.pinData.clippable) pinDoc.presPinClipWidth = targetDoc._clipWidth;
-- 
cgit v1.2.3-70-g09d2

