2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-04-29 01:57:19 +02:00
|
|
|
<FocusTrap v-bind:active="isActive">
|
|
|
|
<div
|
|
|
|
class="omfetrab"
|
|
|
|
:class="['s' + size, 'w' + width, 'h' + height, { asDrawer }]"
|
|
|
|
:style="{ maxHeight: maxHeight ? maxHeight + 'px' : undefined }"
|
2023-04-29 02:47:57 +02:00
|
|
|
tabindex="-1"
|
2023-04-29 01:57:19 +02:00
|
|
|
>
|
|
|
|
<input
|
|
|
|
ref="search"
|
|
|
|
v-model.trim="q"
|
|
|
|
class="search"
|
|
|
|
data-prevent-emoji-insert
|
|
|
|
:class="{ filled: q != null && q != '' }"
|
|
|
|
:placeholder="i18n.ts.search"
|
|
|
|
type="search"
|
|
|
|
@paste.stop="paste"
|
|
|
|
@keyup.enter="done()"
|
|
|
|
/>
|
|
|
|
<div ref="emojis" class="emojis">
|
|
|
|
<section class="result">
|
|
|
|
<div v-if="searchResultCustom.length > 0" class="body">
|
2023-04-08 02:01:42 +02:00
|
|
|
<button
|
2023-04-29 01:57:19 +02:00
|
|
|
v-for="emoji in searchResultCustom"
|
|
|
|
:key="emoji.id"
|
2023-04-08 02:01:42 +02:00
|
|
|
class="_button item"
|
2023-04-29 01:57:19 +02:00
|
|
|
:title="emoji.name"
|
2023-04-08 02:01:42 +02:00
|
|
|
tabindex="0"
|
|
|
|
@click="chosen(emoji, $event)"
|
|
|
|
>
|
2023-04-29 01:57:19 +02:00
|
|
|
<!--<MkEmoji v-if="emoji.char != null" :emoji="emoji.char"/>-->
|
|
|
|
<img
|
2023-04-08 02:01:42 +02:00
|
|
|
class="emoji"
|
2023-04-29 01:57:19 +02:00
|
|
|
:src="
|
|
|
|
disableShowingAnimatedImages
|
|
|
|
? getStaticImageUrl(emoji.url)
|
|
|
|
: emoji.url
|
|
|
|
"
|
2023-04-08 02:01:42 +02:00
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</div>
|
2023-04-29 01:57:19 +02:00
|
|
|
<div v-if="searchResultUnicode.length > 0" class="body">
|
2023-04-08 02:01:42 +02:00
|
|
|
<button
|
2023-04-29 01:57:19 +02:00
|
|
|
v-for="emoji in searchResultUnicode"
|
|
|
|
:key="emoji.name"
|
2023-04-08 02:01:42 +02:00
|
|
|
class="_button item"
|
2023-04-29 01:57:19 +02:00
|
|
|
:title="emoji.name"
|
|
|
|
tabindex="0"
|
2023-04-08 02:01:42 +02:00
|
|
|
@click="chosen(emoji, $event)"
|
|
|
|
>
|
2023-04-29 01:57:19 +02:00
|
|
|
<MkEmoji class="emoji" :emoji="emoji.char" />
|
2023-04-08 02:01:42 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</section>
|
2023-04-29 01:57:19 +02:00
|
|
|
|
|
|
|
<div v-if="tab === 'index'" class="group index">
|
|
|
|
<section v-if="showPinned">
|
|
|
|
<div class="body">
|
|
|
|
<button
|
|
|
|
v-for="emoji in pinned"
|
|
|
|
:key="emoji"
|
|
|
|
class="_button item"
|
|
|
|
tabindex="0"
|
|
|
|
@click="chosen(emoji, $event)"
|
|
|
|
>
|
|
|
|
<MkEmoji
|
|
|
|
class="emoji"
|
|
|
|
:emoji="emoji"
|
|
|
|
:normal="true"
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<header class="_acrylic">
|
|
|
|
<i class="ph-alarm ph-bold ph-fw ph-lg"></i>
|
|
|
|
{{ i18n.ts.recentUsed }}
|
|
|
|
</header>
|
|
|
|
<div class="body">
|
|
|
|
<button
|
|
|
|
v-for="emoji in recentlyUsedEmojis"
|
|
|
|
:key="emoji"
|
|
|
|
class="_button item"
|
|
|
|
@click="chosen(emoji, $event)"
|
|
|
|
>
|
|
|
|
<MkEmoji
|
|
|
|
class="emoji"
|
|
|
|
:emoji="emoji"
|
|
|
|
:normal="true"
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
<div v-once class="group">
|
|
|
|
<header>{{ i18n.ts.customEmojis }}</header>
|
|
|
|
<XSection
|
|
|
|
v-for="category in customEmojiCategories"
|
|
|
|
:key="'custom:' + category"
|
|
|
|
:initial-shown="false"
|
|
|
|
:emojis="
|
|
|
|
customEmojis
|
|
|
|
.filter((e) => e.category === category)
|
|
|
|
.map((e) => ':' + e.name + ':')
|
|
|
|
"
|
|
|
|
@chosen="chosen"
|
|
|
|
>{{ category || i18n.ts.other }}</XSection
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<div v-once class="group">
|
|
|
|
<header>{{ i18n.ts.emoji }}</header>
|
|
|
|
<XSection
|
|
|
|
v-for="category in categories"
|
|
|
|
:key="category"
|
|
|
|
:emojis="
|
|
|
|
emojilist
|
|
|
|
.filter((e) => e.category === category)
|
|
|
|
.map((e) => e.char)
|
|
|
|
"
|
|
|
|
@chosen="chosen"
|
|
|
|
>{{ category }}</XSection
|
|
|
|
>
|
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
</div>
|
2023-04-29 01:57:19 +02:00
|
|
|
<div class="tabs">
|
|
|
|
<button
|
|
|
|
class="_button tab"
|
|
|
|
:class="{ active: tab === 'index' }"
|
|
|
|
@click="tab = 'index'"
|
2023-04-08 02:01:42 +02:00
|
|
|
>
|
2023-04-29 01:57:19 +02:00
|
|
|
<i class="ph-asterisk ph-bold ph-lg ph-fw ph-lg"></i>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class="_button tab"
|
|
|
|
:class="{ active: tab === 'custom' }"
|
|
|
|
@click="tab = 'custom'"
|
|
|
|
>
|
|
|
|
<i class="ph-smiley ph-bold ph-lg ph-fw ph-lg"></i>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class="_button tab"
|
|
|
|
:class="{ active: tab === 'unicode' }"
|
|
|
|
@click="tab = 'unicode'"
|
2023-04-08 02:01:42 +02:00
|
|
|
>
|
2023-04-29 01:57:19 +02:00
|
|
|
<i class="ph-leaf ph-bold ph-lg ph-fw ph-lg"></i>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class="_button tab"
|
|
|
|
:class="{ active: tab === 'tags' }"
|
|
|
|
@click="tab = 'tags'"
|
|
|
|
>
|
|
|
|
<i class="ph-hash ph-bold ph-lg ph-fw ph-lg"></i>
|
|
|
|
</button>
|
2023-04-08 02:01:42 +02:00
|
|
|
</div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
2023-04-29 01:57:19 +02:00
|
|
|
</FocusTrap>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { ref, computed, watch, onMounted } from "vue";
|
|
|
|
import * as Misskey from "calckey-js";
|
|
|
|
import XSection from "@/components/MkEmojiPicker.section.vue";
|
|
|
|
import {
|
|
|
|
emojilist,
|
|
|
|
UnicodeEmojiDef,
|
|
|
|
unicodeEmojiCategories as categories,
|
|
|
|
} from "@/scripts/emojilist";
|
|
|
|
import { getStaticImageUrl } from "@/scripts/get-static-image-url";
|
|
|
|
import Ripple from "@/components/MkRipple.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { isTouchUsing } from "@/scripts/touch";
|
|
|
|
import { deviceKind } from "@/scripts/device-kind";
|
|
|
|
import { emojiCategories, instance } from "@/instance";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { defaultStore } from "@/store";
|
2023-04-29 01:57:19 +02:00
|
|
|
import { FocusTrap } from 'focus-trap-vue';
|
2023-04-08 02:01:42 +02:00
|
|
|
|
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
showPinned?: boolean;
|
|
|
|
asReactionPicker?: boolean;
|
|
|
|
maxHeight?: number;
|
|
|
|
asDrawer?: boolean;
|
|
|
|
}>(),
|
|
|
|
{
|
|
|
|
showPinned: true,
|
|
|
|
}
|
|
|
|
);
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "chosen", v: string): void;
|
2022-01-18 15:06:16 +01:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const search = ref<HTMLInputElement>();
|
|
|
|
const emojis = ref<HTMLDivElement>();
|
|
|
|
|
|
|
|
const {
|
|
|
|
reactions: pinned,
|
2022-02-11 05:38:47 +01:00
|
|
|
reactionPickerSize,
|
2022-01-18 15:06:16 +01:00
|
|
|
reactionPickerWidth,
|
|
|
|
reactionPickerHeight,
|
|
|
|
disableShowingAnimatedImages,
|
|
|
|
recentlyUsedEmojis,
|
|
|
|
} = defaultStore.reactiveState;
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const size = computed(() =>
|
|
|
|
props.asReactionPicker ? reactionPickerSize.value : 1
|
|
|
|
);
|
|
|
|
const width = computed(() =>
|
|
|
|
props.asReactionPicker ? reactionPickerWidth.value : 3
|
|
|
|
);
|
|
|
|
const height = computed(() =>
|
|
|
|
props.asReactionPicker ? reactionPickerHeight.value : 2
|
|
|
|
);
|
2022-01-18 15:06:16 +01:00
|
|
|
const customEmojiCategories = emojiCategories;
|
|
|
|
const customEmojis = instance.emojis;
|
|
|
|
const q = ref<string | null>(null);
|
|
|
|
const searchResultCustom = ref<Misskey.entities.CustomEmoji[]>([]);
|
|
|
|
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
|
2023-04-08 02:01:42 +02:00
|
|
|
const tab = ref<"index" | "custom" | "unicode" | "tags">("index");
|
2022-01-18 15:06:16 +01:00
|
|
|
|
|
|
|
watch(q, () => {
|
|
|
|
if (emojis.value) emojis.value.scrollTop = 0;
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
if (q.value == null || q.value === "") {
|
2022-01-18 15:06:16 +01:00
|
|
|
searchResultCustom.value = [];
|
|
|
|
searchResultUnicode.value = [];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const newQ = q.value.replace(/:/g, "").toLowerCase();
|
2022-01-18 15:06:16 +01:00
|
|
|
|
|
|
|
const searchCustom = () => {
|
|
|
|
const max = 8;
|
|
|
|
const emojis = customEmojis;
|
|
|
|
const matches = new Set<Misskey.entities.CustomEmoji>();
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const exactMatch = emojis.find((emoji) => emoji.name === newQ);
|
2022-01-18 15:06:16 +01:00
|
|
|
if (exactMatch) matches.add(exactMatch);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
if (newQ.includes(" ")) {
|
|
|
|
// AND検索
|
|
|
|
const keywords = newQ.split(" ");
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
// 名前にキーワードが含まれている
|
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (keywords.every((keyword) => emoji.name.includes(keyword))) {
|
2022-01-18 15:06:16 +01:00
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
if (matches.size >= max) return matches;
|
2020-11-07 13:28:28 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
// 名前またはエイリアスにキーワードが含まれている
|
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (
|
|
|
|
keywords.every(
|
|
|
|
(keyword) =>
|
|
|
|
emoji.name.includes(keyword) ||
|
|
|
|
emoji.aliases.some((alias) =>
|
|
|
|
alias.includes(keyword)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
2022-01-18 15:06:16 +01:00
|
|
|
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;
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
if (matches.size >= max) return matches;
|
2020-11-07 13:28:28 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (emoji.aliases.some((alias) => alias.startsWith(newQ))) {
|
2022-01-18 15:06:16 +01:00
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (matches.size >= max) return matches;
|
2020-11-07 02:43:27 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
for (const emoji of emojis) {
|
|
|
|
if (emoji.name.includes(newQ)) {
|
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2021-02-27 17:09:59 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
if (matches.size >= max) return matches;
|
|
|
|
|
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (emoji.aliases.some((alias) => alias.includes(newQ))) {
|
2022-01-18 15:06:16 +01:00
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
};
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const searchUnicode = () => {
|
|
|
|
const max = 8;
|
|
|
|
const emojis = emojilist;
|
|
|
|
const matches = new Set<UnicodeEmojiDef>();
|
2020-11-07 02:43:27 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const exactMatch = emojis.find((emoji) => emoji.name === newQ);
|
2022-01-18 15:06:16 +01:00
|
|
|
if (exactMatch) matches.add(exactMatch);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
if (newQ.includes(" ")) {
|
|
|
|
// AND検索
|
|
|
|
const keywords = newQ.split(" ");
|
2022-01-18 15:06:16 +01:00
|
|
|
|
|
|
|
// 名前にキーワードが含まれている
|
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (keywords.every((keyword) => emoji.name.includes(keyword))) {
|
2022-01-18 15:06:16 +01:00
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2020-11-08 05:58:16 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
if (matches.size >= max) return matches;
|
2020-11-07 02:43:27 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
// 名前またはエイリアスにキーワードが含まれている
|
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (
|
|
|
|
keywords.every(
|
|
|
|
(keyword) =>
|
|
|
|
emoji.name.includes(keyword) ||
|
|
|
|
emoji.keywords.some((alias) =>
|
|
|
|
alias.includes(keyword)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
2022-01-18 15:06:16 +01:00
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
} else {
|
|
|
|
for (const emoji of emojis) {
|
|
|
|
if (emoji.name.startsWith(newQ)) {
|
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
if (matches.size >= max) return matches;
|
|
|
|
|
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (
|
|
|
|
emoji.keywords.some((keyword) => keyword.startsWith(newQ))
|
|
|
|
) {
|
2022-01-18 15:06:16 +01:00
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
if (matches.size >= max) return matches;
|
|
|
|
|
|
|
|
for (const emoji of emojis) {
|
|
|
|
if (emoji.name.includes(newQ)) {
|
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2020-11-07 13:33:36 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
if (matches.size >= max) return matches;
|
|
|
|
|
|
|
|
for (const emoji of emojis) {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (emoji.keywords.some((keyword) => keyword.includes(newQ))) {
|
2022-01-18 15:06:16 +01:00
|
|
|
matches.add(emoji);
|
|
|
|
if (matches.size >= max) break;
|
|
|
|
}
|
2020-11-07 13:33:36 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
};
|
|
|
|
|
|
|
|
searchResultCustom.value = Array.from(searchCustom());
|
|
|
|
searchResultUnicode.value = Array.from(searchUnicode());
|
|
|
|
});
|
|
|
|
|
|
|
|
function focus() {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (!["smartphone", "tablet"].includes(deviceKind) && !isTouchUsing) {
|
2022-01-18 15:06:16 +01:00
|
|
|
search.value?.focus({
|
2022-07-05 16:01:23 +02:00
|
|
|
preventScroll: true,
|
2022-01-18 15:06:16 +01:00
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function reset() {
|
|
|
|
if (emojis.value) emojis.value.scrollTop = 0;
|
2023-04-08 02:01:42 +02:00
|
|
|
q.value = "";
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
function getKey(
|
|
|
|
emoji: string | Misskey.entities.CustomEmoji | UnicodeEmojiDef
|
|
|
|
): string {
|
|
|
|
return typeof emoji === "string" ? emoji : emoji.char || `:${emoji.name}:`;
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function chosen(emoji: any, ev?: MouseEvent) {
|
2023-04-08 02:01:42 +02:00
|
|
|
const el =
|
|
|
|
ev &&
|
|
|
|
((ev.currentTarget ?? ev.target) as HTMLElement | null | undefined);
|
2022-01-18 15:06:16 +01:00
|
|
|
if (el) {
|
|
|
|
const rect = el.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x = rect.left + el.offsetWidth / 2;
|
|
|
|
const y = rect.top + el.offsetHeight / 2;
|
|
|
|
os.popup(Ripple, { x, y }, {}, "end");
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const key = getKey(emoji);
|
2023-04-08 02:01:42 +02:00
|
|
|
emit("chosen", key);
|
2022-01-18 15:06:16 +01:00
|
|
|
|
|
|
|
// 最近使った絵文字更新
|
|
|
|
if (!pinned.value.includes(key)) {
|
|
|
|
let recents = defaultStore.state.recentlyUsedEmojis;
|
2022-05-07 10:00:05 +02:00
|
|
|
recents = recents.filter((emoji: any) => emoji !== key);
|
2022-01-18 15:06:16 +01:00
|
|
|
recents.unshift(key);
|
2023-04-08 02:01:42 +02:00
|
|
|
defaultStore.set("recentlyUsedEmojis", recents.splice(0, 32));
|
2022-01-18 15:06:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function paste(event: ClipboardEvent) {
|
2023-04-08 02:01:42 +02:00
|
|
|
const paste = (event.clipboardData || window.clipboardData).getData("text");
|
2022-01-18 15:06:16 +01:00
|
|
|
if (done(paste)) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function done(query?: any): boolean | void {
|
|
|
|
if (query == null) query = q.value;
|
2023-04-08 02:01:42 +02:00
|
|
|
if (query == null || typeof query !== "string") return;
|
2022-01-18 15:06:16 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const q2 = query.replaceAll(":", "");
|
|
|
|
const exactMatchCustom = customEmojis.find((emoji) => emoji.name === q2);
|
2022-01-18 15:06:16 +01:00
|
|
|
if (exactMatchCustom) {
|
|
|
|
chosen(exactMatchCustom);
|
|
|
|
return true;
|
|
|
|
}
|
2023-04-08 02:01:42 +02:00
|
|
|
const exactMatchUnicode = emojilist.find(
|
|
|
|
(emoji) => emoji.char === q2 || emoji.name === q2
|
|
|
|
);
|
2022-01-18 15:06:16 +01:00
|
|
|
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,
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.omfetrab {
|
2020-11-14 03:47:30 +01:00
|
|
|
$pad: 8px;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
2022-02-11 05:38:47 +01:00
|
|
|
&.s1 {
|
|
|
|
--eachSize: 40px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.s2 {
|
|
|
|
--eachSize: 45px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.s3 {
|
|
|
|
--eachSize: 50px;
|
2020-11-18 04:09:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
&.w1 {
|
|
|
|
width: calc((var(--eachSize) * 5) + (#{$pad} * 2));
|
2021-12-16 18:14:40 +01:00
|
|
|
--columns: 1fr 1fr 1fr 1fr 1fr;
|
2020-11-18 04:09:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
&.w2 {
|
|
|
|
width: calc((var(--eachSize) * 6) + (#{$pad} * 2));
|
2021-12-16 18:14:40 +01:00
|
|
|
--columns: 1fr 1fr 1fr 1fr 1fr 1fr;
|
2020-11-18 04:09:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
&.w3 {
|
|
|
|
width: calc((var(--eachSize) * 7) + (#{$pad} * 2));
|
2021-12-16 18:14:40 +01:00
|
|
|
--columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
2020-11-18 04:09:14 +01:00
|
|
|
}
|
|
|
|
|
2022-02-11 05:53:02 +01: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 04:09:14 +01:00
|
|
|
&.h1 {
|
2021-12-16 18:14:40 +01:00
|
|
|
height: calc((var(--eachSize) * 4) + (#{$pad} * 2));
|
2020-11-18 04:09:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
&.h2 {
|
2021-12-16 18:14:40 +01:00
|
|
|
height: calc((var(--eachSize) * 6) + (#{$pad} * 2));
|
2020-11-18 04:09:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
&.h3 {
|
2021-12-16 18:14:40 +01:00
|
|
|
height: calc((var(--eachSize) * 8) + (#{$pad} * 2));
|
|
|
|
}
|
|
|
|
|
2022-02-11 05:53:02 +01:00
|
|
|
&.h4 {
|
|
|
|
height: calc((var(--eachSize) * 10) + (#{$pad} * 2));
|
|
|
|
}
|
|
|
|
|
2021-12-16 18:14:40 +01:00
|
|
|
&.asDrawer {
|
|
|
|
width: 100% !important;
|
|
|
|
|
|
|
|
> .emojis {
|
|
|
|
::v-deep(section) {
|
2021-12-17 08:14:43 +01:00
|
|
|
> header {
|
|
|
|
height: 32px;
|
|
|
|
line-height: 32px;
|
|
|
|
padding: 0 12px;
|
|
|
|
font-size: 15px;
|
|
|
|
}
|
|
|
|
|
2022-07-06 00:30:56 +02:00
|
|
|
> .body {
|
2021-12-16 18:14:40 +01:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: var(--columns);
|
2022-07-06 00:30:56 +02:00
|
|
|
font-size: 30px;
|
2021-12-16 18:14:40 +01:00
|
|
|
|
2022-07-06 00:30:56 +02:00
|
|
|
> .item {
|
2021-12-16 18:14:40 +01:00
|
|
|
aspect-ratio: 1 / 1;
|
|
|
|
width: auto;
|
|
|
|
height: auto;
|
|
|
|
min-width: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-14 03:47:30 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-11-07 02:43:27 +01: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 03:47:30 +01:00
|
|
|
|
|
|
|
&:not(.filled) {
|
|
|
|
order: 1;
|
|
|
|
z-index: 2;
|
|
|
|
box-shadow: 0px -1px 0 0px var(--divider);
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
|
2021-02-27 11:53:20 +01:00
|
|
|
> .tabs {
|
|
|
|
display: flex;
|
|
|
|
display: none;
|
|
|
|
|
|
|
|
> .tab {
|
|
|
|
flex: 1;
|
|
|
|
height: 38px;
|
2021-04-10 05:40:50 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2021-02-27 11:53:20 +01:00
|
|
|
|
|
|
|
&.active {
|
|
|
|
border-top: solid 1px var(--accent);
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
> .emojis {
|
2021-12-16 18:14:40 +01:00
|
|
|
height: 100%;
|
2020-01-29 20:37:25 +01:00
|
|
|
overflow-y: auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
2020-11-14 03:47:30 +01:00
|
|
|
scrollbar-width: none;
|
|
|
|
|
|
|
|
&::-webkit-scrollbar {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2022-07-06 00:30:56 +02:00
|
|
|
> .group {
|
2021-02-27 11:53:20 +01:00
|
|
|
&:not(.index) {
|
|
|
|
padding: 4px 0 8px 0;
|
2021-04-10 05:40:50 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2021-02-27 11:53:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
> header {
|
|
|
|
/*position: sticky;
|
|
|
|
top: 0;
|
|
|
|
left: 0;*/
|
|
|
|
height: 32px;
|
|
|
|
line-height: 32px;
|
|
|
|
z-index: 2;
|
|
|
|
padding: 0 8px;
|
|
|
|
font-size: 12px;
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
|
2021-02-27 11:53:20 +01:00
|
|
|
::v-deep(section) {
|
2020-11-07 02:43:27 +01:00
|
|
|
> header {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
2021-02-27 11:53:20 +01:00
|
|
|
height: 32px;
|
|
|
|
line-height: 32px;
|
2020-11-07 02:43:27 +01:00
|
|
|
z-index: 1;
|
2021-02-27 11:53:20 +01:00
|
|
|
padding: 0 8px;
|
2020-11-07 02:43:27 +01:00
|
|
|
font-size: 12px;
|
2021-02-27 11:53:20 +01:00
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-07-06 00:30:56 +02:00
|
|
|
> .body {
|
2021-02-27 11:53:20 +01:00
|
|
|
position: relative;
|
2020-11-14 03:47:30 +01:00
|
|
|
padding: $pad;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-07-06 00:30:56 +02:00
|
|
|
> .item {
|
2020-11-07 02:43:27 +01:00
|
|
|
position: relative;
|
|
|
|
padding: 0;
|
2020-11-18 04:09:14 +01:00
|
|
|
width: var(--eachSize);
|
|
|
|
height: var(--eachSize);
|
2022-07-06 00:30:56 +02:00
|
|
|
contain: strict;
|
2020-11-14 03:47:30 +01:00
|
|
|
border-radius: 4px;
|
2022-07-06 00:30:56 +02:00
|
|
|
font-size: 24px;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2021-10-02 19:46:58 +02:00
|
|
|
&:focus-visible {
|
2020-11-07 02:43:27 +01:00
|
|
|
outline: solid 2px var(--focus);
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
|
2020-11-14 03:47:30 +01:00
|
|
|
&:hover {
|
|
|
|
background: rgba(0, 0, 0, 0.05);
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
|
|
|
|
2020-11-14 03:47:30 +01:00
|
|
|
&:active {
|
|
|
|
background: var(--accent);
|
|
|
|
box-shadow: inset 0 0.15em 0.3em rgba(27, 31, 35, 0.15);
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-07-06 00:30:56 +02:00
|
|
|
> .emoji {
|
2020-11-14 03:47:30 +01:00
|
|
|
height: 1.25em;
|
2023-04-08 02:01:42 +02:00
|
|
|
vertical-align: -0.25em;
|
2020-11-07 02:43:27 +01:00
|
|
|
pointer-events: none;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-11-07 02:43:27 +01:00
|
|
|
&.result {
|
2021-04-10 05:40:50 +02:00
|
|
|
border-bottom: solid 0.5px var(--divider);
|
2020-11-14 03:47:30 +01:00
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-11-07 02:43:27 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|