From 3b0fca96e8350c4d103833a0cee6dcdc5e781d5c Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 16 Jul 2025 13:03:12 -0400
Subject: fixed placement of Docs on views that are modified as the result of
 the AI componentUI view being display

---
 src/client/views/nodes/DocumentView.tsx | 7 +++++++
 1 file changed, 7 insertions(+)

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

diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index bd71115db..90edab3a7 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -743,6 +743,12 @@ export class DocumentViewInternal extends DocComponent<DocumentViewProps & Field
     widgetOverlayFunc = () => (this.widgetDecorations ? this.widgetOverlay : null);
     viewingAiEditor = () => (this._props.showAIEditor && this._componentView?.componentAIView?.() !== undefined ? this.aiEditor : null);
     @observable _contentsRef: DocumentContentsView | undefined = undefined;
+    screenToContentsXf = () =>
+        this.viewingAiEditor()
+            ? this.layoutDoc.layout_reflowHorizontal
+                ? this._props.ScreenToLocalTransform().scale(Math.min(this.aiContentsWidth() / this._props.PanelWidth(), this.aiContentsHeight() / this._props.PanelHeight()))
+                : this._props.ScreenToLocalTransform().translate((this._props.PanelWidth() - this.aiContentsWidth()) / 2, 0)
+            : this._props.ScreenToLocalTransform();
     @computed get viewBoxContents() {
         TraceMobx();
         const isInk = this.layoutDoc._layout_isSvg && !this._props.LayoutTemplateString;
@@ -762,6 +768,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewProps & Field
                         layoutFieldKey={StrCast(this.Document.layout_fieldKey, 'layout')}
                         pointerEvents={this.contentPointerEvents}
                         setContentViewBox={this.setContentView}
+                        ScreenToLocalTransform={this.screenToContentsXf}
                         childFilters={this.childFilters}
                         PanelWidth={this.viewingAiEditor() ? this.aiContentsWidth : this._props.PanelWidth}
                         PanelHeight={this.viewingAiEditor() ? this.aiContentsHeight : this.panelHeight}
-- 
cgit v1.2.3-70-g09d2

