From a5d3c68c0c81fcf99557000abdc3b962a8d48ea7 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 6 Oct 2016 10:03:55 +0200 Subject: [PATCH] Fixed \u200B handling --- .../redactor2/plugins/WoltLabClean.js | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index 4f287512bf..c997ede8d2 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -33,20 +33,33 @@ $.Redactor.prototype.WoltLabClean = function() { var mpOnSync = this.clean.onSync; this.clean.onSync = (function (html) { var div = elCreate('div'); + div.innerHTML = html; var replacements = {}; - if (html.indexOf(' with trailing `
\u200B` + elBySelAll('p', div, function (p) { + var br = p.lastElementChild; + if (br && br.nodeName === 'BR') { + // check if there is only whitespace afterwards + if (br.nextSibling && br.nextSibling.textContent.match(/^[\s\u200B]+$/)) { + var newP = elCreate('p'); + newP.innerHTML = '
'; + p.parentNode.insertBefore(newP, p.nextSibling); + + p.removeChild(br.nextSibling); + p.removeChild(br); + } + } + }); + + html = div.innerHTML; html = html.replace(/

\u200B<\/p>/g, '


'); -- 2.20.1