From dae4675183a6f246656f345eac86ae1dc804769c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 19 Sep 2014 16:26:05 +0200 Subject: [PATCH] Fixed handling of floating attachments --- .../js/3rdParty/redactor/plugins/wbbcode.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 086e1d6f14..96a9a142e7 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -287,7 +287,13 @@ RedactorPlugins.wbbcode = { html = html.replace(/]*?class="smiley" alt="([^"]+?)".*?> ?/gi, '$1 '); // chrome, ie // attachments - html = html.replace(/]*?class="redactorEmbeddedAttachment" data-attachment-id="(\d+)".*?>/gi, '[attach=$1][/attach]'); + html = html.replace(/]*?class="redactorEmbeddedAttachment" data-attachment-id="(\d+)"( style="float: (left|right)")?>/gi, function(match, attachmentID, styleTag, alignment) { + if (alignment) { + return '[attach=' + attachmentID + ',' + alignment + '][/attach]'; + } + + return '[attach=' + attachmentID + '][/attach]'; + }); // [img] html = html.replace(/]*?src=(["'])([^"']+?)\1 style="float: (left|right)[^"]*".*?>/gi, "[img='$2',$3][/img]"); @@ -588,11 +594,18 @@ RedactorPlugins.wbbcode = { if ($attachmentUrl) { var $imageAttachmentIDs = this._getImageAttachmentIDs(); - data = data.replace(/\[attach=(\d+)\]\[\/attach\]/g, function(match, attachmentID) { + data = data.replace(/\[attach=(\d+)(,[^\]]*)?\]\[\/attach\]/g, function(match, attachmentID, alignment) { attachmentID = parseInt(attachmentID); if (WCF.inArray(attachmentID, $imageAttachmentIDs)) { - return ''; + var $style = ''; + if (alignment) { + if (alignment.match(/^,'?(left|right)'?/)) { + $style = ' style="float: ' + RegExp.$1 + '"'; + } + } + + return ''; } return match; -- 2.20.1