From: Alexander Ebert Date: Wed, 8 Jul 2015 09:11:42 +0000 (+0200) Subject: Fixed handling of [align]-BBCode X-Git-Tag: 3.0.0_Beta_1~2211 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d979d7689b391771f6ea6f8dff57a1a9a655f9ac;p=GitHub%2FWoltLab%2FWCF.git Fixed handling of [align]-BBCode --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/BBCode/FromHtml.js b/wcfsetup/install/files/js/WoltLab/WCF/BBCode/FromHtml.js index 34c7ecbd94..9745f1862e 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/BBCode/FromHtml.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/BBCode/FromHtml.js @@ -466,8 +466,8 @@ define(['EventHandler', 'StringUtil', 'DOM/Traverse'], function(EventHandler, St * @param {Element} element target element */ _convertInlineTextAlign: function(element, value) { - if (value === 'left' || value === 'right' || value === 'justify') { - element.innerHTML = '[align=' + value + ']' + innerHTML + '[/align]'; + if (['center', 'justify', 'left', 'right'].indexOf(value) !== -1) { + element.innerHTML = '[align=' + value + ']' + element.innerHTML + '[/align]'; } }, diff --git a/wcfsetup/install/files/js/WoltLab/WCF/BBCode/ToHtml.js b/wcfsetup/install/files/js/WoltLab/WCF/BBCode/ToHtml.js index b77d9308bf..399d2eb5b4 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/BBCode/ToHtml.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/BBCode/ToHtml.js @@ -135,6 +135,7 @@ define(['Core', 'EventHandler', 'Language', 'StringUtil', 'WoltLab/WCF/BBCode/Pa tt: 'kbd', // callback replacement + align: this._convertAlignment.bind(this), attach: this._convertAttachment.bind(this), color: this._convertColor.bind(this), code: this._convertCode.bind(this), @@ -212,6 +213,23 @@ define(['Core', 'EventHandler', 'Language', 'StringUtil', 'WoltLab/WCF/BBCode/Pa } }, + /** + * Converts [align] into
. + * + * @param {array} stack linear list of BBCode tags and regular strings + * @param {object} item current BBCode tag object + * @param {integer} index current stack index representing `item` + * @returns {array} first item represents the opening tag, the second the closing one + */ + _convertAlignment: function(stack, item, index) { + var align = (item.attributes.length) ? item.attributes[0] : ''; + if (['center', 'justify', 'left', 'right'].indexOf(align) === -1) { + return [null, null]; + } + + return ['
', '
']; + }, + /** * Converts [attach] into an or to plain text if attachment is a non-image. *