From 6730380478b4da9427cc1a1f546271e2aac28126 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 4 Jun 2015 14:36:21 +0200 Subject: [PATCH] Fixed incorrect removal of newlines on quote insert --- .../js/3rdParty/redactor/plugins/wbbcode.js | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 8ad7b8ef20..63e9cfabf4 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -2148,7 +2148,12 @@ RedactorPlugins.wbbcode = function() { if ($current && $current.parentNode === this.$editor[0]) { if ($current.innerHTML.length) { - this.wutil.setCaretAfter($current); + if ($current.innerHTML === '\u200b') { + this.caret.setEnd($current); + } + else { + this.wutil.setCaretAfter($current); + } } } @@ -2174,6 +2179,15 @@ RedactorPlugins.wbbcode = function() { $quote.removeAttr('id'); this.wutil.setCaretAfter($quote[0]); + + // inserting a quote can spawn an additional empty newline in front + var prev = $quote[0].previousElementSibling; + if (prev !== null && prev.nodeName === 'P' && prev.innerHTML === '\u200B') { + prev = prev.previousElementSibling; + if (prev !== null && prev.nodeName === 'P' && (prev.innerHTML === '\u200B' || prev.innerHTML === '
')) { + prev.parentNode.removeChild(prev.nextElementSibling); + } + } } this.wbbcode.observeQuotes(); @@ -2373,12 +2387,12 @@ RedactorPlugins.wbbcode = function() { if (!$sibling.innerHTML.length) { $sibling.parentElement.removeChild($sibling); } - else if ($sibling.innerHTML === '\u200b') { + /*else if ($sibling.innerHTML === '\u200b') { var $adjacentSibling = $sibling[position]; if ($adjacentSibling && $adjacentSibling.nodeType === Node.ELEMENT_NODE && $adjacentSibling.tagName === 'P' && $adjacentSibling.innerHTML.length) { $sibling.parentElement.removeChild($sibling); } - } + }*/ } }).bind(this); -- 2.20.1