diff options
author | bobzel <zzzman@gmail.com> | 2021-03-04 22:38:27 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2021-03-04 22:38:27 -0500 |
commit | 5753b5105a5f0afccea74abbceaf9f1f96e16db1 (patch) | |
tree | b25dee471745c03730ebbd333f06bf6f754057fa /src | |
parent | 47e0c97b04a67b3bad1f2c789145a92ba7069f1e (diff) |
fixed template doc height setting (when autoHeight text field)
Diffstat (limited to 'src')
4 files changed, 12 insertions, 8 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 45dd3b545..a85082f26 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -757,7 +757,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps screenToLocal = () => this.props.ScreenToLocalTransform().translate(0, -this.headerMargin); contentScaling = () => this.ContentScale; onClickFunc = () => this.onClickHandler; - setHeight = (height: number) => this.rootDoc._height = height; + setHeight = (height: number) => this.layoutDoc._height = height; setContentView = (view: { getAnchor?: () => Doc, forward?: () => boolean, back?: () => boolean }) => this._componentView = view; @observable contentsActive: () => boolean = returnFalse; @action setContentsActive = (setActive: () => boolean) => this.contentsActive = setActive; diff --git a/src/client/views/nodes/formattedText/EquationView.tsx b/src/client/views/nodes/formattedText/EquationView.tsx index 056e61846..15f15a11e 100644 --- a/src/client/views/nodes/formattedText/EquationView.tsx +++ b/src/client/views/nodes/formattedText/EquationView.tsx @@ -15,24 +15,24 @@ export class EquationView { this._fieldWrapper = document.createElement("div"); this._fieldWrapper.style.width = node.attrs.width; this._fieldWrapper.style.height = node.attrs.height; - this._fieldWrapper.style.fontWeight = "bold"; this._fieldWrapper.style.position = "relative"; this._fieldWrapper.style.display = "inline-block"; - this._fieldWrapper.onkeypress = function (e: any) { e.stopPropagation(); }; - this._fieldWrapper.onkeydown = function (e: any) { e.stopPropagation(); }; - this._fieldWrapper.onkeyup = function (e: any) { e.stopPropagation(); }; this._fieldWrapper.onmousedown = function (e: any) { e.stopPropagation(); }; ReactDOM.render(<EquationViewInternal fieldKey={node.attrs.fieldKey} width={node.attrs.width} height={node.attrs.height} + setEditor={this.setEditor} tbox={tbox} />, this._fieldWrapper); (this as any).dom = this._fieldWrapper; } + _editor: EquationEditor | undefined; + setEditor = (editor?: EquationEditor) => { this._editor = editor; } destroy() { ReactDOM.unmountComponentAtNode(this._fieldWrapper); } - selectNode() { } + selectNode() { this._editor?.mathField.focus(); } + deselectNode() { } } interface IEquationViewInternal { @@ -40,6 +40,7 @@ interface IEquationViewInternal { tbox: FormattedTextBox; width: number; height: number; + setEditor: (editor: EquationEditor | undefined) => void; } @observer @@ -47,6 +48,7 @@ export class EquationViewInternal extends React.Component<IEquationViewInternal> _reactionDisposer: IReactionDisposer | undefined; _textBoxDoc: Doc; _fieldKey: string; + _ref: React.RefObject<EquationEditor> = React.createRef(); constructor(props: IEquationViewInternal) { super(props); @@ -55,6 +57,7 @@ export class EquationViewInternal extends React.Component<IEquationViewInternal> } componentWillUnmount() { this._reactionDisposer?.(); } + componentDidMount() { this.props.setEditor(this._ref.current ?? undefined); } render() { return <div className="equationView" style={{ @@ -64,7 +67,7 @@ export class EquationViewInternal extends React.Component<IEquationViewInternal> height: this.props.height, bottom: 3, }}> - <EquationEditor + <EquationEditor ref={this._ref} value={StrCast(this._textBoxDoc[this._fieldKey], "y=")} onChange={str => this._textBoxDoc[this._fieldKey] = str} autoCommands="pi theta sqrt sum prod alpha beta gamma rho" diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index 104d60fff..0f669a544 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -554,6 +554,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp const uicontrols: ContextMenuProps[] = []; uicontrols.push({ description: `${FormattedTextBox.CanAnnotate ? "Hide" : "Show"} Annotation Bar`, event: () => FormattedTextBox.CanAnnotate = !FormattedTextBox.CanAnnotate, icon: "expand-arrows-alt" }); + uicontrols.push({ description: !this.Document._noSidebar ? "Hide Sidebar Handle" : "Show Sidebar Handle", event: () => this.layoutDoc._noSidebar = !this.layoutDoc._noSidebar, icon: "expand-arrows-alt" }); uicontrols.push({ description: `${this.layoutDoc._showAudio ? "Hide" : "Show"} Dictation Icon`, event: () => this.layoutDoc._showAudio = !this.layoutDoc._showAudio, icon: "expand-arrows-alt" }); uicontrols.push({ description: "Show Highlights...", noexpand: true, subitems: highlighting, icon: "hand-point-right" }); !Doc.UserDoc().noviceMode && uicontrols.push({ @@ -597,7 +598,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp const options = cm.findByDescription("Options..."); const optionItems = options && "subitems" in options ? options.subitems : []; - optionItems.push({ description: !this.Document._noSidebar ? "Hide Sidebar Handle" : "Show Sidebar Handle", event: () => this.layoutDoc._noSidebar = !this.layoutDoc._noSidebar, icon: "expand-arrows-alt" }); optionItems.push({ description: !this.Document._singleLine ? "Make Single Line" : "Make Multi Line", event: () => this.layoutDoc._singleLine = !this.layoutDoc._singleLine, icon: "expand-arrows-alt" }); optionItems.push({ description: `${this.Document._autoHeight ? "Lock" : "Auto"} Height`, event: () => this.layoutDoc._autoHeight = !this.layoutDoc._autoHeight, icon: "plus" }); !options && cm.addItem({ description: "Options...", subitems: optionItems, icon: "eye" }); diff --git a/src/client/views/nodes/formattedText/nodes_rts.ts b/src/client/views/nodes/formattedText/nodes_rts.ts index 3bd41fa7d..9893da3bb 100644 --- a/src/client/views/nodes/formattedText/nodes_rts.ts +++ b/src/client/views/nodes/formattedText/nodes_rts.ts @@ -247,6 +247,7 @@ export const nodes: { [index: string]: NodeSpec } = { attrs: { fieldKey: { default: "" }, }, + atom: true, group: "inline", draggable: false, toDOM(node) { |