From 925189eb942601b6d813b046c6ffdbcf9abc577f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 31 Oct 2016 17:59:01 +0100 Subject: [PATCH] Don't normalize with schema when moving selection --- src/plugins/core.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/core.js b/src/plugins/core.js index edb71e766..547b2f958 100644 --- a/src/plugins/core.js +++ b/src/plugins/core.js @@ -32,7 +32,6 @@ function Plugin(options = {}) { placeholderClassName, placeholderStyle, } = options - let prevState /** * On before change, enforce the editor's schema. @@ -43,8 +42,15 @@ function Plugin(options = {}) { */ function onBeforeChange(state, editor) { + // Don't normalize with plugins schema when typing text in native mode if (state.isNative) return state + const schema = editor.getSchema() + const { state: prevState } = editor.state + + // Since schema can only normalize the document, we avoid creating + // a transform and normalize the selection if the document is the same + if (prevState && state.document == prevState.document) return state console.time('onBeforeChange'); const newState = state.transform() @@ -52,8 +58,7 @@ function Plugin(options = {}) { .apply({ save: false }) console.timeEnd('onBeforeChange'); - prevState = newState - return newState; + return newState } /**