mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 18:09:49 +02:00
update setBlockAtRange() transform to use primitives
This commit is contained in:
@@ -613,19 +613,14 @@ export function removeMarkAtRange(transform, range, mark) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function setBlockAtRange(transform, range, properties = {}) {
|
export function setBlockAtRange(transform, range, properties = {}) {
|
||||||
let { state } = transform
|
const { state } = transform
|
||||||
properties = Normalize.nodeProperties(properties)
|
const { document } = state
|
||||||
let { document } = state
|
|
||||||
const blocks = document.getBlocksAtRange(range)
|
const blocks = document.getBlocksAtRange(range)
|
||||||
|
|
||||||
blocks.forEach((block) => {
|
blocks.forEach((block) => {
|
||||||
block = block.merge(properties)
|
transform.setNodeByKey(block.key, properties)
|
||||||
document = document.updateDescendant(block)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
document = document.normalize()
|
|
||||||
state = state.merge({ document })
|
|
||||||
transform.state = state
|
|
||||||
return transform
|
return transform
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user