From: Alexander Ebert Date: Tue, 23 Dec 2014 19:58:54 +0000 (+0100) Subject: Improved pasting of content during WYSIWYG mode X-Git-Tag: 2.1.0_Beta_3~94 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6ead8f5b6c3790b13f4a1d1fc8b39dfbf37f1f0f;p=GitHub%2FWoltLab%2FWCF.git Improved pasting of content during WYSIWYG mode This of course fails if a page has a completely messed up markup e.g. Spiegel Online, but I cannot fix the view for them without messing up the other. The current approach deals best with the average content encountered, if it encounters messy markup it follows the simple rule: Garbage in, Garbage out. --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 412098ec94..edf53ac67d 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -1125,7 +1125,7 @@ RedactorPlugins.wbbcode = function() { // replace nested elements e.g.

...

html = html.replace(/<(div|p)([^>]+)?><(div|p)([^>]+)?>/g, '

'); html = html.replace(/<\/(div|p)><\/(div|p)>/g, '

'); - html = html.replace(/<(div|p)>
<\/(div|p)>/g, '

'); + //html = html.replace(/<(div|p)>
<\/(div|p)>/g, '

'); WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'beforePaste', { html: html }); @@ -1140,7 +1140,7 @@ RedactorPlugins.wbbcode = function() { */ _pasteCallback: function(html) { // reduce successive
by one - html = html.replace(/]*>(]*>)+/g, '$1'); + //html = html.replace(/]*>(]*>)+/g, '$1'); // replace

...

with

...


/*html = html.replace(/

([\s\S]*?)<\/p>/g, function(match, content) { diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index fafd67b5d4..110bee2f5e 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -242,6 +242,11 @@ RedactorPlugins.wmonkeypatch = function() { return $restoreSpecialCharacters(html); }).bind(this); + // clean.onPasteRemoveEmpty + this.clean.onPasteRemoveEmpty = function(html) { + return html.replace(/$/i, ''); + }; + // clean.onSet var $mpOnSet = this.clean.onSet; this.clean.onSet = (function(html) {