pleroma/app/soapbox/features/emoji/mapping.ts

30 lines
591 B
TypeScript
Raw Normal View History

2022-07-04 16:07:04 -07:00
import data, { EmojiData } from './data';
2022-07-04 13:30:35 -07:00
2022-07-04 16:07:04 -07:00
interface UnicodeMap {
2022-07-04 13:30:35 -07:00
[s: string]: {
unified: string,
shortcode: string,
}
}
2022-07-04 16:07:04 -07:00
export const generateMappings = (data: EmojiData): UnicodeMap => {
2022-07-04 13:30:35 -07:00
const result = {};
const emojis = Object.values(data.emojis ?? {});
for (const value of emojis) {
// @ts-ignore
for (const item of value.skins) {
const { unified, native } = item;
// @ts-ignore
result[native] = { unified, shortcode: value.id };
}
}
return result;
};
2022-07-04 16:07:04 -07:00
const unicodeMapping = generateMappings(data);
2022-07-04 13:30:35 -07:00
export default unicodeMapping;