mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 09:13:24 +01:00
Fix deletion of hanging range with trailing void block node (#4125)
Only unhang the range if the end of the range doesn't match the end of the document.
This commit is contained in:
parent
b64fbd06d3
commit
1b77385848
@ -101,7 +101,12 @@ export const TextTransforms: TextTransforms = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hanging) {
|
if (!hanging) {
|
||||||
at = Editor.unhangRange(editor, at, { voids })
|
const [, end] = Range.edges(at)
|
||||||
|
const endOfDoc = Editor.end(editor, [])
|
||||||
|
|
||||||
|
if (!Point.equals(end, endOfDoc)) {
|
||||||
|
at = Editor.unhangRange(editor, at, { voids })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let [start, end] = Range.edges(at)
|
let [start, end] = Range.edges(at)
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Transforms } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const run = editor => {
|
||||||
|
Transforms.delete(editor)
|
||||||
|
}
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<anchor />
|
||||||
|
This is a first paragraph
|
||||||
|
</block>
|
||||||
|
<block>This is the second paragraph</block>
|
||||||
|
<block void />
|
||||||
|
<block>
|
||||||
|
<focus />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
export const output = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<cursor />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
@ -0,0 +1,26 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Transforms } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const run = editor => {
|
||||||
|
Transforms.delete(editor)
|
||||||
|
}
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<anchor />
|
||||||
|
This is a first paragraph
|
||||||
|
</block>
|
||||||
|
<block>This is the second paragraph</block>
|
||||||
|
<block void>
|
||||||
|
<focus />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
export const output = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<cursor />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user