Skip to content

Commit

Permalink
add new emoj plugin for unicode emojis toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
w8tcha committed Mar 21, 2024
1 parent 122b4ea commit cf52e2c
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/plugins/emojis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* SCEditor Paragraph Formatting Plugin
* http://www.sceditor.com/
*
* Copyright (C) 2011-2024, Sam Clarke (samclarke.com)
*
* SCEditor is licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* @fileoverview SCEditor Paragraph Formatting Plugin
* @author Sam Clarke
*/

(function(sceditor) {
'use strict';

sceditor.plugins.emojis = function() {
const base = this;

/**
* Function for the exec and txtExec properties
*
* @param {node} caller
* @private
*/
var emojisCmd = function(caller) {
const editor = this,
content = document.createElement('div'),
emojis = editor.opts.emojis || [],
perLine = Math.sqrt(Object.keys(emojis).length);

var line = document.createElement('div');

sceditor.utils.each(emojis,
function (_, emoji) {
const emojiElem = document.createElement('span');

emojiElem.className = 'sceditor-option';
emojiElem.style = 'cursor:pointer';

emojiElem.appendChild(document.createTextNode(emoji));

emojiElem.addEventListener('click',
function (e) {
editor.closeDropDown(true);

editor.insert(e.target.innerHTML);

e.preventDefault();
});

if (line.children.length >= perLine) {
line = document.createElement('div');
}

content.appendChild(line);

line.appendChild(emojiElem);
});

editor.createDropDown(caller, 'emojis', content);
};

base.init = function () {
const opts = this.opts;
const emojis = opts.emojis;

if (!emojis) {
return;
}

this.commands.emojis = {
exec: emojisCmd,
txtExec: emojisCmd,
tooltip: 'Insert emoji',
shortcut: 'Ctrl+E'
};
};
};
})(sceditor);
1 change: 1 addition & 0 deletions src/themes/icons/famfamfam.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ div.sceditor-grip, .sceditor-button div {
.sceditor-button-format div { background-position: 0px -448px; }
.sceditor-button-font div { background-position: 0px -464px; }
.sceditor-button-emoticon div { background-position: 0px -480px; }
.sceditor-button-emojis div { background-position: 0px -660px; }
.sceditor-button-email div { background-position: 0px -496px; }
.sceditor-button-date div { background-position: 0px -512px; }
.sceditor-button-cut div { background-position: 0px -528px; }
Expand Down
Binary file modified src/themes/icons/famfamfam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/themes/inc/defaultbase.less
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ div.sceditor-dropdown div {
cursor: pointer;
margin: 2px;
}

.sceditor-emojis span {
padding: 0;
cursor: pointer;
margin: 2px;
}

.sceditor-emojis > div > div:not(:last-child) {
margin-bottom: 6px;
}

.sceditor-more {
border-top: 1px solid #bbb;
Expand Down

0 comments on commit cf52e2c

Please sign in to comment.