fix(list-keymap): early exit when selection is not collapsed (#5810)

This commit is contained in:
Juraj Garaj 2024-11-07 09:21:19 +01:00 committed by GitHub
parent 94a8d258f8
commit 88371561bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/extension-list-keymap": patch
---
Fix backspace behavior when selection is not collapsed

View File

@ -12,6 +12,12 @@ export const handleBackspace = (editor: Editor, name: string, parentListTypes: s
return true
}
// if the selection is not collapsed
// we can rely on the default backspace behavior
if (editor.state.selection.from !== editor.state.selection.to) {
return false
}
// if the current item is NOT inside a list item &
// the previous item is a list (orderedList or bulletList)
// move the cursor into the list and delete the current item