aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/EquationBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/EquationBox.tsx')
-rw-r--r--src/client/views/nodes/EquationBox.tsx31
1 files changed, 7 insertions, 24 deletions
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={{