diff --git a/.changeset/four-islands-chew.md b/.changeset/four-islands-chew.md new file mode 100644 index 000000000..74d15a277 --- /dev/null +++ b/.changeset/four-islands-chew.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-list-keymap": patch +--- + +Improve selected text deletion at the end of list items diff --git a/packages/extension-list-keymap/src/listHelpers/handleDelete.ts b/packages/extension-list-keymap/src/listHelpers/handleDelete.ts index 521c5eb5d..893b64f98 100644 --- a/packages/extension-list-keymap/src/listHelpers/handleDelete.ts +++ b/packages/extension-list-keymap/src/listHelpers/handleDelete.ts @@ -16,6 +16,15 @@ export const handleDelete = (editor: Editor, name: string) => { return false } + // if the selection is not collapsed, or not within a single node + // do nothing and proceed + const { selection } = editor.state + const { $from, $to } = selection + + if (!selection.empty && $from.sameParent($to)) { + return false + } + // check if the next node is a list with a deeper depth if (nextListIsDeeper(name, editor.state)) { return editor