From ac430c1fed7a83bb30a0faefef48df7b008c9a01 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 30 Dec 2014 00:21:39 +0100 Subject: [PATCH] Added support for void BBCodes --- .../js/3rdParty/redactor/plugins/wbutton.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js index 3694b5e4b1..a90f2f774a 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js @@ -121,7 +121,10 @@ RedactorPlugins.wbutton = function() { var $button = this.button.add($buttonName, data.label); this.button.addCallback($button, this.wbutton._insertBBCode); - this._bbcodes[$buttonName] = data.name; + this._bbcodes[$buttonName] = { + name: data.name, + voidElement: (data.voidElement === true) + }; // FontAwesome class name if (data.icon.match(/^fa\-[a-z\-]+$/)) { @@ -139,7 +142,7 @@ RedactorPlugins.wbutton = function() { * @param string buttonName */ _insertBBCode: function(buttonName) { - var $bbcode = this._bbcodes[buttonName]; + var $bbcode = this._bbcodes[buttonName].name; var $eventData = { buttonName: buttonName, cancel: false @@ -162,7 +165,14 @@ RedactorPlugins.wbutton = function() { } else { this.buffer.set(); - this.insert.html('[' + $bbcode + ']' + $selectedHtml + this.selection.getMarkerAsHtml() + '[/' + $bbcode + ']', false); + + if (this._bbcodes[buttonName].voidElement) { + this.insert.html($selectedHtml + this.selection.getMarkerAsHtml() + '[' + $bbcode + ']', false); + } + else { + this.insert.html('[' + $bbcode + ']' + $selectedHtml + this.selection.getMarkerAsHtml() + '[/' + $bbcode + ']', false); + } + this.selection.restore(); } } -- 2.20.1