Fix for direct DOM manipulation
authorAlexander Ebert <ebert@woltlab.com>
Sat, 9 Dec 2017 23:56:04 +0000 (00:56 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 9 Dec 2017 23:56:09 +0000 (00:56 +0100)
Editing the DOM ourselves caused Redactor's internal selection to be
out-of-sync with the document.

wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js

index 475dfb0c5d6b52e06c5f5147d2c1948ded5987ca..95d57c2cfadabe06249122408992f7a354e404da 100644 (file)
@@ -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;
                                
index 3704e64653a2f0a2db5988b1c87c50e87d8b2206..62a6815fb7d781d3d0e30080270763cebe776490 100644 (file)
@@ -34,6 +34,9 @@ $.Redactor.prototype.WoltLabSmiley = function() {
                        
                        //noinspection SillyAssignmentJS
                        smiley.outerHTML = smiley.outerHTML;
+                       
+                       // force-save the caret position
+                       this.WoltLabCaret.forceSelectionSave();
                }
        }
 };