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