From aa29157969713a0b2cbb4d017b6f9477f016a4a9 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Fri, 16 Aug 2024 15:52:29 +1000 Subject: [PATCH] Fix backspace at beginning of quote deletes block Fixes #468 --- source/Editor.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/Editor.ts b/source/Editor.ts index 552bac1..f1655c0 100644 --- a/source/Editor.ts +++ b/source/Editor.ts @@ -2060,7 +2060,7 @@ class Squire { return this; // Break blockquote } else if (getNearest(block, root, 'BLOCKQUOTE')) { - this.removeQuote(range); + this.replaceWithBlankLine(range); return this; } } @@ -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([