Revert custom caret navigation logic

This commit is contained in:
Ken Powers 2019-11-12 18:44:41 -05:00 committed by Scott Nonnenberg
parent fa70fa2ecf
commit 7064691696
2 changed files with 36 additions and 353 deletions

View file

@ -38,11 +38,6 @@ export type EmojiSkinVariation = {
has_img_messenger: boolean;
};
export type DataFromEmojiText = {
shortName: string;
tone?: SkinToneKey;
};
export type EmojiData = {
name: string;
unified: string;
@ -121,7 +116,6 @@ export const preloadImages = async () => {
const dataByShortName = keyBy(data, 'short_name');
const imageByEmoji: { [key: string]: string } = {};
const dataByEmoji: { [key: string]: DataFromEmojiText } = {};
export const dataByCategory = mapValues(
groupBy(data, ({ category }) => {
@ -248,8 +242,20 @@ export function emojiToImage(emoji: string): string | undefined {
return imageByEmoji[emoji];
}
export function emojiToData(emoji: string): DataFromEmojiText | undefined {
return dataByEmoji[emoji];
export function replaceColons(str: string) {
return str.replace(/:[a-z0-9-_+]+:(?::skin-tone-[1-5]:)?/gi, m => {
const [shortName = '', skinTone = '0'] = m
.replace('skin-tone-', '')
.toLowerCase()
.split(':')
.filter(Boolean);
if (shortName && isShortName(shortName)) {
return convertShortName(shortName, parseInt(skinTone, 10));
}
return m;
});
}
function getCountOfAllMatches(str: string, regex: RegExp) {
@ -299,17 +305,12 @@ data.forEach(emoji => {
}
imageByEmoji[convertShortName(short_name)] = makeImagePath(image);
dataByEmoji[convertShortName(short_name)] = { shortName: short_name };
if (skin_variations) {
Object.entries(skin_variations).forEach(([tone, variation]) => {
imageByEmoji[
convertShortName(short_name, tone as SkinToneKey)
] = makeImagePath(variation.image);
dataByEmoji[convertShortName(short_name, tone as SkinToneKey)] = {
shortName: short_name,
tone: tone as SkinToneKey,
};
});
}
});