From a6b8595b0429bbc87f6b323c3f5451d905541f1b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 25 Jan 2017 17:59:03 +0100 Subject: [PATCH] Fixed incorrect range being restored --- .../files/js/3rdParty/redactor2/plugins/WoltLabCaret.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 850028ba14..01d2411bd7 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -141,7 +141,14 @@ $.Redactor.prototype.WoltLabCaret = function() { var mpSet = this.buffer.set; this.buffer.set = (function (type) { if (document.activeElement !== editor) { - restoreRange(); + // check if caret is still inside the editor + var selection = window.getSelection(); + if (selection.rangeCount && this.utils.isRedactorParent(selection.anchorNode) !== false) { + editor.focus(); + } + else { + restoreRange(); + } } mpSet.call(this, type); -- 2.20.1