From dd2250552181729a5e910f2c1c249ad52c287c4e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 8 Sep 2016 18:26:33 +0200 Subject: [PATCH] Fixed backspace behavior for last block that is not a paragraph --- .../3rdParty/redactor2/plugins/WoltLabKeydown.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 -- 2.20.1