1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-12 10:14:02 +02:00

Prevent history mutation during initialization (#1329)

* fix history on init

* fix setValue save logic

* update comment
This commit is contained in:
Yifeng Wang
2017-10-30 11:58:38 -05:00
committed by Ian Storm Taylor
parent d0172eac17
commit e29caf46ec
2 changed files with 5 additions and 3 deletions

View File

@@ -109,9 +109,10 @@ function BeforePlugin() {
// If the value's schema isn't the editor's schema, update it. This can
// happen on the initialization of the editor, or if the schema changes.
// This change isn't save into history since only schema is updated.
if (value.schema != editor.schema) {
change
.setValue({ schema: editor.schema })
.setValue({ schema: editor.schema }, { save: false })
.normalize()
}

View File

@@ -14,9 +14,10 @@ const Changes = {}
*
* @param {Change} change
* @param {Object|Value} properties
* @param {Object} options
*/
Changes.setValue = (change, properties) => {
Changes.setValue = (change, properties, options = {}) => {
properties = Value.createProperties(properties)
const { value } = change
@@ -24,7 +25,7 @@ Changes.setValue = (change, properties) => {
type: 'set_value',
properties,
value,
})
}, options)
}
/**