mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-27 09:04:31 +02:00
Merge remote-tracking branch 'origin/schema-normalize-selection-ops' into schema-normalize-selection-ops
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
|
import warning from '../utils/warning'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug.
|
* Debug.
|
||||||
@@ -338,6 +339,16 @@ function setNode(state, operation) {
|
|||||||
const { path, properties } = operation
|
const { path, properties } = operation
|
||||||
let { document } = state
|
let { document } = state
|
||||||
let node = document.assertPath(path)
|
let node = document.assertPath(path)
|
||||||
|
|
||||||
|
// Deprecate using setNode for updating children, or keys
|
||||||
|
if (properties.nodes && properties.nodes != node.nodes) {
|
||||||
|
warning('Updating Node.nodes through setNode is not allowed. Use appropriate insertion and removal functions.')
|
||||||
|
delete properties.nodes
|
||||||
|
} else if (properties.key && properties.key != node.key) {
|
||||||
|
warning('Updating Node.key through setNode is not allowed. You should not have to update keys yourself.')
|
||||||
|
delete properties.key
|
||||||
|
}
|
||||||
|
|
||||||
node = node.merge(properties)
|
node = node.merge(properties)
|
||||||
document = document.updateDescendant(node)
|
document = document.updateDescendant(node)
|
||||||
state = state.merge({ document })
|
state = state.merge({ document })
|
||||||
|
Reference in New Issue
Block a user