bigbuffet-rw/app/soapbox/features/emoji/emoji-unicode-mapping-light.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
// A mapping of unicode strings to an object containing the filename
// (i.e. the svg filename) and a shortCode intended to be shown
// as a "title" attribute in an HTML element (aka tooltip).
const [
shortCodesToEmojiData,
2022-05-02 07:00:50 -07:00
skins, // eslint-disable-line @typescript-eslint/no-unused-vars
categories, // eslint-disable-line @typescript-eslint/no-unused-vars
short_names, // eslint-disable-line @typescript-eslint/no-unused-vars
2020-03-27 13:59:38 -07:00
emojisWithoutShortCodes,
2022-11-15 09:23:36 -08:00
] = require('./emoji-compressed');
const { unicodeToFilename } = require('./unicode-to-filename');
2020-03-27 13:59:38 -07:00
// decompress
const unicodeMapping = {};
function processEmojiMapData(emojiMapData, shortCode) {
const [ native, filename ] = emojiMapData;
2020-03-27 13:59:38 -07:00
unicodeMapping[native] = {
shortCode,
filename: filename || unicodeToFilename(native),
2020-03-27 13:59:38 -07:00
};
}
Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
const [ filenameData ] = shortCodesToEmojiData[shortCode];
2020-03-27 13:59:38 -07:00
filenameData.forEach(emojiMapData => processEmojiMapData(emojiMapData, shortCode));
});
emojisWithoutShortCodes.forEach(emojiMapData => processEmojiMapData(emojiMapData));
module.exports = unicodeMapping;