diff options
author | mehekj <mehek.jethani@gmail.com> | 2023-01-13 18:11:34 -0500 |
---|---|---|
committer | mehekj <mehek.jethani@gmail.com> | 2023-01-13 18:11:34 -0500 |
commit | 82de335e0643f907e44cb193c9b2c6da1b3cbaf1 (patch) | |
tree | e72a74f8b18bfd1e9d6f7262a0fb5203d82b6921 /src/client/views/nodes/formattedText/EquationView.tsx | |
parent | 73d3c63658c4bdf3268ea81a02eb96566869b855 (diff) | |
parent | 6d32fe60ce32d650a2ba0d5eb8e36dccb591521f (diff) |
Merge branch 'master' into schema-mehek
Diffstat (limited to 'src/client/views/nodes/formattedText/EquationView.tsx')
-rw-r--r-- | src/client/views/nodes/formattedText/EquationView.tsx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/client/views/nodes/formattedText/EquationView.tsx b/src/client/views/nodes/formattedText/EquationView.tsx index 0fd2a7808..714ae458c 100644 --- a/src/client/views/nodes/formattedText/EquationView.tsx +++ b/src/client/views/nodes/formattedText/EquationView.tsx @@ -1,5 +1,5 @@ import EquationEditor from 'equation-editor-react'; -import { IReactionDisposer } from 'mobx'; +import { IReactionDisposer, trace } from 'mobx'; import { observer } from 'mobx-react'; import { TextSelection } from 'prosemirror-state'; import * as ReactDOM from 'react-dom/client'; @@ -12,7 +12,11 @@ import React = require('react'); export class EquationView { dom: HTMLDivElement; // container for label and value root: any; + tbox: FormattedTextBox; + view: any; constructor(node: any, view: any, getPos: any, tbox: FormattedTextBox) { + this.tbox = tbox; + this.view = view; this.dom = document.createElement('div'); this.dom.style.width = node.attrs.width; this.dom.style.height = node.attrs.height; @@ -28,13 +32,18 @@ export class EquationView { _editor: EquationEditor | undefined; setEditor = (editor?: EquationEditor) => (this._editor = editor); destroy() { + this.root.unmount(); // ReactDOM.unmountComponentAtNode(this.dom); } setSelection() { this._editor?.mathField.focus(); } selectNode() { - this._editor?.mathField.focus(); + this.tbox._applyingChange = this.tbox.fieldKey; // setting focus will make prosemirror lose focus, which will cause it to change its selection to a text selection, which causes this view to get rebuilt but it's no longer node selected, so the equationview won't have focus + setTimeout(() => { + this._editor?.mathField.focus(); + setTimeout(() => (this.tbox._applyingChange = '')); + }); } deselectNode() {} } |