1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 05:31:56 +02:00

Don't normalize with schema when moving selection

This commit is contained in:
Samy Pessé
2016-10-31 17:59:01 +01:00
parent 74695d80f0
commit 925189eb94

View File

@@ -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
}
/**