Files
aritmija/public/admin/plugins/tmce/cpEmoji/plugin.js
2026-05-13 17:11:09 +02:00

54 lines
2.1 KiB
JavaScript

// emoji-plugin.js
tinymce.PluginManager.add('cpEmoji', function(editor, url) {
// Add a button that opens a window
editor.addButton('cpEmoji', {
text: 'Emoji',
icon: false,
onclick: function() {
// Open window
editor.windowManager.open({
title: 'Select Emoji',
width: 400,
height: 300,
body: [
{
type: 'container',
html: '<div id="emojiTable" style="heigh:300px;"></div>',
},
],
onsubmit: function(e) {
// Insert selected emoji into the editor
editor.insertContent(e.data.emoji);
},
onOpen: function() {
// Create emoji table
var emojis = [
'😀', '😃', '😄', '😁', '😆', '😅', '😂', '🤣',
'😊', '😇', '😍', '🥰', '😘', '😗', '😙', '😚',
'😋', '😛', '😜', '🤪', '😎', '🥳', '😏', '😒',
// Add more emojis as needed
];
var table = document.getElementById('emojiTable');
let btn = '';
for (var i = 0; i < emojis.length; i++) {
btn += '<button class="emoji-btn" data-emoji="' + emojis[i] + '">' + emojis[i] + '</button>';
}
table.innerHTML = btn;
// Add click event to emoji buttons
var buttons = document.getElementsByClassName('emoji-btn');
for (var j = 0; j < buttons.length; j++) {
buttons[j].addEventListener('click', function(event) {
editor.windowManager.close();
editor.insertContent(event.target.getAttribute('data-emoji'));
});
}
}
});
}
});
});