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