mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-25 01:24:02 -05:00
510df0ac55
A new rake task emojis:generate downloads a full list of valid unicode sequences from unicode.org and checks it against existing Twemoji files, finally generating a map from each sequence to the existing file (e.g. when there's multiple ways an emoji can be expressed). The map is dumped into app/javascript/mastodon/emoji_map.json That file is loaded by emojione_light.js (now a misnomer) which decorates it further with shortcodes taken from emoji-mart's index.
39 lines
942 B
JavaScript
39 lines
942 B
JavaScript
// @preval
|
|
// http://www.unicode.org/Public/emoji/5.0/emoji-test.txt
|
|
|
|
const emojis = require('./emoji_map.json');
|
|
const { emojiIndex } = require('emoji-mart');
|
|
const excluded = ['®', '©', '™'];
|
|
const skins = ['🏻', '🏼', '🏽', '🏾', '🏿'];
|
|
const shortcodeMap = {};
|
|
|
|
Object.keys(emojiIndex.emojis).forEach(key => {
|
|
shortcodeMap[emojiIndex.emojis[key].native] = emojiIndex.emojis[key].id;
|
|
});
|
|
|
|
const stripModifiers = unicode => {
|
|
skins.forEach(tone => {
|
|
unicode = unicode.replace(tone, '');
|
|
});
|
|
|
|
return unicode;
|
|
};
|
|
|
|
Object.keys(emojis).forEach(key => {
|
|
if (excluded.includes(key)) {
|
|
delete emojis[key];
|
|
return;
|
|
}
|
|
|
|
const normalizedKey = stripModifiers(key);
|
|
let shortcode = shortcodeMap[normalizedKey];
|
|
|
|
if (!shortcode) {
|
|
shortcode = shortcodeMap[normalizedKey + '\uFE0F'];
|
|
}
|
|
|
|
emojis[key] = [emojis[key], shortcode];
|
|
});
|
|
|
|
module.exports.unicodeMapping = emojis;
|