Upgrade emojibase-bindings and remove local handling of emoticon variations (#127)

* Updgrade emojibase-bindings and remove local handling of emoticon variations

* bump bindings to fix issue of mission emojis with version == 0

* update lockfile

* test emoji variation in RTE
This commit is contained in:
David Langley 2024-10-10 15:52:45 +01:00 committed by GitHub
parent 3a59556749
commit c71dc6b0f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 34 additions and 19 deletions

View file

@ -201,9 +201,9 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
// so xd will not match if the string was "mixd 123456"
// and we are lookinh at xd 123456 part of the string
if (emoticonMatch && (n >= 0 || emoticonMatch.index !== 0)) {
const query = emoticonMatch[1].replace("-", "");
// try both exact match and lower-case, this means that xd won't match xD but :P will match :p
const data = EMOTICON_TO_EMOJI.get(query) || EMOTICON_TO_EMOJI.get(query.toLowerCase());
const query = emoticonMatch[1];
// variations of plaintext emoitcons(E.g. :P vs :p vs :-P) are handled upstream by the emojibase-bindings library
const data = EMOTICON_TO_EMOJI.get(query);
if (data) {
const { partCreator } = model;

View file

@ -388,7 +388,9 @@ function shouldIncrementEndIndex(text: string, index: number): boolean {
*/
export function getMappedSuggestion(text: string, isAutoReplaceEmojiEnabled?: boolean): MappedSuggestion | null {
if (isAutoReplaceEmojiEnabled) {
const emoji = EMOTICON_TO_EMOJI.get(text.toLocaleLowerCase());
// variations of plaintext emoitcons(E.g. :P vs :p vs :-P) are handled upstream by the emojibase-bindings/emojibase libraries.
// See rules for variations here https://github.com/milesj/emojibase/blob/master/packages/core/src/generateEmoticonPermutations.ts#L3-L32
const emoji = EMOTICON_TO_EMOJI.get(text);
if (emoji?.unicode) {
return { keyChar: "", text: emoji.unicode, type: "custom" };
}