From: Alexander Ebert Date: Mon, 5 Sep 2016 10:41:38 +0000 (+0200) Subject: Only add paragraph before/after block if there is none X-Git-Tag: 3.0.0_Beta_1~301 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=134dca8c58670774df90821e64abaa0738342c84;p=GitHub%2FWoltLab%2FWCF.git Only add paragraph before/after block if there is none --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 45ae8a2ac0..b108e5108b 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -171,10 +171,17 @@ $.Redactor.prototype.WoltLabCaret = function() { return; } - this.buffer.set(); - // click occurred onto the empty editor space, but before or after a block element var insertBefore = (event.clientY < block.getBoundingClientRect().top); + + // check if there is already a paragraph in place + var sibling = block[(insertBefore ? 'previous' : 'next') + 'ElementSibling']; + if (sibling && sibling.nodeName === 'P') { + return; + } + + this.buffer.set(); + var p = elCreate('p'); p.textContent = '\u200B'; block.parentNode.insertBefore(p, (insertBefore ? block : block.nextSibling));