From: Alexander Ebert Date: Thu, 8 Sep 2016 16:26:33 +0000 (+0200) Subject: Fixed backspace behavior for last block that is not a paragraph X-Git-Tag: 3.0.0_Beta_1~257 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dd2250552181729a5e910f2c1c249ad52c287c4e;p=GitHub%2FWoltLab%2FWCF.git Fixed backspace behavior for last block that is not a paragraph --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js index 06572bc74f..e0a6f94172 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js @@ -180,6 +180,21 @@ $.Redactor.prototype.WoltLabKeydown = function() { return mpOnTab.call(this, e, key); }).bind(this); + var mpFormatEmpty = this.keydown.formatEmpty; + this.keydown.formatEmpty = (function (e) { + // check if there are block elements other than

+ var editor = this.$editor[0], node; + for (var i = 0, length = editor.childElementCount; i < length; i++) { + node = editor.children[i]; + if (node.nodeName !== 'P' && this.utils.isBlockTag(node.nodeName)) { + // there is at least one block element, treat as non-empty + return; + } + } + + return mpFormatEmpty.call(this, e); + }).bind(this); + require(['Core', 'Environment'], (function (Core, Environment) { if (Environment.platform() !== 'desktop') { // ignore mobile devices