Skip to content

Commit

Permalink
List Keymap: Fix backspace behavior when selection is not collapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
juraj98 committed Nov 7, 2024
1 parent 8a2e548 commit df343a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-monkeys-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/extension-list-keymap": patch
---

Fix backspace behavior when selection is not collapsed
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df343a3

Please sign in to comment.