Mention Composer Plugin
Composer plugin which adds @mention support.
Usage
Like other Composer plugins, it can be declared in the list of plugins when instantiating a composer
$('textarea.selector').evolutionComposer({
plugins: ['mentions']
// extra options supported by the mentions plugin
});
Options
-
onMentionableList
: function which is called to asynchronously provide suggested type-ahead results during @mention composition-
parameters:
query
: string querycomplete
: function to be called to pass the results back to the composer. Should be passed an array of objects withname
andtoken
keys on each.
- default: ** This is automatically supplied globally by Evolution, but can be overridden**
-
parameters:
-
onListContent
: function which is called to transform a set of contentId and contentTypeIds to their HTML Names-
parameters:
contentIdsAndTypes
: array of objects, each containing a contentId and contentTypeId stringcomplete
: function to be called to pass the results back to the composer. Should be passed an array of objects with contentId, contentTypeId, and htmlName.
-
parameters:
-
highlightClass
: class name to apply to the @mention to differentiate it from surrounding text.- default:
'composer-mentionable-mention-highlight'
- default:
Default onMentionableList implementation:
This is automatically supplied globally by Evolution, but can be overridden:
onListContent: function(contentIdsAndTypes, complete) {
// gets a set of HtmlNames for a given set of content ids/type ids for the purpose
// of re-showing a pre-exisitng mention token in text
$.telligent.evolution.batch(function(){
$.each(contentIdsAndTypes, function(i, content) {
$.telligent.evolution.get({
url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/genericcontent/{contentId}/{contentTypeId}.json',
data: {
contentId: content.contentId,
contentTypeId: content.contentTypeId
}
}).then(function(r){
content.name = r.Content.HtmlName;
});
});
}).then(function(){
complete(contentIdsAndTypes);
});
},
onMentionableList: function(query, complete) {
$.telligent.evolution.get({
url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/mentionables.json?IncludeFields=Token,PreviewHtml',
data: {
QueryText: query,
PageSize: 20
},
cache: false,
dataType: 'json',
success: function(response) {
if(response.Mentionables && response.Mentionables.length > 0) {
var results = $.map(response.Mentionables, function(mentionable) {
return { name: mentionable.PreviewHtml, token: mentionable.Token };
});
complete(results);
} else {
complete(null);
}
}
});
}