From dba3497b7729f47fd5b3c608aa4d05809e75f6ad Mon Sep 17 00:00:00 2001 From: Nicolas Gaborit Date: Tue, 26 Sep 2017 19:06:05 +0200 Subject: [PATCH] Apply stack.onBeforeChange in editor.onChange (#1183) --- packages/slate-react/src/components/editor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/slate-react/src/components/editor.js b/packages/slate-react/src/components/editor.js index cee618cc2..f2ce2d341 100644 --- a/packages/slate-react/src/components/editor.js +++ b/packages/slate-react/src/components/editor.js @@ -130,8 +130,6 @@ class Editor extends React.Component { const stk = this.state.stack const change = this.state.state.change() stk[method](change, this, ...args) - stk.onBeforeChange(change, this) - stk.onChange(change, this) this.onChange(change) } } @@ -240,10 +238,14 @@ class Editor extends React.Component { } const { onChange, onDocumentChange, onSelectionChange } = this.props + const { stack } = this.state const { document, selection } = this.tmp const { state } = change if (state == this.state.state) return + stack.onBeforeChange(change, this) + stack.onChange(change, this) + onChange(change) if (onDocumentChange && state.document != document) onDocumentChange(state.document, change) if (onSelectionChange && state.selection != selection) onSelectionChange(state.selection, change)