Firefox sometimes includes the editor itself in the selection
authorAlexander Ebert <ebert@woltlab.com>
Fri, 8 Jun 2018 16:38:31 +0000 (18:38 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 8 Jun 2018 16:38:31 +0000 (18:38 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js

index cc5dd5563b66e5d328c07647292e30236d5ea8f4..ffa6ea6d5007f8155ab9aa7f3214cc9070a7e5aa 100644 (file)
@@ -138,6 +138,26 @@ $.Redactor.prototype.WoltLabBlock = function() {
                                
                                return returned;
                        }).bind(this);
+                       
+                       this.block.getBlocks = (function(block) {
+                               block = (typeof block === 'undefined') ? this.selection.blocks() : block;
+                               
+                               // Firefox may add the editor itself to the selection
+                               if ($(block).hasClass('redactor-box') || $(block).hasClass('redactor-layer')) {
+                                       var blocks = [];
+                                       var nodes = this.core.editor().children();
+                                       $.each(nodes, $.proxy(function (i, node) {
+                                               if (this.utils.isBlock(node)) {
+                                                       blocks.push(node);
+                                               }
+                                               
+                                       }, this));
+                                       
+                                       return blocks;
+                               }
+                               
+                               return block
+                       }).bind(this);
                },
                
                register: function(tag, arrowKeySupport) {