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:
committed by
Ian Storm Taylor
parent
3e573453a8
commit
2f296972c0
@@ -361,9 +361,8 @@ Transforms.unwrapNodeByKey = (transform, key, options = {}) => {
|
|||||||
|
|
||||||
|
|
||||||
if (parent.nodes.size === 1) {
|
if (parent.nodes.size === 1) {
|
||||||
// Remove the parent and replace it by the node itself.
|
transform.moveNodeByKey(key, parentParent.key, parentIndex, { normalize: false })
|
||||||
transform.removeNodeByKey(parent.key, { normalize: false })
|
transform.removeNodeByKey(parent.key, options)
|
||||||
transform.insertNodeByKey(parentParent.key, parentIndex, node, options)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (isFirst) {
|
else if (isFirst) {
|
||||||
|
Reference in New Issue
Block a user