- Include the
bundle.jsfile in your javascript. - In the
callbacksoption passed to Summernote, include the configuration object.
The configuration object that should be passed into the callbacks option to Summernote has the following structure:
{
getSuggestions: (value) => ['Array of strings'],
onSelect: (value) => {},
}This object should be passed via the summernoteAtMention key within the callbacks option passed to Summernote.
The first function getSuggestions takes in a string via the value argument and should return a list of strings that will be presented as options to the user.
The second function onSelect gets called once a user selects an option using the ENTER key. It is passed the selected value via the value argument. If no such function is provided, the default behavior is to fill in the the text after the @ sign with the selected option.
$('#summernote').summernote({
placeholder: 'Placeholder',
toolbar: [['style', ['style']]],
callbacks: {
summernoteAtMention: {
getSuggestions: = (value) => {
const userEmails = ['cecilia@email.co', 'pedro@email.co'];
return userEmails.filter((email) => {
return sample.includes(value) && sample !== value
});
},
},
},
})All ideas and contributions are welcome! Please use the Issues tab.