fix(suggestion): allow case-insensitive emoji suggestion (#2565)

pull/1414/merge
TAKAHASHI Shuuji 2024-02-19 18:23:58 +09:00 zatwierdzone przez GitHub
rodzic 54fe0c1ab9
commit bf0c562794
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 6 dodań i 4 usunięć

Wyświetl plik

@ -62,13 +62,15 @@ export const TiptapEmojiSuggestion: Partial<SuggestionOptions> = {
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<EmojiMartData>('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 }) => {