Adjusted active button states for code/html
authorAlexander Ebert <ebert@woltlab.com>
Tue, 13 Jun 2017 14:59:26 +0000 (16:59 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 13 Jun 2017 14:59:26 +0000 (16:59 +0200)
See #2301

wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabObserve.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Html.js

index 943eed8e4cd361c22f11ced58940af7c169b4042..f91ff3fc5fabce4900a75b111d43041d7dafb4af 100644 (file)
@@ -69,11 +69,13 @@ $.Redactor.prototype.WoltLabObserve = function() {
                                if (this.utils.isCurrentOrParent(['table', 'li'])) {
                                        this.button.disable('code');
                                        this.button.disable('spoiler');
+                                       this.button.disable('woltlabHtml');
                                        this.button.disable('woltlabQuote');
                                }
                                else if (!isSource) {
                                        this.button.enable('code');
                                        this.button.enable('spoiler');
+                                       this.button.enable('woltlabHtml');
                                        this.button.enable('woltlabQuote');
                                }
                                
@@ -83,16 +85,21 @@ $.Redactor.prototype.WoltLabObserve = function() {
                                var editor = this.$editor[0];
                                if (current.nodeType !== Node.ELEMENT_NODE) current = current.parentNode;
                                
-                               var tagName, tags = [];
+                               var key, tagName, tags = [];
                                while (current !== editor) {
                                        tagName = current.nodeName.toLowerCase();
                                        if (tags.indexOf(tagName) === -1) {
-                                               if (this.opts.activeButtonsStates.hasOwnProperty(tagName)) {
-                                                       this.button.setActive(this.opts.activeButtonsStates[tagName]);
+                                               key = tagName;
+                                               if (tagName === 'pre' && current.classList.contains('woltlabHtml')) {
+                                                       key = 'woltlab-html';
+                                               }
+                                               
+                                               if (this.opts.activeButtonsStates.hasOwnProperty(key)) {
+                                                       this.button.setActive(this.opts.activeButtonsStates[key]);
                                                }
                                                
                                                // mark as known
-                                               tags.push(tagName);
+                                               if (tagName !== 'pre') tags.push(tagName);
                                        }
                                        
                                        current = current.parentNode;
index 4a2f821059923441e1354f061e0af440460ff84c..767a48096199da08fc3f49cda67dcdb5c036c844 100644 (file)
@@ -46,7 +46,7 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                        EventHandler.add('com.woltlab.wcf.redactor2', 'observe_load_' + this._elementId, this._observeLoad.bind(this));
                        
                        // support for active button marking
-                       this._editor.opts.activeButtonsStates['pre-html'] = 'code';
+                       this._editor.opts.activeButtonsStates['woltlab-html'] = 'woltlabHtml';
                        
                        // static bind to ensure that removing works
                        this._callbackEdit = this._edit.bind(this);