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