Merge pull request #4882 from hpetru/4868-mention-inside-tags

4868 mention inside tags
This commit is contained in:
Jonne Haß 2014-03-31 12:05:18 +02:00
commit 0ea53aa5ed
2 changed files with 10 additions and 3 deletions

View file

@ -31,6 +31,7 @@
* Restore comment textarea content after revealing more comments [#4514](https://github.com/diaspora/diaspora/issues/4514)
* OpenGraph: don't make description into links [#4492](https://github.com/diaspora/diaspora/issues/4492)
* Don't cut off long tags in stream posts [#4864](https://github.com/diaspora/diaspora/issues/4864)
* Do not replace earlier appearances of the name while mentioning somebody [#4868](https://github.com/diaspora/diaspora/issues/4868)
## Features
* You can report a single post by clicking the correct icon in the controler section [#4517](https://github.com/diaspora/diaspora/pull/4517)

View file

@ -6,6 +6,11 @@
* Using underscore.js
*
* License: MIT License - http://www.opensource.org/licenses/mit-license.php
*
* Modifcations for Diaspora:
*
* Prevent replacing the wrong text by marking the replacement position with a special character
* Don't add a space after inserting a mention
*/
(function ($, _, undefined) {
@ -69,6 +74,7 @@
var autocompleteItemCollection = {};
var inputBuffer = [];
var currentDataQuery = '';
var mentionChar = "\u200B"; // zero width space
settings = $.extend(true, {}, defaultSettings, settings );
@ -114,13 +120,13 @@
_.each(mentionsCollection, function (mention) {
var textSyntax = settings.templates.mentionItemSyntax(mention);
syntaxMessage = syntaxMessage.replace(mention.value, textSyntax);
syntaxMessage = syntaxMessage.replace(mentionChar + mention.value, textSyntax);
});
var mentionText = utils.htmlEncode(syntaxMessage);
_.each(mentionsCollection, function (mention) {
var formattedMention = _.extend({}, mention, {value: utils.htmlEncode(mention.value)});
var formattedMention = _.extend({}, mention, {value: mentionChar + utils.htmlEncode(mention.value)});
var textSyntax = settings.templates.mentionItemSyntax(formattedMention);
var textHighlight = settings.templates.mentionItemHighlight(formattedMention);
@ -170,7 +176,7 @@
hideAutoComplete();
// Mentions & syntax message
var updatedMessageText = start + mention.value + end;
var updatedMessageText = start + mentionChar + mention.value + end;
elmInputBox.val(updatedMessageText);
updateValues();