From ce1e635fcbfe2ab558e97a691475426738f9a046 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 18 Dec 2014 13:57:12 +0100 Subject: [PATCH] Moved image handling further down to avoid required whitespaces chopped of --- .../js/3rdParty/redactor/plugins/wbbcode.js | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index e5e4ddc9e2..c2e85cb90a 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -355,66 +355,6 @@ RedactorPlugins.wbbcode = function() { html = html.replace(/<(?:s(trike)?|del)>/gi, '[s]'); html = html.replace(/<\/(?:s(trike)?|del)>/gi, '[/s]'); - // smileys - html = html.replace(/]*?alt="([^"]+?)" class="smiley".*?> ?/gi, '$1 '); // firefox - html = html.replace(/]*?class="smiley" alt="([^"]+?)".*?> ?/gi, '$1 '); // chrome, ie - - // attachments - html = html.replace(/]*?class="redactorEmbeddedAttachment[^"]*" data-attachment-id="(\d+)"( style="([^"]+)")?>/gi, function(match, attachmentID, styleTag, style) { - var $float = 'none'; - var $width = null; - - if (style) { - style = style.split(';'); - - for (var $i = 0; $i < style.length; $i++) { - var $style = $.trim(style[$i]); - if ($style.match(/^float: (left|right)$/)) { - $float = RegExp.$1; - } - else if ($style.match(/^width: (\d+)px$/)) { - $width = RegExp.$1; - } - } - - if ($width !== null) { - return '[attach=' + attachmentID + ',' + $float + ',' + $width + '][/attach]'; - } - else if ($float !== 'none') { - return '[attach=' + attachmentID + ',' + $float + '][/attach]'; - } - } - - return '[attach=' + attachmentID + '][/attach]'; - }); - - // [img] - html = html.replace(/]*?src=(["'])([^"']+?)\1 style="([^"]+)".*?>/gi, function(match, quotationMarks, source, style) { - var $float = 'none'; - var $width = 0; - - var $styles = style.split(';'); - for (var $i = 0; $i < $styles.length; $i++) { - var $style = $styles[$i]; - if ($style.match(/float: (left|right|none)/)) { - $float = RegExp.$1; - } - else if ($style.match(/width: (\d+)px/)) { - $width = parseInt(RegExp.$1); - } - } - - if ($width) { - return "[img='" + source + "'," + $float + "," + $width + "][/img]"; - } - else if ($float !== 'none') { - return "[img='" + source + "'," + $float + "][/img]"; - } - - return "[img]" + source + "[/img]"; - }); - html = html.replace(/]*?src=(["'])([^"']+?)\1.*?>/gi, '[img]$2[/img]'); - // handle [color], [size], [font] and [tt] var $components = html.split(/(<\/?span[^>]*>)/); @@ -532,6 +472,66 @@ RedactorPlugins.wbbcode = function() { return '[align=' + alignment + ']' + $.trim(content) + '[/align]'; }); + // smileys + html = html.replace(/]*?alt="([^"]+?)" class="smiley".*?> ?/gi, '$1 '); // firefox + html = html.replace(/]*?class="smiley" alt="([^"]+?)".*?> ?/gi, '$1 '); // chrome, ie + + // attachments + html = html.replace(/]*?class="redactorEmbeddedAttachment[^"]*" data-attachment-id="(\d+)"( style="([^"]+)")?>/gi, function(match, attachmentID, styleTag, style) { + var $float = 'none'; + var $width = null; + + if (style) { + style = style.split(';'); + + for (var $i = 0; $i < style.length; $i++) { + var $style = $.trim(style[$i]); + if ($style.match(/^float: (left|right)$/)) { + $float = RegExp.$1; + } + else if ($style.match(/^width: (\d+)px$/)) { + $width = RegExp.$1; + } + } + + if ($width !== null) { + return '[attach=' + attachmentID + ',' + $float + ',' + $width + '][/attach]'; + } + else if ($float !== 'none') { + return '[attach=' + attachmentID + ',' + $float + '][/attach]'; + } + } + + return '[attach=' + attachmentID + '][/attach]'; + }); + + // [img] + html = html.replace(/]*?src=(["'])([^"']+?)\1 style="([^"]+)".*?>/gi, function(match, quotationMarks, source, style) { + var $float = 'none'; + var $width = 0; + + var $styles = style.split(';'); + for (var $i = 0; $i < $styles.length; $i++) { + var $style = $styles[$i]; + if ($style.match(/float: (left|right|none)/)) { + $float = RegExp.$1; + } + else if ($style.match(/width: (\d+)px/)) { + $width = parseInt(RegExp.$1); + } + } + + if ($width) { + return "[img='" + source + "'," + $float + "," + $width + "][/img]"; + } + else if ($float !== 'none') { + return "[img='" + source + "'," + $float + "][/img]"; + } + + return "[img]" + source + "[/img]"; + }); + html = html.replace(/]*?src=(["'])([^"']+?)\1.*?>/gi, '[img]$2[/img]'); + // [*] html = html.replace(/
  • /gi, '[*]'); html = html.replace(/<\/li>/gi, ''); -- 2.20.1