From 5b888dc6446b86fa3cac2f6a794a55d78c7ce5c3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 28 Aug 2016 17:38:03 +0200 Subject: [PATCH] Fixed check for empty paragraph after insert --- .../redactor2/plugins/WoltLabInsert.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js index 4d4003b4de..f28d1c5eee 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js @@ -17,10 +17,20 @@ $.Redactor.prototype.WoltLabInsert = function() { mpHtml.call(this, html, data); - if (block && block.nodeName === 'P' && block.nextElementSibling && !block.childElementCount && block.textContent.replace(/\u200B/g, '').trim() === '') { - // inserting HTML tends to cause new paragraphs inserted - // rather than using the current, empty one - elRemove(block); + if (block && block.nodeName === 'P' && block.nextElementSibling) { + var removeBlock = false; + if (block.childElementCount === 0 && block.textContent.replace(/\u200B/g, '').trim() === '') { + removeBlock = true; + } + else if (block.childElementCount === 1 && block.innerHTML === '
') { + removeBlock = true; + } + + if (removeBlock) { + // inserting HTML tends to cause new paragraphs inserted + // rather than using the current, empty one + elRemove(block); + } } }).bind(this); -- 2.20.1