2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2021-09-17 15:39:15 +02:00
|
|
|
<template>
|
2023-08-11 12:04:15 +02:00
|
|
|
<MkStickyContainer>
|
2023-10-14 10:00:14 +02:00
|
|
|
<template #header>
|
|
|
|
<MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/>
|
|
|
|
</template>
|
2023-08-11 12:04:15 +02:00
|
|
|
<MkSpacer v-if="tab === 'emojis'" :contentMax="1000" :marginMin="20">
|
2023-10-14 10:00:14 +02:00
|
|
|
<MkButton
|
|
|
|
v-if="$i && ($i.isModerator || $i.policies.canManageCustomEmojis)" primary link
|
|
|
|
to="/custom-emojis-manager"
|
|
|
|
>
|
|
|
|
{{ i18n.ts.manageCustomEmojis }}
|
|
|
|
</MkButton>
|
|
|
|
<MkButton
|
|
|
|
v-if="$i && (!$i.isModerator || !$i.policies.canManageCustomEmojis || $i.policies.canRequestCustomEmojis)"
|
|
|
|
primary style="margin-top: 8px;" @click="edit"
|
|
|
|
>
|
|
|
|
{{ i18n.ts.requestCustomEmojis }}
|
|
|
|
</MkButton>
|
2023-08-11 12:04:15 +02:00
|
|
|
|
|
|
|
<div class="query" style="margin-top: 10px;">
|
2023-10-28 09:06:07 +02:00
|
|
|
<MkInput v-model="q" class="" :placeholder="i18n.ts.search" autocapitalize="off">
|
2023-08-11 12:04:15 +02:00
|
|
|
<template #prefix><i class="ti ti-search"></i></template>
|
|
|
|
</MkInput>
|
|
|
|
|
|
|
|
<!-- たくさんあると邪魔
|
2023-10-14 10:00:14 +02:00
|
|
|
<div class="tags">
|
|
|
|
<span class="tag _button" v-for="tag in customEmojiTags" :class="{ active: selectedTags.has(tag) }" @click="toggleTag(tag)">{{ tag }}</span>
|
|
|
|
</div>
|
|
|
|
-->
|
2021-09-17 15:39:15 +02:00
|
|
|
</div>
|
|
|
|
|
2023-08-11 12:04:15 +02:00
|
|
|
<MkFoldableSection v-if="searchEmojis">
|
|
|
|
<template #header>{{ i18n.ts.searchResult }}</template>
|
|
|
|
<div :class="$style.emojis">
|
|
|
|
<XEmoji v-for="emoji in searchEmojis" :key="emoji.name" :emoji="emoji" :draft="emoji.draft"/>
|
|
|
|
</div>
|
|
|
|
</MkFoldableSection>
|
|
|
|
|
2023-10-14 06:37:50 +02:00
|
|
|
<MkFoldableSection v-for="category in filteredCategories" v-once :key="category">
|
2023-10-14 10:00:14 +02:00
|
|
|
<template #header>{{ category || i18n.ts.other }}</template>
|
2023-08-11 12:04:15 +02:00
|
|
|
<div :class="$style.emojis">
|
2023-10-14 10:00:14 +02:00
|
|
|
<XEmoji
|
|
|
|
v-for="emoji in customEmojis.filter(e => e.category === category && !e.draft)" :key="emoji.name"
|
|
|
|
:emoji="emoji" :draft="emoji.draft"
|
|
|
|
/>
|
2023-08-11 12:04:15 +02:00
|
|
|
</div>
|
|
|
|
</MkFoldableSection>
|
|
|
|
</MkSpacer>
|
2023-10-13 21:51:57 +02:00
|
|
|
|
2023-08-11 12:04:15 +02:00
|
|
|
<MkSpacer v-if="tab === 'draft'" :contentMax="1000" :marginMin="20">
|
2023-05-19 09:20:53 +02:00
|
|
|
<div :class="$style.emojis">
|
2023-10-14 10:00:14 +02:00
|
|
|
<XEmoji v-for="emoji in draftEmojis" :key="emoji.name" :emoji="emoji" :draft="emoji.draft"/>
|
2021-09-17 15:39:15 +02:00
|
|
|
</div>
|
2023-08-11 12:04:15 +02:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2021-09-17 15:39:15 +02:00
|
|
|
</template>
|
|
|
|
|
2023-01-09 07:50:25 +01:00
|
|
|
<script lang="ts" setup>
|
2023-08-11 12:04:15 +02:00
|
|
|
import { watch, defineAsyncComponent, ref, computed } from 'vue';
|
2023-04-01 06:52:07 +02:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-09-06 11:21:49 +02:00
|
|
|
import XEmoji from './emojis.emoji.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-01-07 07:09:46 +01:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
2023-01-09 01:41:25 +01:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
2023-08-11 12:04:15 +02:00
|
|
|
import { customEmojis, customEmojiCategories } from '@/custom-emojis.js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
2023-05-16 17:44:19 +02:00
|
|
|
import * as os from '@/os';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { $i } from '@/account.js';
|
2023-08-11 12:04:15 +02:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
|
|
|
|
let tab = $ref('emojis');
|
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => [{
|
|
|
|
key: 'emojis',
|
|
|
|
title: i18n.ts.list,
|
|
|
|
}, {
|
|
|
|
key: 'draft',
|
|
|
|
title: i18n.ts.draftEmojis,
|
|
|
|
}]);
|
2023-10-14 06:37:50 +02:00
|
|
|
const filteredCategories = computed(() => {
|
2023-10-14 10:00:14 +02:00
|
|
|
return customEmojiCategories.value.filter((category: any) => {
|
2023-10-14 10:33:42 +02:00
|
|
|
return customEmojis.value.some((em: any) => em.category === category && !em.draft);
|
2023-10-14 10:00:14 +02:00
|
|
|
});
|
2023-10-14 06:37:50 +02:00
|
|
|
});
|
2023-08-11 12:04:15 +02:00
|
|
|
definePageMetadata(ref({}));
|
|
|
|
|
2023-01-09 07:50:25 +01:00
|
|
|
let q = $ref('');
|
2023-01-16 10:39:58 +01:00
|
|
|
let searchEmojis = $ref<Misskey.entities.CustomEmoji[]>(null);
|
2023-01-09 07:50:25 +01:00
|
|
|
let selectedTags = $ref(new Set());
|
2023-10-13 21:51:57 +02:00
|
|
|
const draftEmojis = customEmojis.value.filter(emoji => emoji.draft);
|
2023-10-14 10:00:14 +02:00
|
|
|
|
2023-01-09 07:50:25 +01:00
|
|
|
function search() {
|
|
|
|
if ((q === '' || q == null) && selectedTags.size === 0) {
|
|
|
|
searchEmojis = null;
|
|
|
|
return;
|
|
|
|
}
|
2021-09-17 15:39:15 +02:00
|
|
|
|
2023-01-09 07:50:25 +01:00
|
|
|
if (selectedTags.size === 0) {
|
2023-04-14 07:49:41 +02:00
|
|
|
const queryarry = q.match(/\:([a-z0-9_]*)\:/g);
|
|
|
|
|
|
|
|
if (queryarry) {
|
2023-07-08 00:08:16 +02:00
|
|
|
searchEmojis = customEmojis.value.filter(emoji =>
|
2023-05-19 09:20:53 +02:00
|
|
|
queryarry.includes(`:${emoji.name}:`),
|
2023-04-14 07:49:41 +02:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
searchEmojis = customEmojis.value.filter(emoji => emoji.name.includes(q) || emoji.aliases.includes(q));
|
|
|
|
}
|
2023-01-09 07:50:25 +01:00
|
|
|
} else {
|
2023-01-16 10:39:58 +01:00
|
|
|
searchEmojis = customEmojis.value.filter(emoji => (emoji.name.includes(q) || emoji.aliases.includes(q)) && [...selectedTags].every(t => emoji.aliases.includes(t)));
|
2023-01-09 07:50:25 +01:00
|
|
|
}
|
|
|
|
}
|
2021-09-17 15:39:15 +02:00
|
|
|
|
2023-01-09 07:50:25 +01:00
|
|
|
function toggleTag(tag) {
|
|
|
|
if (selectedTags.has(tag)) {
|
|
|
|
selectedTags.delete(tag);
|
|
|
|
} else {
|
|
|
|
selectedTags.add(tag);
|
|
|
|
}
|
|
|
|
}
|
2021-09-17 15:39:15 +02:00
|
|
|
|
2023-05-16 17:44:19 +02:00
|
|
|
const edit = () => {
|
2023-08-18 14:41:33 +02:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkEmojiEditDialog.vue')), {
|
2023-05-16 17:44:19 +02:00
|
|
|
isRequest: true,
|
|
|
|
}, {
|
|
|
|
done: result => {
|
|
|
|
window.location.reload();
|
|
|
|
},
|
|
|
|
}, 'closed');
|
|
|
|
};
|
|
|
|
|
2023-01-09 07:50:25 +01:00
|
|
|
watch($$(q), () => {
|
|
|
|
search();
|
2021-09-17 15:39:15 +02:00
|
|
|
});
|
2023-01-09 07:50:25 +01:00
|
|
|
|
|
|
|
watch($$(selectedTags), () => {
|
|
|
|
search();
|
|
|
|
}, { deep: true });
|
2023-10-13 21:51:57 +02:00
|
|
|
|
|
|
|
definePageMetadata({
|
2023-10-14 10:00:14 +02:00
|
|
|
title: i18n.ts.customEmojis,
|
|
|
|
icon: null,
|
2023-10-13 21:51:57 +02:00
|
|
|
});
|
2021-09-17 15:39:15 +02:00
|
|
|
</script>
|
|
|
|
|
2023-05-19 09:20:53 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.emojis {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: 12px;
|
2021-09-17 15:39:15 +02:00
|
|
|
}
|
|
|
|
</style>
|