aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-04-13 18:55:28 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-04-13 18:55:28 -0400
commitb7252aeacbbd73120bc6f80d551f4505646a883b (patch)
tree51fda97eba307793f3a4f74d357c7c5d7255f451 /src
parent22888445b70e374cec082933505017c66bf1fba6 (diff)
Fixed rich text undo
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 3a2a8a554..a49497f8f 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -57,16 +57,20 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
this.onChange = this.onChange.bind(this);
}
+ _applyingChange: boolean = false;
+
dispatchTransaction = (tx: Transaction) => {
if (this._editorView) {
const state = this._editorView.state.apply(tx);
this._editorView.updateState(state);
+ this._applyingChange = true;
this.props.Document.SetDataOnPrototype(
this.props.fieldKey,
JSON.stringify(state.toJSON()),
RichTextField
);
this.props.Document.SetDataOnPrototype(KeyStore.DocumentText, state.doc.textBetween(0, state.doc.content.size, "\n\n"), TextField);
+ this._applyingChange = false;
// doc.SetData(fieldKey, JSON.stringify(state.toJSON()), RichTextField);
}
}
@@ -108,7 +112,7 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
return field && field !== FieldWaiting ? field.Data : undefined;
},
field => {
- if (field && this._editorView) {
+ if (field && this._editorView && !this._applyingChange) {
this._editorView.updateState(
EditorState.fromJSON(config, JSON.parse(field))
);