Skip to content

Commit

Permalink
Fix formatting so passes tests
Browse files Browse the repository at this point in the history
Changes spaces to tabs, adds a few spaces before opening brackets.

Also adds a comment to tell ESLint `EmojiMart` is a global variable.
  • Loading branch information
samclarke authored Mar 31, 2024
1 parent 543feb6 commit 3161e47
Showing 1 changed file with 74 additions and 74 deletions.
148 changes: 74 additions & 74 deletions src/plugins/emojis.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,77 +10,77 @@
* @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);

if (!emojis.length) {
const pickerOptions = { onEmojiSelect: handleSelect };
const picker = new EmojiMart.Picker(pickerOptions);

content.appendChild(picker);
} else {
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);

function handleSelect(emoji) {
editor.insert(emoji.native);

editor.closeDropDown(true);
}
};

base.init = function () {
this.commands.emojis = {
exec: emojisCmd,
txtExec: emojisCmd,
tooltip: 'Insert emoji',
shortcut: 'Ctrl+E'
};
};
};
})(sceditor);
/*global EmojiMart*/
(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);

if (!emojis.length) {
const pickerOptions = { onEmojiSelect: handleSelect };
const picker = new EmojiMart.Picker(pickerOptions);

content.appendChild(picker);
} else {
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);

function handleSelect(emoji) {
editor.insert(emoji.native);

editor.closeDropDown(true);
}
};

base.init = function () {
this.commands.emojis = {
exec: emojisCmd,
txtExec: emojisCmd,
tooltip: 'Insert emoji',
shortcut: 'Ctrl+E'
};
};
};
})(sceditor);

0 comments on commit 3161e47

Please sign in to comment.