Fixed selection sometimes returning the editor itself
authorAlexander Ebert <ebert@woltlab.com>
Fri, 5 May 2017 16:54:05 +0000 (18:54 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 5 May 2017 16:54:12 +0000 (18:54 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js

index 42db675fca95aeaaa2d496e8893d303d05e26484..e7451f28f6ff7ffe611db2cf56209dc58bb0c37d 100644 (file)
@@ -49,6 +49,19 @@ $.Redactor.prototype.WoltLabCaret = function() {
                                return mpEnd.call(this, node);
                        }).bind(this);
                        
+                       var mpSelectionNodes = this.selection.nodes;
+                       this.selection.nodes = (function (tag) {
+                               var returnValues = mpSelectionNodes.call(this, tag);
+                               if (returnValues.length === 1 && returnValues[0] === this.$editor[0]) {
+                                       var range = this.selection.range(this.selection.get());
+                                       if (range.startContainer === range.endContainer) {
+                                               return [range.startContainer];
+                                       }
+                               }
+                               
+                               return returnValues;
+                       }).bind(this);
+                       
                        this.$editor[0].addEventListener(WCF_CLICK_EVENT, this.WoltLabCaret._handleEditorClick.bind(this));
                        
                        this.WoltLabCaret._initInternalRange();