Skip to content

Commit

Permalink
Fix backspace at beginning of quote deletes block
Browse files Browse the repository at this point in the history
Fixes #468
  • Loading branch information
neilj committed Aug 16, 2024
1 parent 3495270 commit aa29157
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion source/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ class Squire {
return this;
// Break blockquote
} else if (getNearest(block, root, 'BLOCKQUOTE')) {
this.removeQuote(range);
this.replaceWithBlankLine(range);
return this;
}
}
Expand Down Expand Up @@ -2521,6 +2521,18 @@ class Squire {
}

removeQuote(range?: Range): Squire {
this.modifyBlocks((frag) => {
Array.from(frag.querySelectorAll('blockquote')).forEach(
(el: Node) => {
replaceWith(el, empty(el));
},
);
return frag;
}, range);
return this.focus();
}

replaceWithBlankLine(range?: Range): Squire {
this.modifyBlocks(
(/* frag */) =>
this.createDefaultBlock([
Expand Down

0 comments on commit aa29157

Please sign in to comment.