From: Alexander Ebert Date: Thu, 4 Jun 2015 12:36:21 +0000 (+0200) Subject: Fixed incorrect removal of newlines on quote insert X-Git-Tag: 2.1.5~32 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6730380478b4da9427cc1a1f546271e2aac28126;p=GitHub%2FWoltLab%2FWCF.git Fixed incorrect removal of newlines on quote insert --- 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);