ignore non-children path of remove op

This commit is contained in:
Ulion 2021-02-07 13:42:04 +08:00
parent dfbb59616a
commit 56b1902577

View File

@ -90,7 +90,9 @@ const opRemove = (
if (type === 'map' && path) {
// remove a key from map, mapping to slate set a key's value to undefined.
ops.push(setDataOp(op, doc)(map, tmpDoc))
if (path[0] === 'children') {
ops.push(setDataOp(op, doc)(map, tmpDoc))
}
return [map, ops]
}
@ -109,8 +111,6 @@ const opRemove = (
const key = path[path.length - 1]
if (key === 'cursors' || op.key === 'cursors') return [map, ops]
const fn = key === 'text' ? removeTextOp : removeNodeOp
return [map, [...ops, fn(op)(map, tmpDoc)]]