From: Alexander Ebert Date: Sat, 7 Mar 2015 22:20:55 +0000 (+0100) Subject: Using our own range to determine cursor position (more reliable) X-Git-Tag: 2.1.2~79 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=08b2daeb616ec873cc73a6a8bcb9cecadb2aec59;p=GitHub%2FWoltLab%2FWCF.git Using our own range to determine cursor position (more reliable) --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 2824465d88..e80a5e1e46 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -790,26 +790,31 @@ RedactorPlugins.wutil = function() { * @return boolean */ isEndOfElement: function(element) { - this.selection.get(); + // prefer our range because it is more reliable + var $range = this.selection.implicitRange; + if ($range === null) { + this.selection.get(); + $range = this.range; + } // range is not a plain caret if (!this.wutil.isCaret()) { return false; } - if (this.range.endContainer.nodeType === Element.TEXT_NODE) { + if ($range.endContainer.nodeType === Element.TEXT_NODE) { // caret is not at the end - if (this.range.endOffset < this.range.endContainer.length) { + if ($range.endOffset < $range.endContainer.length) { return false; } } // range is not within the provided element - if (!this.wutil.isNodeWithin(this.range.endContainer, element)) { + if (!this.wutil.isNodeWithin($range.endContainer, element)) { return false; } - var $current = this.range.endContainer; + var $current = $range.endContainer; while ($current !== element) { // end of range is not the last element if ($current.nextSibling) {