mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 05:31:56 +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:
committed by
Ian Storm Taylor
parent
ce8bfa56a6
commit
287875b9e3
@@ -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
|
||||
}
|
||||
|
@@ -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>
|
||||
)
|
Reference in New Issue
Block a user