Skip to content

Commit

Permalink
Prevent history checkpoints during backspace in empty editor (#5063)
Browse files Browse the repository at this point in the history
* Prevent history checkpoints during backspace in empty editor

* Remove errant comment/lint problem
  • Loading branch information
Nantris committed May 9, 2024
1 parent 3a21bc1 commit c52a602
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/src/extensions/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export const Keymap = Extension.create({
? parentPos === $anchor.pos
: Selection.atStart(doc).from === pos

if (!empty || !isAtStart || !parent.type.isTextblock || parent.textContent.length) {
if (
!empty
|| !parent.type.isTextblock
|| parent.textContent.length
|| !isAtStart
|| (isAtStart && $anchor.parent.type.name === 'paragraph') // prevent clearNodes when no nodes to clear, otherwise history stack is appended
) {
return false
}

Expand Down

0 comments on commit c52a602

Please sign in to comment.