1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 21:21:21 +02:00

Checking to make sure there is only text in the node before removing the whole node on deleteBackward (#2476)

* Checking to make sure there is only text in the node before removing the whole node.

* Make it Prettier
This commit is contained in:
ldavidpace
2018-12-04 12:08:45 -07:00
committed by Ian Storm Taylor
parent ce8bfa56a6
commit 287875b9e3
2 changed files with 38 additions and 1 deletions

View File

@@ -312,7 +312,12 @@ Commands.deleteBackwardAtRange = (editor, range, n = 1) => {
// PERF: If the closest block is empty, remove it. This is just a shortcut,
// since merging it would result in the same outcome.
if (document.nodes.size !== 1 && block && block.text === '') {
if (
document.nodes.size !== 1 &&
block &&
block.text === '' &&
block.nodes.size === 1
) {
editor.removeNodeByKey(block.key)
return
}

View File

@@ -0,0 +1,32 @@
/** @jsx h */
import h from '../../../helpers/h'
export default function(editor) {
editor.deleteBackward()
}
export const input = (
<value>
<document>
<paragraph>
<emoji />
<emoji />
<cursor />
</paragraph>
<paragraph />
</document>
</value>
)
export const output = (
<value>
<document>
<paragraph>
<emoji />
<cursor />
</paragraph>
<paragraph />
</document>
</value>
)