From b4033a40e4c17e0f0d71623a792eb1caf02a0cf8 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 16 Nov 2016 12:14:26 +0100 Subject: [PATCH] Fix block formatting in Firefox w/o prior editor focus --- .../js/3rdParty/redactor2/plugins/WoltLabBlock.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js index 557e838662..3a240230bb 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js @@ -31,6 +31,21 @@ $.Redactor.prototype.WoltLabBlock = function() { var mpFormatCollapsed = this.block.formatCollapsed; this.block.formatCollapsed = (function(tag, attr, value, type) { + if (this.detect.isFirefox()) { + var editor = this.core.editor()[0]; + if (document.activeElement !== editor) { + this.selection.restore(); + + if (document.activeElement !== editor) { + editor.focus(); + } + } + + if (this.selection.block() === false) { + this.focus.end(); + } + } + var replaced = mpFormatCollapsed.call(this, tag, attr, value, type); for (var i = 0, length = replaced.length; i < length; i++) { -- 2.20.1