diff options
author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-07 23:33:44 -0500 |
---|---|---|
committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-07 23:33:44 -0500 |
commit | 9b942166ca6b09ce4f310928c3daf8503a63ee5c (patch) | |
tree | cec530ff1bf61f02f3d1a9e722325d78aa935d70 /src/views/nodes/FormattedTextBox.tsx | |
parent | 090093a50397ddc2a8fc2c50f5097f4a4ea8a74c (diff) |
Restored Opt<T> and made a new FieldValue<T> type to replace old Opt<T>
Diffstat (limited to 'src/views/nodes/FormattedTextBox.tsx')
-rw-r--r-- | src/views/nodes/FormattedTextBox.tsx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/views/nodes/FormattedTextBox.tsx b/src/views/nodes/FormattedTextBox.tsx index 3e3e22e46..6d0e117cc 100644 --- a/src/views/nodes/FormattedTextBox.tsx +++ b/src/views/nodes/FormattedTextBox.tsx @@ -6,7 +6,7 @@ import { keymap } from "prosemirror-keymap"; import { schema } from "prosemirror-schema-basic"; import { EditorState, Transaction } from "prosemirror-state"; import { EditorView } from "prosemirror-view"; -import { Opt, FieldWaiting } from "../../fields/Field"; +import { Opt, FieldWaiting, FieldValue } from "../../fields/Field"; import { SelectionManager } from "../../util/SelectionManager"; import "./FormattedTextBox.scss"; import React = require("react") @@ -48,7 +48,7 @@ export class FormattedTextBox extends React.Component<FieldViewProps> { } dispatchTransaction = (tx: Transaction) => { - if (this._editorView && this._editorView != FieldWaiting) { + if (this._editorView) { const state = this._editorView.state.apply(tx); this._editorView.updateState(state); const { doc, fieldKey } = this.props; @@ -85,17 +85,17 @@ export class FormattedTextBox extends React.Component<FieldViewProps> { const field = this.props.doc.GetT(this.props.fieldKey, RichTextField); return field && field != FieldWaiting ? field.Data : undefined; }, (field) => { - if (field && this._editorView && this._editorView != FieldWaiting) { + if (field && this._editorView) { this._editorView.updateState(EditorState.fromJSON(config, JSON.parse(field))); } }) } componentWillUnmount() { - if (this._editorView && this._editorView != FieldWaiting) { + if (this._editorView) { this._editorView.destroy(); } - if (this._reactionDisposer && this._reactionDisposer != FieldWaiting) { + if (this._reactionDisposer) { this._reactionDisposer(); } } |