From afbd3fb6c2fbf68b63627c3b3d5b2afdfdfc2387 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 8 Jun 2018 18:38:31 +0200 Subject: [PATCH] Firefox sometimes includes the editor itself in the selection --- .../redactor2/plugins/WoltLabBlock.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js index cc5dd5563b..ffa6ea6d50 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js @@ -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) { -- 2.20.1