From: Alexander Ebert Date: Mon, 19 Dec 2016 12:53:01 +0000 (+0100) Subject: Fixed nested formating X-Git-Tag: 3.0.0_RC_2~18 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cbc0a8a57e570d8d1882944ab73152b797c7a421;p=GitHub%2FWoltLab%2FWCF.git Fixed nested formating --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index 26cf5ccc88..8747166532 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -152,6 +152,10 @@ $.Redactor.prototype.WoltLabClean = function() { else if (p.className.match(/\btext-(left|right|center|justify)\b/)) { p.insertBefore(document.createTextNode('@@@WOLTLAB-P-ALIGN-' + RegExp.$1 + '@@@'), p.firstChild); } + + // discard classes and styles, they're stripped later on anyway + p.className = ''; + p.removeAttribute('style'); }); elBySelAll('br', div, function (br) { @@ -237,7 +241,17 @@ $.Redactor.prototype.WoltLabClean = function() { }); storage.forEach(function (item, i) { - item.element.outerHTML = '###custom' + i + '###' + item.element.innerHTML + '###/custom' + i + '###'; + var element = item.element; + var parent = element.parentNode; + + parent.insertBefore(document.createTextNode('###custom' + i + '###'), element); + parent.insertBefore(document.createTextNode('###/custom' + i + '###'), element.nextSibling); + + while (element.childNodes.length) { + parent.insertBefore(element.childNodes[0], element); + } + + parent.removeChild(element); }); var hadLinks = false;