summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/emoji
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/emoji')
-rw-r--r--app/assets/javascripts/emoji/index.js27
-rw-r--r--app/assets/javascripts/emoji/no_emoji_validator.js2
-rw-r--r--app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js4
-rw-r--r--app/assets/javascripts/emoji/support/unicode_support_map.js8
4 files changed, 21 insertions, 20 deletions
diff --git a/app/assets/javascripts/emoji/index.js b/app/assets/javascripts/emoji/index.js
index 4a56843c0b5..fa1024a74a4 100644
--- a/app/assets/javascripts/emoji/index.js
+++ b/app/assets/javascripts/emoji/index.js
@@ -35,7 +35,7 @@ async function prepareEmojiMap() {
validEmojiNames = [...Object.keys(emojiMap), ...Object.keys(emojiAliases)];
- Object.keys(emojiMap).forEach(name => {
+ Object.keys(emojiMap).forEach((name) => {
emojiMap[name].aliases = [];
emojiMap[name].name = name;
});
@@ -122,23 +122,23 @@ const searchMatchers = {
const searchPredicates = {
// Search by name
- name: (matcher, query) => emoji => {
+ name: (matcher, query) => (emoji) => {
const m = matcher(emoji.name, query);
return [{ ...m, emoji, field: emoji.name }];
},
// Search by alias
- alias: (matcher, query) => emoji =>
- emoji.aliases.map(alias => {
+ alias: (matcher, query) => (emoji) =>
+ emoji.aliases.map((alias) => {
const m = matcher(alias, query);
return { ...m, emoji, field: alias };
}),
// Search by description
- description: (matcher, query) => emoji => {
+ description: (matcher, query) => (emoji) => {
const m = matcher(emoji.d, query);
return [{ ...m, emoji, field: emoji.d }];
},
// Search by unicode value (always exact)
- unicode: (matcher, query) => emoji => {
+ unicode: (matcher, query) => (emoji) => {
return [{ emoji, field: emoji.e, success: emoji.e === query }];
},
};
@@ -196,18 +196,18 @@ export function searchEmoji(query, opts) {
}
const matcher = searchMatchers[match] || searchMatchers.exact;
- const predicates = fields.map(f => searchPredicates[f](matcher, query));
+ const predicates = fields.map((f) => searchPredicates[f](matcher, query));
const results = Object.values(emojiMap)
- .flatMap(emoji => predicates.flatMap(predicate => predicate(emoji)))
- .filter(r => r.success);
+ .flatMap((emoji) => predicates.flatMap((predicate) => predicate(emoji)))
+ .filter((r) => r.success);
// Fallback to question mark for unknown emojis
if (fallback && results.length === 0) {
return raw ? [{ emoji: fallbackEmoji }] : [fallbackEmoji];
}
- return raw ? results : results.map(r => r.emoji);
+ return raw ? results : results.map((r) => r.emoji);
}
let emojiCategoryMap;
@@ -223,7 +223,7 @@ export function getEmojiCategoryMap() {
symbols: [],
flags: [],
};
- Object.keys(emojiMap).forEach(name => {
+ Object.keys(emojiMap).forEach((name) => {
const emoji = emojiMap[name];
if (emojiCategoryMap[emoji.c]) {
emojiCategoryMap[emoji.c].push(name);
@@ -242,8 +242,9 @@ export function getEmojiInfo(query) {
export function emojiFallbackImageSrc(inputName) {
const { name } = getEmojiInfo(inputName);
- return `${gon.asset_host || ''}${gon.relative_url_root ||
- ''}/-/emojis/${EMOJI_VERSION}/${name}.png`;
+ return `${gon.asset_host || ''}${
+ gon.relative_url_root || ''
+ }/-/emojis/${EMOJI_VERSION}/${name}.png`;
}
export function emojiImageTag(name, src) {
diff --git a/app/assets/javascripts/emoji/no_emoji_validator.js b/app/assets/javascripts/emoji/no_emoji_validator.js
index edef868619a..85c8204225a 100644
--- a/app/assets/javascripts/emoji/no_emoji_validator.js
+++ b/app/assets/javascripts/emoji/no_emoji_validator.js
@@ -9,7 +9,7 @@ export default class NoEmojiValidator extends InputValidator {
const container = opts.container || '';
this.noEmojiEmelents = document.querySelectorAll(`${container} .js-block-emoji`);
- this.noEmojiEmelents.forEach(element =>
+ this.noEmojiEmelents.forEach((element) =>
element.addEventListener('input', this.eventHandler.bind(this)),
);
}
diff --git a/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js b/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js
index c5f9fcf6358..cf9794e6a87 100644
--- a/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js
+++ b/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js
@@ -33,7 +33,7 @@ const tone5 = 127999; // parseInt('1F3FF', 16)
function isSkinToneComboEmoji(emojiUnicode) {
return (
emojiUnicode.length > 2 &&
- Array.from(emojiUnicode).some(char => {
+ Array.from(emojiUnicode).some((char) => {
const cp = char.codePointAt(0);
return cp >= tone1 && cp <= tone5;
})
@@ -60,7 +60,7 @@ const personEndCodePoint = 128105; // parseInt('1F469', 16)
function isPersonZwjEmoji(emojiUnicode) {
let hasPersonEmoji = false;
let hasZwj = false;
- Array.from(emojiUnicode).forEach(character => {
+ Array.from(emojiUnicode).forEach((character) => {
const cp = character.codePointAt(0);
if (cp === zwj) {
hasZwj = true;
diff --git a/app/assets/javascripts/emoji/support/unicode_support_map.js b/app/assets/javascripts/emoji/support/unicode_support_map.js
index 651169391fe..fe3bc75f9fd 100644
--- a/app/assets/javascripts/emoji/support/unicode_support_map.js
+++ b/app/assets/javascripts/emoji/support/unicode_support_map.js
@@ -89,9 +89,9 @@ function generateUnicodeSupportMap(testMap) {
ctx.font = `${fontSize}px "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`;
// Write each emoji to the canvas vertically
let writeIndex = 0;
- testMapKeys.forEach(testKey => {
+ testMapKeys.forEach((testKey) => {
const testEntry = testMap[testKey];
- [].concat(testEntry).forEach(emojiUnicode => {
+ [].concat(testEntry).forEach((emojiUnicode) => {
ctx.fillText(emojiUnicode, 0, writeIndex * fontSize + fontSize / 2);
writeIndex += 1;
});
@@ -100,11 +100,11 @@ function generateUnicodeSupportMap(testMap) {
// Read from the canvas
const resultMap = {};
let readIndex = 0;
- testMapKeys.forEach(testKey => {
+ testMapKeys.forEach((testKey) => {
const testEntry = testMap[testKey];
// This needs to be a `reduce` instead of `every` because we need to
// keep the `readIndex` in sync from the writes by running all entries
- const isTestSatisfied = [].concat(testEntry).reduce(isSatisfied => {
+ const isTestSatisfied = [].concat(testEntry).reduce((isSatisfied) => {
// Sample along the vertical-middle for a couple of characters
const imageData = ctx.getImageData(0, readIndex * fontSize + fontSize / 2, 2 * fontSize, 1)
.data;