mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-25 08:11:53 +02:00
Only create data once in setBlockAtRange and prevent its deletion (#196)
This commit is contained in:
committed by
Ian Storm Taylor
parent
b2c1b844af
commit
21a002ad63
@@ -527,11 +527,15 @@ const Transforms = {
|
|||||||
if (typeof properties == 'string') {
|
if (typeof properties == 'string') {
|
||||||
properties = { type: properties }
|
properties = { type: properties }
|
||||||
}
|
}
|
||||||
|
if (properties.data) {
|
||||||
|
properties.data = Data.create(properties.data)
|
||||||
|
} else {
|
||||||
|
delete properties.data
|
||||||
|
}
|
||||||
|
|
||||||
// Update each of the blocks.
|
// Update each of the blocks.
|
||||||
const blocks = node.getBlocksAtRange(range)
|
const blocks = node.getBlocksAtRange(range)
|
||||||
blocks.forEach((block) => {
|
blocks.forEach((block) => {
|
||||||
if (properties.data) properties.data = Data.create(properties.data)
|
|
||||||
block = block.merge(properties)
|
block = block.merge(properties)
|
||||||
node = node.updateDescendant(block)
|
node = node.updateDescendant(block)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user