Upgrade emojibase
and twemoji
(#7286)
Co-authored-by: Tulir Asokan <tulir@maunium.net> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
9961b003bb
commit
3534e9b6ce
9 changed files with 31 additions and 20 deletions
|
@ -72,8 +72,9 @@
|
||||||
"counterpart": "^0.18.6",
|
"counterpart": "^0.18.6",
|
||||||
"diff-dom": "^4.2.2",
|
"diff-dom": "^4.2.2",
|
||||||
"diff-match-patch": "^1.0.5",
|
"diff-match-patch": "^1.0.5",
|
||||||
"emojibase-data": "^6.2.0",
|
"emojibase": "6.0.2",
|
||||||
"emojibase-regex": "^5.1.3",
|
"emojibase-data": "7.0.0",
|
||||||
|
"emojibase-regex": "6.0.0",
|
||||||
"escape-html": "^1.0.3",
|
"escape-html": "^1.0.3",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"filesize": "6.1.0",
|
"filesize": "6.1.0",
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -75,7 +75,7 @@ export default class EmojiProvider extends AutocompleteProvider {
|
||||||
shouldMatchWordsOnly: false,
|
shouldMatchWordsOnly: false,
|
||||||
});
|
});
|
||||||
this.nameMatcher = new QueryMatcher(SORTED_EMOJI, {
|
this.nameMatcher = new QueryMatcher(SORTED_EMOJI, {
|
||||||
keys: ['emoji.annotation'],
|
keys: ['emoji.label'],
|
||||||
// For removing punctuation
|
// For removing punctuation
|
||||||
shouldMatchWordsOnly: true,
|
shouldMatchWordsOnly: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -196,8 +196,11 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private emojiMatchesFilter = (emoji: IEmoji, filter: string): boolean => {
|
private emojiMatchesFilter = (emoji: IEmoji, filter: string): boolean => {
|
||||||
return emoji.annotation.toLowerCase().includes(filter) ||
|
return emoji.label.toLowerCase().includes(filter) ||
|
||||||
emoji.emoticon?.toLowerCase().includes(filter) ||
|
(Array.isArray(emoji.emoticon)
|
||||||
|
? emoji.emoticon.some((x) => x.includes(filter))
|
||||||
|
: emoji.emoticon?.includes(filter)
|
||||||
|
) ||
|
||||||
emoji.shortcodes.some(x => x.toLowerCase().includes(filter)) ||
|
emoji.shortcodes.some(x => x.toLowerCase().includes(filter)) ||
|
||||||
emoji.unicode.split(ZERO_WIDTH_JOINER).includes(filter);
|
emoji.unicode.split(ZERO_WIDTH_JOINER).includes(filter);
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,7 @@ interface IProps {
|
||||||
@replaceableComponent("views.emojipicker.Preview")
|
@replaceableComponent("views.emojipicker.Preview")
|
||||||
class Preview extends React.PureComponent<IProps> {
|
class Preview extends React.PureComponent<IProps> {
|
||||||
render() {
|
render() {
|
||||||
const { unicode, annotation, shortcodes: [shortcode] } = this.props.emoji;
|
const { unicode, label, shortcodes: [shortcode] } = this.props.emoji;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_EmojiPicker_footer mx_EmojiPicker_preview">
|
<div className="mx_EmojiPicker_footer mx_EmojiPicker_preview">
|
||||||
|
@ -36,7 +36,7 @@ class Preview extends React.PureComponent<IProps> {
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_EmojiPicker_preview_text">
|
<div className="mx_EmojiPicker_preview_text">
|
||||||
<div className="mx_EmojiPicker_name mx_EmojiPicker_preview_name">
|
<div className="mx_EmojiPicker_name mx_EmojiPicker_preview_name">
|
||||||
{ annotation }
|
{ label }
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_EmojiPicker_shortcode">
|
<div className="mx_EmojiPicker_shortcode">
|
||||||
{ shortcode }
|
{ shortcode }
|
||||||
|
|
|
@ -68,7 +68,7 @@ class QuickReactions extends React.Component<IProps, IState> {
|
||||||
{ !this.state.hover
|
{ !this.state.hover
|
||||||
? _t("Quick Reactions")
|
? _t("Quick Reactions")
|
||||||
: <React.Fragment>
|
: <React.Fragment>
|
||||||
<span className="mx_EmojiPicker_name">{ this.state.hover.annotation }</span>
|
<span className="mx_EmojiPicker_name">{ this.state.hover.label }</span>
|
||||||
<span className="mx_EmojiPicker_shortcode">{ this.state.hover.shortcodes[0] }</span>
|
<span className="mx_EmojiPicker_shortcode">{ this.state.hover.shortcodes[0] }</span>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
|
|
10
src/emoji.ts
10
src/emoji.ts
|
@ -18,7 +18,7 @@ import EMOJIBASE from 'emojibase-data/en/compact.json';
|
||||||
import SHORTCODES from 'emojibase-data/en/shortcodes/iamcal.json';
|
import SHORTCODES from 'emojibase-data/en/shortcodes/iamcal.json';
|
||||||
|
|
||||||
export interface IEmoji {
|
export interface IEmoji {
|
||||||
annotation: string;
|
label: string;
|
||||||
group?: number;
|
group?: number;
|
||||||
hexcode: string;
|
hexcode: string;
|
||||||
order?: number;
|
order?: number;
|
||||||
|
@ -26,7 +26,7 @@ export interface IEmoji {
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
unicode: string;
|
unicode: string;
|
||||||
skins?: Omit<IEmoji, "shortcodes" | "tags">[]; // Currently unused
|
skins?: Omit<IEmoji, "shortcodes" | "tags">[]; // Currently unused
|
||||||
emoticon?: string;
|
emoticon?: string | string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// The unicode is stored without the variant selector
|
// The unicode is stored without the variant selector
|
||||||
|
@ -74,7 +74,7 @@ export const EMOJI: IEmoji[] = EMOJIBASE.map((emojiData: Omit<IEmoji, "shortcode
|
||||||
// If there's ever a gap in shortcode coverage, we fudge it by
|
// If there's ever a gap in shortcode coverage, we fudge it by
|
||||||
// filling it in with the emoji's CLDR annotation
|
// filling it in with the emoji's CLDR annotation
|
||||||
const shortcodeData = SHORTCODES[emojiData.hexcode] ??
|
const shortcodeData = SHORTCODES[emojiData.hexcode] ??
|
||||||
[emojiData.annotation.toLowerCase().replace(/\W+/g, "_")];
|
[emojiData.label.toLowerCase().replace(/\W+/g, "_")];
|
||||||
|
|
||||||
const emoji: IEmoji = {
|
const emoji: IEmoji = {
|
||||||
...emojiData,
|
...emojiData,
|
||||||
|
@ -102,7 +102,9 @@ export const EMOJI: IEmoji[] = EMOJIBASE.map((emojiData: Omit<IEmoji, "shortcode
|
||||||
|
|
||||||
if (emoji.emoticon) {
|
if (emoji.emoticon) {
|
||||||
// Add mapping from emoticon to Emoji object
|
// Add mapping from emoticon to Emoji object
|
||||||
EMOTICON_TO_EMOJI.set(emoji.emoticon, emoji);
|
Array.isArray(emoji.emoticon)
|
||||||
|
? emoji.emoticon.forEach((x) => EMOTICON_TO_EMOJI.set(x, emoji))
|
||||||
|
: EMOTICON_TO_EMOJI.set(emoji.emoticon, emoji);
|
||||||
}
|
}
|
||||||
|
|
||||||
return emoji;
|
return emoji;
|
||||||
|
|
21
yarn.lock
21
yarn.lock
|
@ -3531,15 +3531,20 @@ emoji-regex@^9.2.2:
|
||||||
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72"
|
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72"
|
||||||
integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==
|
integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==
|
||||||
|
|
||||||
emojibase-data@^6.2.0:
|
emojibase-data@7.0.0:
|
||||||
version "6.2.0"
|
version "7.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/emojibase-data/-/emojibase-data-6.2.0.tgz#db6c75c36905284fa623f4aa5f468d2be6ed364a"
|
resolved "https://registry.yarnpkg.com/emojibase-data/-/emojibase-data-7.0.0.tgz#5e16ed265871d58b3ca7c3b2bc7d80853a55f34f"
|
||||||
integrity sha512-SWKaXD2QeQs06IE7qfJftsI5924Dqzp+V9xaa5RzZIEWhmlrG6Jt2iKwfgOPHu+5S8MEtOI7GdpKsXj46chXOw==
|
integrity sha512-ka3p06egA+jqWnUUjNfOwYAw4j9/+KyUcCpFjSItM0NjbL8n5qZfe1mskmGUP4TkuE5SbiOvG++CC1iN+53jKg==
|
||||||
|
|
||||||
emojibase-regex@^5.1.3:
|
emojibase-regex@6.0.0:
|
||||||
version "5.1.3"
|
version "6.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/emojibase-regex/-/emojibase-regex-5.1.3.tgz#f0ef621ed6ec624becd2326f999fd4ea01b94554"
|
resolved "https://registry.yarnpkg.com/emojibase-regex/-/emojibase-regex-6.0.0.tgz#2d236f6bd38e6aa69089707eb06fe1f6a3270198"
|
||||||
integrity sha512-gT8T9LxLA8VJdI+8KQtyykB9qKzd7WuUL3M2yw6y9tplFeufOUANg3UKVaKUvkMcRNvZsSElWhxcJrx8WPE12g==
|
integrity sha512-vpo76XcjjFapY4Q1vZAp8fu07p9lNCZi0TMtpZ3XyHYRqnqYZTzHgSI7tMvpYmnD8xt9o4XC5oUaSJXT4Ky9Tw==
|
||||||
|
|
||||||
|
emojibase@6.0.2:
|
||||||
|
version "6.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/emojibase/-/emojibase-6.0.2.tgz#1e76996b2bd9e6927e51f54c3995245b03eacb02"
|
||||||
|
integrity sha512-2h2eblOm86tj+lsJLgLYmEni13H74KNNu1NI1ZgMOX9ByWuvjFZLhETEUH1edpcd8srAlzhfJSD892UbpxfwsA==
|
||||||
|
|
||||||
emojis-list@^3.0.0:
|
emojis-list@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
|
|
Loading…
Reference in a new issue