From 6c888e3e71fc07134a39b7240ad3d7e5e17cad68 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 12 Dec 2017 11:25:28 +0100 Subject: [PATCH] Fixed caret position on text insert Fixes WoltLab/com.woltlab.gallery#55 --- .../files/js/3rdParty/redactor2/plugins/WoltLabInsert.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js index 55a948cd61..a3f181599e 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js @@ -67,7 +67,16 @@ $.Redactor.prototype.WoltLabInsert = function() { this.insert.text = (function (text) { if (callback) callback = callback(); + this.core.editor().focus(); + this.selection.restore(); + if (elClosest(window.getSelection().anchorNode, '.redactor-layer') !== this.core.editor()[0]) { + this.WoltLabCaret.endOfEditor(); + console.log("fixed selection"); + } + mpText.call(this, text); + + this.selection.saveInstant(); }).bind(this); } }; -- 2.20.1