From 134dca8c58670774df90821e64abaa0738342c84 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 5 Sep 2016 12:41:38 +0200 Subject: [PATCH] Only add paragraph before/after block if there is none --- .../js/3rdParty/redactor2/plugins/WoltLabCaret.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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)); -- 2.20.1