From: Alexander Ebert Date: Thu, 20 Oct 2016 11:11:44 +0000 (+0200) Subject: Improved pasting X-Git-Tag: 3.0.0_Beta_3~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d273c3c42753d639705b38b239d7e558dbd37ed7;p=GitHub%2FWoltLab%2FWCF.git Improved pasting --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index 38346dcc00..6d30544dad 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -133,7 +133,41 @@ $.Redactor.prototype.WoltLabClean = function() { } }); - return mpOnPaste.call(this, div.innerHTML, data, insert); + elBySelAll('br', div, function (br) { + br.parentNode.insertBefore(document.createTextNode('@@@WOLTLAB-BR-MARKER@@@'), br); + }); + + html = mpOnPaste.call(this, div.innerHTML, data, insert); + + html = html.replace(/@@@WOLTLAB-BR-MARKER@@@/g, ''); + + div.innerHTML = html; + + elBySelAll('woltlab-br-marker', div, function (marker) { + var parent = marker.parentNode; + + if (parent.nodeName === 'P') { + var p = elCreate('p'); + while (marker.nextSibling) { + p.appendChild(marker.nextSibling); + } + p.appendChild(elCreate('br')); + + parent.parentNode.insertBefore(p, parent.nextSibling); + + var previous = marker.previousElementSibling; + if (previous && previous.nodeName === 'BR') { + elRemove(previous); + } + } + else { + parent.insertBefore(elCreate('br'), marker); + } + + elRemove(marker); + }); + + return div.innerHTML; }).bind(this); var storage = [];