From 9d9d8ea3166b67d6c71229aa41f401bda2fec598 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 5 May 2017 18:54:05 +0200 Subject: [PATCH] Fixed selection sometimes returning the editor itself --- .../js/3rdParty/redactor2/plugins/WoltLabCaret.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 42db675fca..e7451f28f6 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -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(); -- 2.20.1