From c6c8004ef4c546ded64fc040c87a5afe12bc0b3f Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Sun, 21 Jan 2024 19:29:35 +0900 Subject: [PATCH] refactor(suggestion): cache emojimart data import --- composables/tiptap/suggestion.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composables/tiptap/suggestion.ts b/composables/tiptap/suggestion.ts index f48e65b00d..e2d34974d0 100644 --- a/composables/tiptap/suggestion.ts +++ b/composables/tiptap/suggestion.ts @@ -64,9 +64,8 @@ export const TiptapEmojiSuggestion: Partial = { const lowerCaseQuery = query.toLowerCase() - const emojis = await import('@emoji-mart/data') - .then(r => r.default as EmojiMartData) - .then(data => Object.values(data.emojis).filter(({ id }) => id.toLowerCase().startsWith(lowerCaseQuery))) + const { data } = await useAsyncData('emoji-data', () => import('@emoji-mart/data').then(r => r.default)) + const emojis: Emoji[] = Object.values(data.value.emojis).filter(({ id }) => id.toLowerCase().startsWith(lowerCaseQuery)) const customEmojis: CustomEmoji[] = currentCustomEmojis.value.emojis .filter(emoji => emoji.shortcode.toLowerCase().startsWith(lowerCaseQuery))