From: Alexander Ebert Date: Thu, 9 Jun 2016 16:35:32 +0000 (+0200) Subject: Added basic support for code bbcode (WIP!) X-Git-Tag: 3.0.0_Beta_1~1470 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=97f8f467d833ea9108f8a8f417a58ff9864914f5;p=GitHub%2FWoltLab%2FWCF.git Added basic support for code bbcode (WIP!) --- diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index 919ccdb602..52bc64755c 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -20,6 +20,7 @@ {* WoltLab *} '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabAttachment.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabButton.js?v={@LAST_UPDATE_TIME}', + '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabCode.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabColor.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabDropdown.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabEvent.js?v={@LAST_UPDATE_TIME}', @@ -73,6 +74,7 @@ 'source', 'table', 'WoltLabAttachment', + 'WoltLabCode', 'WoltLabColor', 'WoltLabDropdown', 'WoltLabEvent', diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js new file mode 100644 index 0000000000..a39af3d664 --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js @@ -0,0 +1,28 @@ +$.Redactor.prototype.WoltLabCode = function() { + "use strict"; + + return { + init: function() { + this.opts.activeButtonsStates.pre = 'code'; + + require(['EventHandler'], (function (EventHandler) { + EventHandler.add('com.woltlab.wcf.redactor2', 'bbcode_code_' + this.$element[0].id, (function(data) { + data.cancel = true; + + this.button.toggle({}, 'pre', 'func', 'block.format'); + + var pre = this.selection.block(); + if (pre && pre.nodeName === 'PRE') { + if (pre.textContent === '') { + pre.textContent = '\u200B'; + } + + if (elData(pre, 'display-value') === '') { + elData(pre, 'display-value', 'TODO: source code'); + } + } + }).bind(this)); + }).bind(this)); + } + }; +}; diff --git a/wcfsetup/install/files/style/bbcode/code.scss b/wcfsetup/install/files/style/bbcode/code.scss new file mode 100644 index 0000000000..92e47e73a0 --- /dev/null +++ b/wcfsetup/install/files/style/bbcode/code.scss @@ -0,0 +1,20 @@ +.redactor-editor pre { + background-color: rgb(255, 255, 255) !important; + border: 1px solid rgb(196, 196, 196) !important; + border-radius: 2px; + color: rgb(68, 68, 68) !important; + font-family: Consolas, 'Courier New', monospace; + margin: 1em 0; + padding: 10px 20px; + position: relative; + white-space: pre; + + &::before { + content: attr(data-display-value); + display: block; + font-family: $wcfFontFamily; + margin-bottom: 20px; + + @include wcfFontHeadline; + } +}