mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-15 11:44:05 +02:00
Prevent history mutation during initialization (#1329)
* fix history on init * fix setValue save logic * update comment
This commit is contained in:
committed by
Ian Storm Taylor
parent
d0172eac17
commit
e29caf46ec
@@ -109,9 +109,10 @@ function BeforePlugin() {
|
|||||||
|
|
||||||
// If the value's schema isn't the editor's schema, update it. This can
|
// 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.
|
// 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) {
|
if (value.schema != editor.schema) {
|
||||||
change
|
change
|
||||||
.setValue({ schema: editor.schema })
|
.setValue({ schema: editor.schema }, { save: false })
|
||||||
.normalize()
|
.normalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,9 +14,10 @@ const Changes = {}
|
|||||||
*
|
*
|
||||||
* @param {Change} change
|
* @param {Change} change
|
||||||
* @param {Object|Value} properties
|
* @param {Object|Value} properties
|
||||||
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Changes.setValue = (change, properties) => {
|
Changes.setValue = (change, properties, options = {}) => {
|
||||||
properties = Value.createProperties(properties)
|
properties = Value.createProperties(properties)
|
||||||
const { value } = change
|
const { value } = change
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ Changes.setValue = (change, properties) => {
|
|||||||
type: 'set_value',
|
type: 'set_value',
|
||||||
properties,
|
properties,
|
||||||
value,
|
value,
|
||||||
})
|
}, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user