* @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]';
}
},
tt: 'kbd',
// callback replacement
+ align: this._convertAlignment.bind(this),
attach: this._convertAttachment.bind(this),
color: this._convertColor.bind(this),
code: this._convertCode.bind(this),
}
},
+ /**
+ * Converts [align] into <div style="text-align: ...">.
+ *
+ * @param {array<mixed>} 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 ['<div style="text-align: ' + align + '">', '</div>'];
+ },
+
/**
* Converts [attach] into an <img> or to plain text if attachment is a non-image.
*