1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-20 21:34:53 +02:00

fix: cut will remove void element when only select void element (#4107)

This commit is contained in:
Githoniel 2021-04-01 05:19:25 +08:00 committed by GitHub
parent bf83f333e6
commit 5b24c86547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -703,8 +703,15 @@ export const Editable = (props: EditableProps) => {
ReactEditor.setFragmentData(editor, event.clipboardData)
const { selection } = editor
if (selection && Range.isExpanded(selection)) {
Editor.deleteFragment(editor)
if (selection) {
if (Range.isExpanded(selection)) {
Editor.deleteFragment(editor)
} else {
const node = Node.parent(editor, selection.anchor.path)
if (Editor.isVoid(editor, node)) {
Transforms.delete(editor)
}
}
}
}
},