Sharkey/packages/frontend/src/components/MkEmojiPicker.vue

685 lines
17 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
2023-01-07 07:44:50 +02:00
<div class="omfetrab" :class="['s' + size, 'w' + width, 'h' + height, { asDrawer, asWindow }]" :style="{ maxHeight: maxHeight ? maxHeight + 'px' : undefined }">
<input ref="searchEl" :value="q" class="search" data-prevent-emoji-insert :class="{ filled: q != null && q != '' }" :placeholder="i18n.ts.search" type="search" autocapitalize="off" @input="input()" @paste.stop="paste" @keydown.stop.prevent.enter="onEnter">
<!-- FirefoxのTabフォーカスが想定外の挙動となるためtabindex="-1"を追加 https://github.com/misskey-dev/misskey/issues/10744 -->
<div ref="emojisEl" class="emojis" tabindex="-1">
<section class="result">
<div v-if="searchResultCustom.length > 0" class="body">
<button
v-for="emoji in searchResultCustom"
:key="emoji.name"
class="_button item"
:title="emoji.name"
tabindex="0"
2021-11-19 12:36:12 +02:00
@click="chosen(emoji, $event)"
>
<MkCustomEmoji class="emoji" :name="emoji.name"/>
</button>
</div>
<div v-if="searchResultUnicode.length > 0" class="body">
<button
v-for="emoji in searchResultUnicode"
2021-11-19 12:36:12 +02:00
:key="emoji.name"
class="_button item"
:title="emoji.name"
tabindex="0"
2021-11-19 12:36:12 +02:00
@click="chosen(emoji, $event)"
>
<MkEmoji class="emoji" :emoji="emoji.char"/>
</button>
</div>
</section>
<div v-if="tab === 'index'" class="group index">
<section v-if="showPinned && pinned.length > 0">
<div class="body">
<button
v-for="emoji in pinned"
2021-11-19 12:36:12 +02:00
:key="emoji"
:data-emoji="emoji"
class="_button item"
tabindex="0"
@pointerenter="computeButtonTitle"
2021-11-19 12:36:12 +02:00
@click="chosen(emoji, $event)"
>
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
</button>
</div>
</section>
<section>
2022-12-20 08:24:31 +02:00
<header class="_acrylic"><i class="ti ti-clock ti-fw"></i> {{ i18n.ts.recentUsed }}</header>
<div class="body">
<button
v-for="emoji in recentlyUsedEmojis"
2021-11-19 12:36:12 +02:00
:key="emoji"
class="_button item"
:data-emoji="emoji"
@pointerenter="computeButtonTitle"
@click="chosen(emoji, $event)"
>
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
</button>
</div>
</section>
</div>
<div v-once class="group">
<header class="_acrylic">{{ i18n.ts.customEmojis }}</header>
2023-01-22 19:33:20 +02:00
<XSection
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
v-for="child in customEmojiFolderRoot.children"
:key="`custom:${child.value}`"
2023-05-18 14:17:32 +03:00
:initialShown="false"
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
:emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
2023-12-09 19:11:17 +02:00
:hasChildSection="child.children.length !== 0"
:customEmojiTree="child.children"
2023-01-22 19:33:20 +02:00
@chosen="chosen"
>
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
{{ child.value || i18n.ts.other }}
2023-01-22 19:33:20 +02:00
</XSection>
2021-02-27 12:53:20 +02:00
</div>
<div v-once class="group">
<header class="_acrylic">{{ i18n.ts.emoji }}</header>
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
<XSection v-for="category in categories" :key="category" :emojis="emojiCharByCategory.get(category) ?? []" :hasChildSection="false" @chosen="chosen">{{ category }}</XSection>
2021-02-27 12:53:20 +02:00
</div>
</div>
<div class="tabs">
2022-12-20 01:35:49 +02:00
<button class="_button tab" :class="{ active: tab === 'index' }" @click="tab = 'index'"><i class="ti ti-asterisk ti-fw"></i></button>
<button class="_button tab" :class="{ active: tab === 'custom' }" @click="tab = 'custom'"><i class="ti ti-mood-happy ti-fw"></i></button>
2022-12-20 01:35:49 +02:00
<button class="_button tab" :class="{ active: tab === 'unicode' }" @click="tab = 'unicode'"><i class="ti ti-leaf ti-fw"></i></button>
<button class="_button tab" :class="{ active: tab === 'tags' }" @click="tab = 'tags'"><i class="ti ti-hash ti-fw"></i></button>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, shallowRef, computed, watch, onMounted } from 'vue';
import * as Misskey from 'misskey-js';
import XSection from '@/components/MkEmojiPicker.section.vue';
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
import {
2023-12-09 19:11:17 +02:00
emojilist,
emojiCharByCategory,
UnicodeEmojiDef,
unicodeEmojiCategories as categories,
getEmojiName,
2023-12-11 13:31:23 +02:00
CustomEmojiFolderTree,
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
} from '@/scripts/emojilist.js';
2023-01-01 05:28:30 +02:00
import MkRippleEffect from '@/components/MkRippleEffect.vue';
2023-09-19 10:37:43 +03:00
import * as os from '@/os.js';
import { isTouchUsing } from '@/scripts/touch.js';
import { deviceKind } from '@/scripts/device-kind.js';
import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js';
import { customEmojiCategories, customEmojis, customEmojisMap } from '@/custom-emojis.js';
import { $i } from '@/account.js';
const props = withDefaults(defineProps<{
showPinned?: boolean;
pinnedEmojis?: string[];
maxHeight?: number;
asDrawer?: boolean;
2023-01-07 07:44:50 +02:00
asWindow?: boolean;
asReactionPicker?: boolean; // 今は使われてないが将来的に使いそう
}>(), {
showPinned: true,
});
const emit = defineEmits<{
(ev: 'chosen', v: string): void;
}>();
2023-01-09 10:04:52 +02:00
const searchEl = shallowRef<HTMLInputElement>();
2023-01-09 09:27:09 +02:00
const emojisEl = shallowRef<HTMLDivElement>();
const {
emojiPickerScale,
emojiPickerWidth,
emojiPickerHeight,
recentlyUsedEmojis,
} = defaultStore.reactiveState;
const pinned = computed(() => props.pinnedEmojis);
const size = computed(() => emojiPickerScale.value);
const width = computed(() => emojiPickerWidth.value);
const height = computed(() => emojiPickerHeight.value);
const q = ref<string>('');
const searchResultCustom = ref<Misskey.entities.EmojiSimple[]>([]);
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: '', category: '', children: [] };
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
const parts = input.split('/').map(p => p.trim());
let currentNode: CustomEmojiFolderTree = root;
for (const part of parts) {
let existingNode = currentNode.children.find((node) => node.value === part);
if (!existingNode) {
const newNode: CustomEmojiFolderTree = { value: part, category: input, children: [] };
currentNode.children.push(newNode);
existingNode = newNode;
}
currentNode = existingNode;
}
return currentNode;
}
customEmojiCategories.value.forEach(ec => {
2023-12-09 19:11:17 +02:00
if (ec !== null) {
parseAndMergeCategories(ec, customEmojiFolderRoot);
}
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
});
parseAndMergeCategories('', customEmojiFolderRoot);
watch(q, () => {
2023-01-09 09:27:09 +02:00
if (emojisEl.value) emojisEl.value.scrollTop = 0;
if (q.value === '') {
searchResultCustom.value = [];
searchResultUnicode.value = [];
return;
}
const newQ = q.value.replace(/:/g, '').toLowerCase();
const searchCustom = () => {
const max = 100;
2023-01-16 11:39:58 +02:00
const emojis = customEmojis.value;
const matches = new Set<Misskey.entities.EmojiSimple>();
const exactMatch = emojis.find(emoji => emoji.name === newQ);
if (exactMatch) matches.add(exactMatch);
if (newQ.includes(' ')) { // AND検索
const keywords = newQ.split(' ');
// 名前にキーワードが含まれている
for (const emoji of emojis) {
if (keywords.every(keyword => emoji.name.includes(keyword))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
if (matches.size >= max) return matches;
// 名前またはエイリアスにキーワードが含まれている
for (const emoji of emojis) {
if (keywords.every(keyword => emoji.name.includes(keyword) || emoji.aliases.some(alias => alias.includes(keyword)))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
} else {
if (customEmojisMap.has(newQ)) {
matches.add(customEmojisMap.get(newQ)!);
}
if (matches.size >= max) return matches;
for (const emoji of emojis) {
if (emoji.aliases.some(alias => alias === newQ)) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
if (matches.size >= max) return matches;
for (const emoji of emojis) {
if (emoji.name.startsWith(newQ)) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
if (matches.size >= max) return matches;
for (const emoji of emojis) {
if (emoji.aliases.some(alias => alias.startsWith(newQ))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
if (matches.size >= max) return matches;
for (const emoji of emojis) {
if (emoji.name.includes(newQ)) {
matches.add(emoji);
if (matches.size >= max) break;
}
2021-02-27 18:09:59 +02:00
}
if (matches.size >= max) return matches;
for (const emoji of emojis) {
if (emoji.aliases.some(alias => alias.includes(newQ))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
}
return matches;
};
const searchUnicode = () => {
const max = 100;
const emojis = emojilist;
const matches = new Set<UnicodeEmojiDef>();
const exactMatch = emojis.find(emoji => emoji.name === newQ);
if (exactMatch) matches.add(exactMatch);
if (newQ.includes(' ')) { // AND検索
const keywords = newQ.split(' ');
for (const emoji of emojis) {
if (keywords.every(keyword => emoji.name.includes(keyword))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
if (matches.size >= max) return matches;
for (const index of Object.values(defaultStore.state.additionalUnicodeEmojiIndexes)) {
for (const emoji of emojis) {
if (keywords.every(keyword => index[emoji.char].some(k => k.includes(keyword)))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
}
} else {
for (const emoji of emojis) {
if (emoji.name.startsWith(newQ)) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
if (matches.size >= max) return matches;
for (const index of Object.values(defaultStore.state.additionalUnicodeEmojiIndexes)) {
for (const emoji of emojis) {
if (index[emoji.char].some(k => k.startsWith(newQ))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
}
for (const emoji of emojis) {
if (emoji.name.includes(newQ)) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
if (matches.size >= max) return matches;
for (const index of Object.values(defaultStore.state.additionalUnicodeEmojiIndexes)) {
for (const emoji of emojis) {
if (index[emoji.char].some(k => k.includes(newQ))) {
matches.add(emoji);
if (matches.size >= max) break;
}
}
}
}
return matches;
};
2023-05-18 14:17:32 +03:00
searchResultCustom.value = Array.from(searchCustom()).filter(filterAvailable);
searchResultUnicode.value = Array.from(searchUnicode());
});
function filterAvailable(emoji: Misskey.entities.EmojiSimple): boolean {
2023-05-18 14:17:32 +03:00
return (emoji.roleIdsThatCanBeUsedThisEmojiAsReaction == null || emoji.roleIdsThatCanBeUsedThisEmojiAsReaction.length === 0) || ($i && $i.roles.some(r => emoji.roleIdsThatCanBeUsedThisEmojiAsReaction.includes(r.id)));
}
function focus() {
if (!['smartphone', 'tablet'].includes(deviceKind) && !isTouchUsing) {
2023-01-09 10:04:52 +02:00
searchEl.value?.focus({
preventScroll: true,
});
}
}
function reset() {
2023-01-09 09:27:09 +02:00
if (emojisEl.value) emojisEl.value.scrollTop = 0;
q.value = '';
}
function getKey(emoji: string | Misskey.entities.EmojiSimple | UnicodeEmojiDef): string {
return typeof emoji === 'string' ? emoji : 'char' in emoji ? emoji.char : `:${emoji.name}:`;
}
/** @see MkEmojiPicker.section.vue */
function computeButtonTitle(ev: MouseEvent): void {
const elm = ev.target as HTMLElement;
const emoji = elm.dataset.emoji as string;
elm.title = getEmojiName(emoji) ?? emoji;
}
function chosen(emoji: any, ev?: MouseEvent) {
2022-01-28 04:53:12 +02:00
const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined;
if (el) {
const rect = el.getBoundingClientRect();
const x = rect.left + (el.offsetWidth / 2);
const y = rect.top + (el.offsetHeight / 2);
2023-01-01 05:28:30 +02:00
os.popup(MkRippleEffect, { x, y }, {}, 'end');
}
const key = getKey(emoji);
emit('chosen', key);
// 最近使った絵文字更新
if (!pinned.value?.includes(key)) {
let recents = defaultStore.state.recentlyUsedEmojis;
recents = recents.filter((emoji: any) => emoji !== key);
recents.unshift(key);
defaultStore.set('recentlyUsedEmojis', recents.splice(0, 32));
}
}
function input(): void {
// Using custom input event instead of v-model to respond immediately on
// Android, where composition happens on all languages
// (v-model does not update during composition)
2023-01-09 10:04:52 +02:00
q.value = searchEl.value?.value.trim() ?? '';
}
function paste(event: ClipboardEvent): void {
const pasted = event.clipboardData?.getData('text') ?? '';
if (done(pasted)) {
event.preventDefault();
}
}
2023-02-06 14:05:33 +02:00
function onEnter(ev: KeyboardEvent) {
if (ev.isComposing || ev.key === 'Process' || ev.keyCode === 229) return;
done();
}
function done(query?: string): boolean | void {
if (query == null) query = q.value;
if (query == null || typeof query !== 'string') return;
const q2 = query.replace(/:/g, '');
const exactMatchCustom = customEmojisMap.get(q2);
if (exactMatchCustom) {
chosen(exactMatchCustom);
return true;
}
const exactMatchUnicode = emojilist.find(emoji => emoji.char === q2 || emoji.name === q2);
if (exactMatchUnicode) {
chosen(exactMatchUnicode);
return true;
}
if (searchResultCustom.value.length > 0) {
chosen(searchResultCustom.value[0]);
return true;
}
if (searchResultUnicode.value.length > 0) {
chosen(searchResultUnicode.value[0]);
return true;
}
}
onMounted(() => {
focus();
});
defineExpose({
focus,
reset,
});
</script>
<style lang="scss" scoped>
.omfetrab {
2020-11-14 04:47:30 +02:00
$pad: 8px;
display: flex;
flex-direction: column;
&.s1 {
--eachSize: 40px;
}
&.s2 {
--eachSize: 45px;
}
&.s3 {
--eachSize: 50px;
2020-11-18 05:09:14 +02:00
}
&.w1 {
width: calc((var(--eachSize) * 5) + (#{$pad} * 2));
--columns: 1fr 1fr 1fr 1fr 1fr;
2020-11-18 05:09:14 +02:00
}
&.w2 {
width: calc((var(--eachSize) * 6) + (#{$pad} * 2));
--columns: 1fr 1fr 1fr 1fr 1fr 1fr;
2020-11-18 05:09:14 +02:00
}
&.w3 {
width: calc((var(--eachSize) * 7) + (#{$pad} * 2));
--columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
2020-11-18 05:09:14 +02:00
}
&.w4 {
width: calc((var(--eachSize) * 8) + (#{$pad} * 2));
--columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
}
&.w5 {
width: calc((var(--eachSize) * 9) + (#{$pad} * 2));
--columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
}
2020-11-18 05:09:14 +02:00
&.h1 {
height: calc((var(--eachSize) * 4) + (#{$pad} * 2));
2020-11-18 05:09:14 +02:00
}
&.h2 {
height: calc((var(--eachSize) * 6) + (#{$pad} * 2));
2020-11-18 05:09:14 +02:00
}
&.h3 {
height: calc((var(--eachSize) * 8) + (#{$pad} * 2));
}
&.h4 {
height: calc((var(--eachSize) * 10) + (#{$pad} * 2));
}
&.asDrawer {
width: 100% !important;
> .emojis {
::v-deep(section) {
2021-12-17 09:14:43 +02:00
> header {
height: 32px;
line-height: 32px;
padding: 0 12px;
font-size: 15px;
}
> .body {
display: grid;
grid-template-columns: var(--columns);
font-size: 30px;
> .item {
2023-01-07 07:44:50 +02:00
aspect-ratio: 1 / 1;
width: auto;
height: auto;
min-width: 0;
}
}
}
}
}
&.asWindow {
width: 100% !important;
height: 100% !important;
> .emojis {
::v-deep(section) {
> .body {
display: grid;
grid-template-columns: var(--columns);
font-size: 30px;
> .item {
aspect-ratio: 1 / 1;
width: auto;
height: auto;
min-width: 0;
}
}
}
}
2020-11-14 04:47:30 +02:00
}
> .search {
width: 100%;
padding: 12px;
box-sizing: border-box;
font-size: 1em;
outline: none;
border: none;
background: transparent;
color: var(--fg);
2020-11-14 04:47:30 +02:00
&:not(:focus):not(.filled) {
margin-bottom: env(safe-area-inset-bottom, 0px);
}
2020-11-14 04:47:30 +02:00
&:not(.filled) {
order: 1;
z-index: 2;
box-shadow: 0px -1px 0 0px var(--divider);
}
}
2021-02-27 12:53:20 +02:00
> .tabs {
display: flex;
display: none;
> .tab {
flex: 1;
height: 38px;
border-top: solid 0.5px var(--divider);
2021-02-27 12:53:20 +02:00
&.active {
border-top: solid 1px var(--accent);
color: var(--accent);
}
}
}
> .emojis {
height: 100%;
overflow-y: auto;
overflow-x: hidden;
2020-11-14 04:47:30 +02:00
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
> .group {
2021-02-27 12:53:20 +02:00
&:not(.index) {
padding: 4px 0 8px 0;
border-top: solid 0.5px var(--divider);
2021-02-27 12:53:20 +02:00
}
> header {
/*position: sticky;
top: 0;
left: 0;*/
height: 32px;
line-height: 32px;
z-index: 2;
padding: 0 8px;
font-size: 12px;
}
}
2021-02-27 12:53:20 +02:00
::v-deep(section) {
> header {
position: sticky;
top: 0;
left: 0;
feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように (#12132) * Update CHANGELOG.md * Feat:emoji picker folder select * Fix: lint error * Fix: lint error 2 * Fix: lint error 3 * カスタム絵文字のカテゴリ表示部分が長かったので短くした * エフェクトが壊れて出ないのを修正 * padding 18px -> 9px * Update CHANGELOG.md * Revert: en-US.yml * chg: Folder -> folder * chg: isChildrenExits -> isChildren * chg: isChildren -> categoryFolderFlag * カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応 * 特定のパターンのカテゴリ名でピッカーに出てこないのを修正 「i18n.ts.other」や「/」始まりの場合壊れる * chg: categoryFolderFlag -> hasChildSection * code format * Del: ti-fw * fix * 絵文字とフォルダの表示順序入れ替え * ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした * fix lint * カテゴリの名前が長いと表示がおかしくなる問題を修正 Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com> Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com> Co-authored-by: nenohi <kimutipartylove@gmail.com> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: rinsuki <428rinsuki+git@gmail.com> Co-authored-by: FineArchs <133759614+FineArchs@users.noreply.github.com> Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
2023-12-02 08:26:46 +02:00
line-height: 28px;
z-index: 1;
2021-02-27 12:53:20 +02:00
padding: 0 8px;
font-size: 12px;
2021-02-27 12:53:20 +02:00
cursor: pointer;
&:hover {
color: var(--accent);
}
}
> .body {
2021-02-27 12:53:20 +02:00
position: relative;
2020-11-14 04:47:30 +02:00
padding: $pad;
> .item {
position: relative;
padding: 0;
2020-11-18 05:09:14 +02:00
width: var(--eachSize);
height: var(--eachSize);
contain: strict;
2020-11-14 04:47:30 +02:00
border-radius: 4px;
font-size: 24px;
2021-10-02 20:46:58 +03:00
&:focus-visible {
outline: solid 2px var(--focus);
z-index: 1;
}
2020-11-14 04:47:30 +02:00
&:hover {
background: rgba(0, 0, 0, 0.05);
}
2020-11-14 04:47:30 +02:00
&:active {
background: var(--accent);
box-shadow: inset 0 0.15em 0.3em rgba(27, 31, 35, 0.15);
}
> .emoji {
2020-11-14 04:47:30 +02:00
height: 1.25em;
vertical-align: -.25em;
pointer-events: none;
width: 100%;
object-fit: contain;
}
}
}
&.result {
border-bottom: solid 0.5px var(--divider);
2020-11-14 04:47:30 +02:00
&:empty {
display: none;
}
}
}
}
}
</style>