fix: allow deleting last character in headings (#1954)

The copy-link decoration widget (contentEditable="false") injected
inside headings prevented browsers from deleting the last remaining
character via Backspace or Delete keys. Only show the widget when the
heading has more than one character of content.
This commit is contained in:
Julien Fontanet 2026-02-18 14:48:15 +01:00 committed by GitHub
parent 0aeaa43112
commit 03a70d768a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,7 +20,7 @@ export const Heading = TiptapHeading.extend<TiptapHeadingOptions>({
const { doc } = state;
doc.descendants((node, pos) => {
if (node.type.name === "heading" && node.content.size > 0) {
if (node.type.name === "heading" && node.content.size > 1) {
const deco = Decoration.widget(
pos + node.nodeSize - 1,
() => {