Add regional indicators to emoji picker
Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
parent
9707797d45
commit
caefefc2c2
1 changed files with 8 additions and 1 deletions
|
@ -35,6 +35,9 @@ export const EMOTICON_TO_EMOJI = new Map<string, IEmoji>();
|
||||||
|
|
||||||
export const getEmojiFromUnicode = unicode => UNICODE_TO_EMOJI.get(stripVariation(unicode));
|
export const getEmojiFromUnicode = unicode => UNICODE_TO_EMOJI.get(stripVariation(unicode));
|
||||||
|
|
||||||
|
const isRegionalIndicator = (x: string) =>
|
||||||
|
Array.from(x).length === 1 && x >= '\u{1f1e6}' && x <= '\u{1f1ff}';
|
||||||
|
|
||||||
const EMOJIBASE_GROUP_ID_TO_CATEGORY = [
|
const EMOJIBASE_GROUP_ID_TO_CATEGORY = [
|
||||||
"people", // smileys
|
"people", // smileys
|
||||||
"people", // actually people
|
"people", // actually people
|
||||||
|
@ -72,7 +75,11 @@ export const EMOJI: IEmoji[] = EMOJIBASE.map((emojiData: Omit<IEmoji, "shortcode
|
||||||
shortcodes: typeof shortcodeData === "string" ? [shortcodeData] : shortcodeData,
|
shortcodes: typeof shortcodeData === "string" ? [shortcodeData] : shortcodeData,
|
||||||
};
|
};
|
||||||
|
|
||||||
const categoryId = EMOJIBASE_GROUP_ID_TO_CATEGORY[emoji.group];
|
// We manually include regional indicators in the symbols group, since
|
||||||
|
// Emojibase intentionally leaves them uncategorized
|
||||||
|
const categoryId = EMOJIBASE_GROUP_ID_TO_CATEGORY[emoji.group] ??
|
||||||
|
(isRegionalIndicator(emoji.unicode) ? "symbols" : null);
|
||||||
|
|
||||||
if (DATA_BY_CATEGORY.hasOwnProperty(categoryId)) {
|
if (DATA_BY_CATEGORY.hasOwnProperty(categoryId)) {
|
||||||
DATA_BY_CATEGORY[categoryId].push(emoji);
|
DATA_BY_CATEGORY[categoryId].push(emoji);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue