From: Alexander Ebert Date: Tue, 12 Dec 2017 10:25:28 +0000 (+0100) Subject: Fixed caret position on text insert X-Git-Tag: 3.1.0_Beta_5~39 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6c888e3e71fc07134a39b7240ad3d7e5e17cad68;p=GitHub%2FWoltLab%2FWCF.git Fixed caret position on text insert Fixes WoltLab/com.woltlab.gallery#55 --- 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); } };