From cbc0a8a57e570d8d1882944ab73152b797c7a421 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 19 Dec 2016 13:53:01 +0100 Subject: [PATCH] Fixed nested formating --- .../3rdParty/redactor2/plugins/WoltLabClean.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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; -- 2.20.1