From 6ead8f5b6c3790b13f4a1d1fc8b39dfbf37f1f0f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 23 Dec 2014 20:58:54 +0100 Subject: [PATCH] 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. --- .../install/files/js/3rdParty/redactor/plugins/wbbcode.js | 4 ++-- .../files/js/3rdParty/redactor/plugins/wmonkeypatch.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) 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) { -- 2.20.1