From: Alexander Ebert Date: Mon, 28 Jul 2014 13:43:20 +0000 (+0200) Subject: Added visual representation of [tt] X-Git-Tag: 2.1.0_Alpha_1~513 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fc03cf6e8bdf86e372f4e7eb4134e3ba89b12279;p=GitHub%2FWoltLab%2FWCF.git Added visual representation of [tt] --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js index 19338cb0ff..86ecd7f39b 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js @@ -113,8 +113,22 @@ RedactorPlugins.wbutton = { _insertBBCode: function(buttonName, buttonDOM, buttonObj, event) { var $bbcode = this._bbcodes[buttonName]; var $selectedHtml = this.getSelectionHtml(); - this.insertHtml('[' + $bbcode + ']' + $selectedHtml + '[/' + $bbcode + ']'); - this.sync(); + if ($bbcode === 'tt') { + var $parent = (this.getParent()) ? $(this.getParent()) : null; + if ($parent && $parent.closest('inline.inlineCode', this.$editor.get()[0]).length) { + this.inlineRemoveClass('inlineCode'); + } + else { + this.inlineSetClass('inlineCode'); + } + } + else { + this.insertHtml('[' + $bbcode + ']' + $selectedHtml + '[/' + $bbcode + ']'); + this.sync(); + } + + event.preventDefault(); + return false; } }; diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 8a9df2a7d7..e7d407c903 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -113,10 +113,8 @@ RedactorPlugins.wmonkeypatch = { if (parent && parent.closest('inline.inlineCode', this.$editor.get()[0]).length != 0) { this.$toolbar.find('a.re-__wcf_tt').addClass('redactor_act'); - console.debug("adding"); } else { - console.debug("removing"); this.$toolbar.find('a.re-__wcf_tt').removeClass('redactor_act'); } }, @@ -149,6 +147,67 @@ RedactorPlugins.wmonkeypatch = { this.sync(); }, + /** + * Overwrites $.Redactor.inlineMethods() to fix calls to inlineSetClass(). + * + * @see $.Redactor.inlineMethods() + * @param string type + * @param string attr + * @param string value + */ + inlineMethods: function(type, attr, value) { + this.bufferSet(); + this.selectionSave(); + + var range = this.getRange(); + var el = this.getElement(); + + if ((range.collapsed || range.startContainer === range.endContainer) && el && !this.nodeTestBlocks(el)) + { + $(el)[type](attr, value); + } + else + { + var cmd, arg = value; + switch (attr) + { + case 'font-size': + cmd = 'fontSize'; + arg = 4; + break; + case 'font-family': + cmd = 'fontName'; + break; + case 'color': + cmd = 'foreColor'; + break; + case 'background-color': + cmd = 'backColor'; + break; + } + + // WoltLab modifications START + if (type === 'addClass') { + cmd = 'fontSize'; + arg = 4; + } + // WoltLab modifications END + + this.document.execCommand(cmd, false, arg); + + var fonts = this.$editor.find('font'); + $.each(fonts, $.proxy(function(i, s) + { + this.inlineSetMethods(type, s, attr, value); + + }, this)); + + } + + this.selectionRestore(); + this.sync(); + }, + /** * Drops the indentation if not within a list. *