Skip to content

Commit bed4605

Browse files
committed
Clear field entirely with backspace/delete
1 parent 4ba4fff commit bed4605

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/js/core.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@
178178
// Firefox thrown an error when calling `formatBlock` on an empty editable blockContainer that's not a <div>
179179
if (MediumEditor.util.isMediumEditorElement(node) && node.children.length === 0 && !MediumEditor.util.isBlockContainer(node)) {
180180
this.options.ownerDocument.execCommand('formatBlock', false, 'p');
181+
182+
// https://github.com/yabwe/medium-editor/issues/1350
183+
// Pressing backspace/delete once more on an already empty field will clear it entirely
184+
if (MediumEditor.util.isKey(event, [MediumEditor.util.keyCode.DELETE, MediumEditor.util.keyCode.BACKSPACE])) {
185+
this.setContent(null);
186+
}
181187
}
182188

183189
// https://github.com/yabwe/medium-editor/issues/834

0 commit comments

Comments
 (0)