2017-07-14 20:30:12 +02:00
|
|
|
// @preval
|
2017-09-25 18:36:33 +02:00
|
|
|
// http://www.unicode.org/Public/emoji/5.0/emoji-test.txt
|
2017-07-14 20:30:12 +02:00
|
|
|
|
2017-09-25 18:36:33 +02:00
|
|
|
const emojis = require('./emoji_map.json');
|
|
|
|
const { emojiIndex } = require('emoji-mart');
|
|
|
|
const excluded = ['®', '©', '™'];
|
|
|
|
const skins = ['🏻', '🏼', '🏽', '🏾', '🏿'];
|
|
|
|
const shortcodeMap = {};
|
2017-07-14 20:30:12 +02:00
|
|
|
|
2017-09-25 18:36:33 +02:00
|
|
|
Object.keys(emojiIndex.emojis).forEach(key => {
|
|
|
|
shortcodeMap[emojiIndex.emojis[key].native] = emojiIndex.emojis[key].id;
|
|
|
|
});
|
2017-07-14 20:30:12 +02:00
|
|
|
|
2017-09-25 18:36:33 +02:00
|
|
|
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;
|