From 930bdf84ab4f4489f5072f9c082b732f060d880d Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 2 Feb 2023 09:18:36 -0500
Subject: fixed sizing of equation boxes and added grab cursor for link anchors

---
 src/client/views/nodes/EquationBox.tsx | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

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

diff --git a/src/client/views/nodes/EquationBox.tsx b/src/client/views/nodes/EquationBox.tsx
index da9be63b8..163c5a9ed 100644
--- a/src/client/views/nodes/EquationBox.tsx
+++ b/src/client/views/nodes/EquationBox.tsx
@@ -79,14 +79,13 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() {
         if (e.key === 'Backspace' && !this.dataDoc.text) this.props.removeDocument?.(this.rootDoc);
     };
     @undoBatch
-    onChange = (str: string) => {
-        this.dataDoc.text = str;
+    onChange = (str: string) => (this.dataDoc.text = str);
+
+    updateSize = () => {
         const style = this._ref.current && getComputedStyle(this._ref.current.element.current);
-        if (style) {
-            const _height = Number(style.height.replace('px', ''));
-            const _width = Number(style.width.replace('px', ''));
-            this.layoutDoc._width = Math.max(35, _width);
-            this.layoutDoc._height = Math.max(25, _height);
+        if (style?.width.endsWith('px') && style?.height.endsWith('px')) {
+            this.layoutDoc._width = Math.max(35, Number(style.width.replace('px', '')));
+            this.layoutDoc._height = Math.max(25, Number(style.height.replace('px', '')));
         }
     };
     render() {
@@ -94,23 +93,7 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() {
         const scale = (this.props.NativeDimScaling?.() || 1) * NumCast(this.layoutDoc._viewScale, 1);
         return (
             <div
-                ref={r => {
-                    r instanceof HTMLDivElement &&
-                        new ResizeObserver(
-                            action((entries: any) => {
-                                if (entries[0].contentBoxSize[0].inlineSize) {
-                                    this.rootDoc._width = entries[0].contentBoxSize[0].inlineSize;
-                                }
-                                const style = this._ref.current && getComputedStyle(this._ref.current.element.current);
-                                if (style) {
-                                    const _height = Number(style.height.replace('px', ''));
-                                    const _width = Number(style.width.replace('px', ''));
-                                    this.layoutDoc._width = Math.max(35, _width);
-                                    this.layoutDoc._height = Math.max(25, _height);
-                                }
-                            })
-                        ).observe(r);
-                }}
+                ref={r => this.updateSize()}
                 className="equationBox-cont"
                 onPointerDown={e => !e.ctrlKey && e.stopPropagation()}
                 style={{
-- 
cgit v1.2.3-70-g09d2

