MentionFeed (mention)
@ckeditor/ckeditor5-mention/src/mention
The mention feed descriptor. Used in config.mention
.
See MentionConfig
to learn more.
// Static configuration.
const mentionFeedPeople = {
marker: '@',
feed: [ '@Alice', '@Bob', ... ],
minimumCharacters: 2
};
// Simple synchronous callback.
const mentionFeedTags = {
marker: '#',
feed: searchString => {
return tags
// Filter the tags list.
.filter( tag => {
return tag.toLowerCase().includes( queryText.toLowerCase() );
} )
}
};
const tags = [ 'wysiwyg', 'rte', 'rich-text-edior', 'collaboration', 'real-time', ... ];
// Asynchronous callback.
const mentionFeedPlaceholders = {
marker: '$',
feed: searchString => {
return getMatchingPlaceholders( searchString );
}
};
function getMatchingPlaceholders( searchString ) {
return new Promise( resolve => {
doSomeXHRQuery( result => {
// console.log( result );
// -> [ '$name', '$surname', '$postal', ... ]
resolve( result );
} );
} );
}
Filtering
Properties
-
feed : Array.<MentionFeedItem> | function
module:mention/mention~MentionFeed#feed
Autocomplete items. Provide an array for a static configuration (the mention feature will show matching items automatically) or a function which returns an array of matching items (directly, or via a promise). If a function is passed, it is executed in the context of the editor instance.
-
itemRenderer : function
module:mention/mention~MentionFeed#itemRenderer
A function that renders a
MentionFeedItem
to the autocomplete panel. -
marker : String
module:mention/mention~MentionFeed#marker
The character which triggers autocompletion for mention. It must be a single character.
-
minimumCharacters : Number
module:mention/mention~MentionFeed#minimumCharacters
Specifies after how many characters the autocomplete panel should be shown.
Defaults to
0
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.