mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-19 15:29:59 +00:00
fix(suggestion): allow case-insensitive emoji suggestion (#2565)
This commit is contained in:
parent
54fe0c1ab9
commit
bf0c562794
1 changed files with 6 additions and 4 deletions
|
@ -62,13 +62,15 @@ export const TiptapEmojiSuggestion: Partial<SuggestionOptions> = {
|
||||||
if (currentCustomEmojis.value.emojis.length === 0)
|
if (currentCustomEmojis.value.emojis.length === 0)
|
||||||
await updateCustomEmojis()
|
await updateCustomEmojis()
|
||||||
|
|
||||||
const emojis = await import('@emoji-mart/data')
|
const lowerCaseQuery = query.toLowerCase()
|
||||||
.then(r => r.default as EmojiMartData)
|
|
||||||
.then(data => Object.values(data.emojis).filter(({ id }) => id.startsWith(query)))
|
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
|
const customEmojis: CustomEmoji[] = currentCustomEmojis.value.emojis
|
||||||
.filter(emoji => emoji.shortcode.startsWith(query))
|
.filter(emoji => emoji.shortcode.toLowerCase().startsWith(lowerCaseQuery))
|
||||||
.map(emoji => ({ ...emoji, custom: true }))
|
.map(emoji => ({ ...emoji, custom: true }))
|
||||||
|
|
||||||
return [...emojis, ...customEmojis]
|
return [...emojis, ...customEmojis]
|
||||||
},
|
},
|
||||||
command: ({ editor, props, range }) => {
|
command: ({ editor, props, range }) => {
|
||||||
|
|
Loading…
Reference in a new issue