Fix jquery.mentionInput.js plugin
This commit is contained in:
parent
dfa41997df
commit
2be528494a
1 changed files with 9 additions and 3 deletions
|
|
@ -6,6 +6,11 @@
|
||||||
* Using underscore.js
|
* Using underscore.js
|
||||||
*
|
*
|
||||||
* License: MIT License - http://www.opensource.org/licenses/mit-license.php
|
* 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) {
|
(function ($, _, undefined) {
|
||||||
|
|
@ -69,6 +74,7 @@
|
||||||
var autocompleteItemCollection = {};
|
var autocompleteItemCollection = {};
|
||||||
var inputBuffer = [];
|
var inputBuffer = [];
|
||||||
var currentDataQuery = '';
|
var currentDataQuery = '';
|
||||||
|
var mentionChar = "\u200B"; // zero width space
|
||||||
|
|
||||||
settings = $.extend(true, {}, defaultSettings, settings );
|
settings = $.extend(true, {}, defaultSettings, settings );
|
||||||
|
|
||||||
|
|
@ -114,13 +120,13 @@
|
||||||
|
|
||||||
_.each(mentionsCollection, function (mention) {
|
_.each(mentionsCollection, function (mention) {
|
||||||
var textSyntax = settings.templates.mentionItemSyntax(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);
|
var mentionText = utils.htmlEncode(syntaxMessage);
|
||||||
|
|
||||||
_.each(mentionsCollection, function (mention) {
|
_.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 textSyntax = settings.templates.mentionItemSyntax(formattedMention);
|
||||||
var textHighlight = settings.templates.mentionItemHighlight(formattedMention);
|
var textHighlight = settings.templates.mentionItemHighlight(formattedMention);
|
||||||
|
|
||||||
|
|
@ -170,7 +176,7 @@
|
||||||
hideAutoComplete();
|
hideAutoComplete();
|
||||||
|
|
||||||
// Mentions & syntax message
|
// Mentions & syntax message
|
||||||
var updatedMessageText = start + mention.value + end;
|
var updatedMessageText = start + mentionChar + mention.value + end;
|
||||||
elmInputBox.val(updatedMessageText);
|
elmInputBox.val(updatedMessageText);
|
||||||
updateValues();
|
updateValues();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue