1
0
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:
Claudéric Demers 2021-03-31 18:30:45 -04:00 committed by GitHub
parent b64fbd06d3
commit 1b77385848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 1 deletions

View File

@ -101,8 +101,13 @@ export const TextTransforms: TextTransforms = {
}
if (!hanging) {
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)
const startBlock = Editor.above(editor, {

View File

@ -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>
)

View File

@ -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>
)