1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-24 16:02:55 +02:00

Only create data once in setBlockAtRange and prevent its deletion (#196)

This commit is contained in:
Samy Pessé
2016-07-28 20:13:45 +02:00
committed by Ian Storm Taylor
parent b2c1b844af
commit 21a002ad63

View File

@@ -527,11 +527,15 @@ const Transforms = {
if (typeof properties == 'string') {
properties = { type: properties }
}
if (properties.data) {
properties.data = Data.create(properties.data)
} else {
delete properties.data
}
// Update each of the blocks.
const blocks = node.getBlocksAtRange(range)
blocks.forEach((block) => {
if (properties.data) properties.data = Data.create(properties.data)
block = block.merge(properties)
node = node.updateDescendant(block)
})