From 72c43615c762558e340a9ad19901d18ba4e1a848 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 4 Jan 2018 19:58:01 +0100 Subject: [PATCH] Work-around for backspacing into a list in Firefox --- .../redactor2/plugins/WoltLabKeydown.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js index 4ef08424e3..24f2d0233a 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js @@ -86,6 +86,32 @@ $.Redactor.prototype.WoltLabKeydown = function() { } } + // Redactor's own work-around for backspacing in Firefox at the start of a block + // is flawed when the previous element is a list. Their current implementation + // inserts the content straight into the list element, rather than appending it + // to the last possible location inside a
  • . + if (e.which === this.keyCode.BACKSPACE && this.detect.isFirefox()) { + var block = this.selection.block(); + if (block && block.tagName === 'P' && this.utils.isStartOfElement(block)) { + var previousBlock = block.previousElementSibling; + if (previousBlock && (previousBlock.nodeName === 'OL' || previousBlock.nodeName === 'UL')) { + this.buffer.set(); + this.selection.save(); + + var listItem = previousBlock.lastElementChild; + while (block.childNodes.length) { + listItem.appendChild(block.childNodes[0]); + } + + elRemove(block); + this.selection.restore(); + + e.preventDefault(); + return; + } + } + } + var returnValue = mpInit.call(this, e); if (returnValue !== false && !e.originalEvent.defaultPrevented) { -- 2.20.1