Fixed incorrect range being restored
authorAlexander Ebert <ebert@woltlab.com>
Wed, 25 Jan 2017 16:59:03 +0000 (17:59 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 25 Jan 2017 16:59:09 +0000 (17:59 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js

index 850028ba1439adf53353a66dadc1b09933bdb018..01d2411bd78c0a1e12ef85f40086297d1f6df07a 100644 (file)
@@ -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);