logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

emoji_unicode_mapping_light.js (1185B)


  1. // A mapping of unicode strings to an object containing the filename
  2. // (i.e. the svg filename) and a shortCode intended to be shown
  3. // as a "title" attribute in an HTML element (aka tooltip).
  4. const [
  5. shortCodesToEmojiData,
  6. skins, // eslint-disable-line no-unused-vars
  7. categories, // eslint-disable-line no-unused-vars
  8. short_names, // eslint-disable-line no-unused-vars
  9. emojisWithoutShortCodes,
  10. ] = require('./emoji_compressed');
  11. const { unicodeToFilename } = require('./unicode_to_filename');
  12. // decompress
  13. const unicodeMapping = {};
  14. function processEmojiMapData(emojiMapData, shortCode) {
  15. let [ native, filename ] = emojiMapData;
  16. if (!filename) {
  17. // filename name can be derived from unicodeToFilename
  18. filename = unicodeToFilename(native);
  19. }
  20. unicodeMapping[native] = {
  21. shortCode: shortCode,
  22. filename: filename,
  23. };
  24. }
  25. Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
  26. let [ filenameData ] = shortCodesToEmojiData[shortCode];
  27. filenameData.forEach(emojiMapData => processEmojiMapData(emojiMapData, shortCode));
  28. });
  29. emojisWithoutShortCodes.forEach(emojiMapData => processEmojiMapData(emojiMapData));
  30. module.exports = unicodeMapping;