From 6bd7e8597689ce694a1278c3f83b0337f5b541ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:17:24 +0900 Subject: [PATCH] Complete unicode emoji after last colon (misskey-dev#13384) (MisskeyIO#523) Co-authored-by: anatawa12 --- .../src/components/MkAutocomplete.vue | 79 +++++++++++++++---- packages/frontend/src/scripts/autocomplete.ts | 37 +++++++-- 2 files changed, 96 insertions(+), 20 deletions(-) diff --git a/packages/frontend/src/components/MkAutocomplete.vue b/packages/frontend/src/components/MkAutocomplete.vue index 2f3855266c..06de95ab19 100644 --- a/packages/frontend/src/components/MkAutocomplete.vue +++ b/packages/frontend/src/components/MkAutocomplete.vue @@ -15,12 +15,12 @@ SPDX-License-Identifier: AGPL-3.0-only
  • {{ i18n.ts.selectUser }}
  • -
      +
      1. {{ hashtag }}
      -
        +
        1. @@ -30,12 +30,12 @@ SPDX-License-Identifier: AGPL-3.0-only ({{ emoji.aliasOf }})
        -
          +
          1. {{ tag }}
          -
            +
            1. {{ param }}
            2. @@ -59,9 +59,41 @@ import { customEmojis } from '@/custom-emojis.js'; import { MFM_TAGS, MFM_PARAMS } from '@/const.js'; import { searchEmoji, EmojiDef } from '@/scripts/search-emoji.js'; +export type CompleteInfo = { + user: { + payload: any; + query: string | null; + }, + hashtag: { + payload: string; + query: string; + }, + // `:emo` -> `:emoji:` or some unicode emoji + emoji: { + payload: string; + query: string; + }, + // like emoji but for `:emoji:` -> unicode emoji + emojiComplete: { + payload: string; + query: string; + }, + mfmTag: { + payload: string; + query: string; + }, + mfmParam: { + payload: string; + query: { + tag: string; + params: string[]; + }; + }, +} + const lib = emojilist.filter(x => x.category !== 'flags'); -const emojiDb = computed(() => { +const unicodeEmojiDB = computed(() => { //#region Unicode Emoji const char2path = defaultStore.reactiveState.emojiStyle.value === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath; @@ -87,6 +119,10 @@ const emojiDb = computed(() => { unicodeEmojiDB.sort((a, b) => a.name.length - b.name.length); //#endregion + return unicodeEmojiDB; +}); + +const emojiDb = computed(() => { //#region Custom Emoji const customEmojiDB: EmojiDef[] = []; @@ -112,7 +148,7 @@ const emojiDb = computed(() => { customEmojiDB.sort((a, b) => a.name.length - b.name.length); //#endregion - return markRaw([...customEmojiDB, ...unicodeEmojiDB]); + return markRaw([...customEmojiDB, ...unicodeEmojiDB.value]); }); export default { @@ -121,18 +157,23 @@ export default { }; -