From: Alexander Ebert Date: Tue, 24 Feb 2015 16:52:58 +0000 (+0100) Subject: Fixed issues with split nodes X-Git-Tag: 2.1.0~35 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=16df77807e4acf500ec1d7263528c60ac36ec6f8;p=GitHub%2FWoltLab%2FWCF.git Fixed issues with split nodes --- diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index bbfb755a8f..e05a1c325d 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -3598,8 +3598,17 @@ WCF.Message.UserMention = Class.extend({ // allow redactor to undo this this._redactor.buffer.set(); + var $startContainer = $orgRange.startContainer; + var $startOffset = $orgRange.startOffset - (this._mentionStart.length + 1); + + // navigating with the keyboard before hitting enter will cause the text node to be split + if ($startOffset < 0) { + $startContainer = $startContainer.previousSibling; + $startOffset = $startContainer.length - (this._mentionStart.length + 1) - ($orgRange.startOffset - 1); + } + var $newRange = document.createRange(); - $newRange.setStart($orgRange.startContainer, $orgRange.startOffset - (this._mentionStart.length + 1)); + $newRange.setStart($startContainer, $startOffset); $newRange.setEnd($orgRange.startContainer, $orgRange.startOffset); this._redactor.wutil.replaceRangesWith($newRange);