Fix issue with editing mentions
authorMatthias Schmidt <gravatronics@live.com>
Fri, 4 Apr 2014 17:12:48 +0000 (19:12 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 4 Apr 2014 17:12:48 +0000 (19:12 +0200)
wcfsetup/install/files/js/WCF.Message.js

index 776ad462779a8a1d18a9977b1f99041f5fec3dcf..521469483768b98c2c2da6b674616ddb5cd10878 100644 (file)
@@ -3299,7 +3299,7 @@ WCF.Message.UserMention = Class.extend({
                var $range = this._ckEditor.getSelection().getRanges()[0];
                
                // remove the beginning of the username
-               $range.setStart($range.startContainer, $range.startOffset - this._mentionStart.length);
+               $range.setStart($range.startContainer, $range.startOffset - (this._mentionStart.length + 1));
                $range.deleteContents();
                
                // insert username
@@ -3310,7 +3310,7 @@ WCF.Message.UserMention = Class.extend({
                else if (username.indexOf(' ') !== -1) {
                        username = "'" + username + "'";
                }
-               this._ckEditor.insertText(username);
+               this._ckEditor.insertText('@' + username);
                
                // add whitespace after username
                var $element = CKEDITOR.dom.element.createFromHtml('<span class="wcfUserMentionTemporary">&nbsp;</span>');
@@ -3319,11 +3319,6 @@ WCF.Message.UserMention = Class.extend({
                        return $(this).html();
                });
                
-               // the @-sign and the entered username are now in seperate text
-               // nodes which causes issues if the user changes the text
-               $range.endContainer.$.nodeValue += $range.endContainer.$.nextSibling.nodeValue;
-               $($range.endContainer.$.nextSibling).remove();
-               
                // make sure that the range in Firefox is that same as in the
                // other browsers
                if ($.browser.mozilla) {