mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-02 11:42:53 +02:00
Do not remove empty node in merge operation if it is first children i… (#4287)
* Do not remove empty node in merge operation if it is first children in parent(#4228) * Create merge-nodes-issue * fix typo in changeset Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
This commit is contained in:
5
.changeset/merge-nodes-issue
Normal file
5
.changeset/merge-nodes-issue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"slate": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Do not remove empty node in merge operation if it is first children in its parent.
|
@@ -422,9 +422,12 @@ export const NodeTransforms: NodeTransforms = {
|
|||||||
// of merging the two. This is a common rich text editor behavior to
|
// of merging the two. This is a common rich text editor behavior to
|
||||||
// prevent losing formatting when deleting entire nodes when you have a
|
// prevent losing formatting when deleting entire nodes when you have a
|
||||||
// hanging selection.
|
// hanging selection.
|
||||||
|
// if prevNode is first child in parent,don't remove it.
|
||||||
if (
|
if (
|
||||||
(Element.isElement(prevNode) && Editor.isEmpty(editor, prevNode)) ||
|
(Element.isElement(prevNode) && Editor.isEmpty(editor, prevNode)) ||
|
||||||
(Text.isText(prevNode) && prevNode.text === '')
|
(Text.isText(prevNode) &&
|
||||||
|
prevNode.text === '' &&
|
||||||
|
prevPath[prevPath.length - 1] !== 0)
|
||||||
) {
|
) {
|
||||||
Transforms.removeNodes(editor, { at: prevPath, voids })
|
Transforms.removeNodes(editor, { at: prevPath, voids })
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user