1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-28 17:39:57 +02:00

Keep selection while applying Transform.unwrapNodeByKey (#717)

Transforms should be applied in an order so that the selection is
preserved. This replaces "remove --> insert" with "move --> remove".

Close #670
This commit is contained in:
Victor Pontis
2017-04-11 21:37:29 -07:00
committed by Ian Storm Taylor
parent 3e573453a8
commit 2f296972c0

View File

@@ -361,9 +361,8 @@ Transforms.unwrapNodeByKey = (transform, key, options = {}) => {
if (parent.nodes.size === 1) {
// Remove the parent and replace it by the node itself.
transform.removeNodeByKey(parent.key, { normalize: false })
transform.insertNodeByKey(parentParent.key, parentIndex, node, options)
transform.moveNodeByKey(key, parentParent.key, parentIndex, { normalize: false })
transform.removeNodeByKey(parent.key, options)
}
else if (isFirst) {