From bf0c562794c0fd546d8b0cc7098712fd2b398609 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Mon, 19 Feb 2024 18:23:58 +0900 Subject: [PATCH] fix(suggestion): allow case-insensitive emoji suggestion (#2565) --- composables/tiptap/suggestion.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/composables/tiptap/suggestion.ts b/composables/tiptap/suggestion.ts index 0add4f01..e9c6b035 100644 --- a/composables/tiptap/suggestion.ts +++ b/composables/tiptap/suggestion.ts @@ -62,13 +62,15 @@ export const TiptapEmojiSuggestion: Partial = { if (currentCustomEmojis.value.emojis.length === 0) await updateCustomEmojis() - const emojis = await import('@emoji-mart/data') - .then(r => r.default as EmojiMartData) - .then(data => Object.values(data.emojis).filter(({ id }) => id.startsWith(query))) + const lowerCaseQuery = query.toLowerCase() + + const { data } = await useAsyncData('emoji-data', () => import('@emoji-mart/data').then(r => r.default as EmojiMartData)) + const emojis: Emoji[] = Object.values(data.value?.emojis || []).filter(({ id }) => id.toLowerCase().startsWith(lowerCaseQuery)) const customEmojis: CustomEmoji[] = currentCustomEmojis.value.emojis - .filter(emoji => emoji.shortcode.startsWith(query)) + .filter(emoji => emoji.shortcode.toLowerCase().startsWith(lowerCaseQuery)) .map(emoji => ({ ...emoji, custom: true })) + return [...emojis, ...customEmojis] }, command: ({ editor, props, range }) => {