From: Alexander Ebert Date: Sat, 9 Dec 2017 23:56:04 +0000 (+0100) Subject: Fix for direct DOM manipulation X-Git-Tag: 3.1.0_Beta_4~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bc8750dc11ac47d0fb6789a711525582c9c483bf;p=GitHub%2FWoltLab%2FWCF.git Fix for direct DOM manipulation Editing the DOM ourselves caused Redactor's internal selection to be out-of-sync with the document. --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 475dfb0c5d..95d57c2cfa 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -179,6 +179,8 @@ $.Redactor.prototype.WoltLabCaret = function() { internalRange = (selection.rangeCount) ? selection.getRangeAt(0).cloneRange() : null; }; + this.WoltLabCaret.forceSelectionSave = saveRange; + var restoreRange = function () { if (internalRange === null) return; diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js index 3704e64653..62a6815fb7 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js @@ -34,6 +34,9 @@ $.Redactor.prototype.WoltLabSmiley = function() { //noinspection SillyAssignmentJS smiley.outerHTML = smiley.outerHTML; + + // force-save the caret position + this.WoltLabCaret.forceSelectionSave(); } } };