mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-02 03:32:36 +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:
@@ -422,9 +422,12 @@ export const NodeTransforms: NodeTransforms = {
|
||||
// of merging the two. This is a common rich text editor behavior to
|
||||
// prevent losing formatting when deleting entire nodes when you have a
|
||||
// hanging selection.
|
||||
// if prevNode is first child in parent,don't remove it.
|
||||
if (
|
||||
(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 })
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user