Prevent history checkpoints during backspace in empty editor (#5063)

* Prevent history checkpoints during backspace in empty editor

* Remove errant comment/lint problem
This commit is contained in:
Nantris 2024-05-09 09:49:59 -04:00 committed by GitHub
parent 3a21bc1d2f
commit c52a6026fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,7 +27,13 @@ export const Keymap = Extension.create({
? parentPos === $anchor.pos ? parentPos === $anchor.pos
: Selection.atStart(doc).from === 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 return false
} }