diff options
author | bobzel <zzzman@gmail.com> | 2023-02-02 00:20:54 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-02-02 00:20:54 -0500 |
commit | ac6f6a19fedc9c6a9d233a43aee4ed82b620d5ad (patch) | |
tree | b31769fd93f7d8df244bb95936d842e2f5c1b6a4 /src/client/views/nodes/EquationBox.tsx | |
parent | 294412015c0f3dbfaa8982f1dcab100fbfdd036f (diff) |
added initial support for equationBox font size setting
Diffstat (limited to 'src/client/views/nodes/EquationBox.tsx')
-rw-r--r-- | src/client/views/nodes/EquationBox.tsx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/client/views/nodes/EquationBox.tsx b/src/client/views/nodes/EquationBox.tsx index c279341cc..da9be63b8 100644 --- a/src/client/views/nodes/EquationBox.tsx +++ b/src/client/views/nodes/EquationBox.tsx @@ -21,6 +21,7 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() { public static SelectOnLoad: string = ''; _ref: React.RefObject<EquationEditor> = React.createRef(); componentDidMount() { + this.props.setContentView?.(this); if (EquationBox.SelectOnLoad === this.rootDoc[Id] && (!LightboxView.LightboxDoc || LightboxView.IsLightboxDocView(this.props.docViewPath()))) { this.props.select(false); @@ -100,6 +101,13 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() { 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); }} @@ -110,6 +118,7 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() { width: 'fit-content', // `${100 / scale}%`, height: `${100 / scale}%`, pointerEvents: !this.props.isSelected() ? 'none' : undefined, + fontSize: StrCast(this.rootDoc._fontSize), }} onKeyDown={e => e.stopPropagation()}> <EquationEditor ref={this._ref} value={this.dataDoc.text || 'x'} spaceBehavesLikeTab={true} onChange={this.onChange} autoCommands="pi theta sqrt sum prod alpha beta gamma rho" autoOperatorNames="sin cos tan" /> |