Skip to content

Instantly share code, notes, and snippets.

tinymce.PluginManager.add('mention_plugin', function(editor, url) {
// Mock data for recipients
const recipients = [
{ avatar: 'https://via.placeholder.com/40', name: 'Alice Johnson', email: 'alice.johnson@example.com' },
{ avatar: 'https://via.placeholder.com/40', name: 'Bob Smith', email: 'bob.smith@example.com' },
{ avatar: 'https://via.placeholder.com/40', name: 'Charlie Brown', email: 'charlie.brown@example.com' }
];
editor.on('keypress', function(event) {
if (event.key === '@') {
tinymce.PluginManager.add('mention_plugin', function(editor, url) {
// The plugin's initialization logic
editor.on('keypress', function(event) {
if (event.key === '@') {
showContextMenu(editor);
}
});
function showContextMenu(editor) {
// Placeholder for showing a context menu
tinymce.PluginManager.add('mention_plugin', function(editor, url) {
// The plugin's initialization logic
editor.on('keypress', function(event) {
if (event.key === '@') {
showContextMenu(editor);
}
});
function showContextMenu(editor) {
// Placeholder for showing a context menu
tinymce.PluginManager.add('mentions', function(editor) {
let mentionList = null;
let currentMention = null;
// Configuration for the mentions feature
const mentionsConfig = {
delimiter: '@',
source: getSuggestions, // Function to get user suggestions
insertTemplate: function(mention) {
return `<span class="mention" data-user="${mention.id}">@${mention.name}</span>`;