Update
This commit is contained in:
53
public/admin/plugins/tmce/cpEmoji/plugin.js
Normal file
53
public/admin/plugins/tmce/cpEmoji/plugin.js
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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'));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user