mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 12:30:11 +02:00
Fix deleteBackwardAtRange removing extra character when called at start of both block and inline node (#2408)
This commit is contained in:
committed by
Ian Storm Taylor
parent
a75c06b501
commit
da2cf83310
@@ -322,7 +322,16 @@ Commands.deleteBackwardAtRange = (editor, range, n = 1) => {
|
|||||||
const text = document.getDescendant(start.key)
|
const text = document.getDescendant(start.key)
|
||||||
|
|
||||||
if (start.isAtStartOfNode(text)) {
|
if (start.isAtStartOfNode(text)) {
|
||||||
const prev = document.getPreviousText(text.key)
|
let prev = document.getPreviousText(text.key)
|
||||||
|
const inline = document.getClosestInline(text.key)
|
||||||
|
|
||||||
|
// If the range is at the start of the inline node, and previous text node
|
||||||
|
// is empty, take the text node before that, or "prevBlock" would be the
|
||||||
|
// same node as "block"
|
||||||
|
if (inline && prev.text === '') {
|
||||||
|
prev = document.getPreviousText(prev.key)
|
||||||
|
}
|
||||||
|
|
||||||
const prevBlock = document.getClosestBlock(prev.key)
|
const prevBlock = document.getClosestBlock(prev.key)
|
||||||
const prevVoid = document.getClosestVoid(prev.key, editor)
|
const prevVoid = document.getClosestVoid(prev.key, editor)
|
||||||
|
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
|
import h from '../../../helpers/h'
|
||||||
|
|
||||||
|
export default function(editor) {
|
||||||
|
editor.deleteBackward()
|
||||||
|
}
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<value>
|
||||||
|
<document>
|
||||||
|
<paragraph>
|
||||||
|
one<link>two</link>
|
||||||
|
</paragraph>
|
||||||
|
<paragraph>
|
||||||
|
<link>
|
||||||
|
<cursor />three
|
||||||
|
</link>four
|
||||||
|
</paragraph>
|
||||||
|
</document>
|
||||||
|
</value>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const output = (
|
||||||
|
<value>
|
||||||
|
<document>
|
||||||
|
<paragraph>
|
||||||
|
one<link>two</link>
|
||||||
|
<link>
|
||||||
|
<cursor />three
|
||||||
|
</link>four
|
||||||
|
</paragraph>
|
||||||
|
</document>
|
||||||
|
</value>
|
||||||
|
)
|
Reference in New Issue
Block a user