mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-28 17:39:57 +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 = {}) {
|
||||
let { state } = transform
|
||||
properties = Normalize.nodeProperties(properties)
|
||||
let { document } = state
|
||||
const { state } = transform
|
||||
const { document } = state
|
||||
const blocks = document.getBlocksAtRange(range)
|
||||
|
||||
blocks.forEach((block) => {
|
||||
block = block.merge(properties)
|
||||
document = document.updateDescendant(block)
|
||||
transform.setNodeByKey(block.key, properties)
|
||||
})
|
||||
|
||||
document = document.normalize()
|
||||
state = state.merge({ document })
|
||||
transform.state = state
|
||||
return transform
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user