Fixed handling of multiple editor instances
authorAlexander Ebert <ebert@woltlab.com>
Thu, 7 Sep 2017 10:47:50 +0000 (12:47 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 7 Sep 2017 10:47:50 +0000 (12:47 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabObserve.js

index 943eed8e4cd361c22f11ced58940af7c169b4042..8314670c69c89316ed9d3cf9629326dbd742a234 100644 (file)
@@ -83,32 +83,31 @@ $.Redactor.prototype.WoltLabObserve = function() {
                                var editor = this.$editor[0];
                                if (current.nodeType !== Node.ELEMENT_NODE) current = current.parentNode;
                                
-                               var 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]);
+                               if (current.closest('.redactor-layer') === editor) {
+                                       var 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]);
+                                                       }
+                                                       
+                                                       // mark as known
+                                                       tags.push(tagName);
                                                }
                                                
-                                               // mark as known
-                                               tags.push(tagName);
+                                               current = current.parentNode;
                                        }
-                                       
-                                       current = current.parentNode;
                                }
-                               
                        }).bind(this);
                        
                        this.observe.dropdowns = (function() {
                                var current = this.selection.current();
+                               if (current && current.nodeType !== Node.ELEMENT_NODE) current = current.parentNode;
                                var editor = this.$editor[0];
-                               var isRedactor = this.utils.isRedactorParent(current);
                                
                                var tagName, tags = [];
-                               if (current && isRedactor) {
-                                       if (current.nodeType !== Node.ELEMENT_NODE) current = current.parentNode;
-                                       
+                               if (current && current.closest('.redactor-layer') === editor) {
                                        while (current !== editor) {
                                                tagName = current.nodeName.toLowerCase();
                                                if (tags.indexOf(tagName) === -1) {