mirror of
https://github.com/kokonect-link/cherrypick
synced 2025-01-19 08:13:14 +09:00
Feat:emoji picker folder select
This commit is contained in:
parent
3043b5256d
commit
e1b45bd400
@ -311,6 +311,7 @@ folderName: "Folder name"
|
|||||||
createFolder: "Create a folder"
|
createFolder: "Create a folder"
|
||||||
renameFolder: "Rename this folder"
|
renameFolder: "Rename this folder"
|
||||||
deleteFolder: "Delete this folder"
|
deleteFolder: "Delete this folder"
|
||||||
|
Folder: "Folder"
|
||||||
addFile: "Add a file"
|
addFile: "Add a file"
|
||||||
emptyDrive: "Your Drive is empty"
|
emptyDrive: "Your Drive is empty"
|
||||||
emptyFolder: "This folder is empty"
|
emptyFolder: "This folder is empty"
|
||||||
|
1
locales/index.d.ts
vendored
1
locales/index.d.ts
vendored
@ -314,6 +314,7 @@ export interface Locale {
|
|||||||
"createFolder": string;
|
"createFolder": string;
|
||||||
"renameFolder": string;
|
"renameFolder": string;
|
||||||
"deleteFolder": string;
|
"deleteFolder": string;
|
||||||
|
"Folder": string;
|
||||||
"addFile": string;
|
"addFile": string;
|
||||||
"emptyDrive": string;
|
"emptyDrive": string;
|
||||||
"emptyFolder": string;
|
"emptyFolder": string;
|
||||||
|
@ -311,6 +311,7 @@ folderName: "フォルダー名"
|
|||||||
createFolder: "フォルダーを作成"
|
createFolder: "フォルダーを作成"
|
||||||
renameFolder: "フォルダー名を変更"
|
renameFolder: "フォルダー名を変更"
|
||||||
deleteFolder: "フォルダーを削除"
|
deleteFolder: "フォルダーを削除"
|
||||||
|
Folder: "フォルダー"
|
||||||
addFile: "ファイルを追加"
|
addFile: "ファイルを追加"
|
||||||
emptyDrive: "ドライブは空です"
|
emptyDrive: "ドライブは空です"
|
||||||
emptyFolder: "フォルダーは空です"
|
emptyFolder: "フォルダーは空です"
|
||||||
|
@ -5,7 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- このコンポーネントの要素のclassは親から利用されるのでむやみに弄らないこと -->
|
<!-- このコンポーネントの要素のclassは親から利用されるのでむやみに弄らないこと -->
|
||||||
<section>
|
<!-- フォルダの中にはカスタム絵文字だけ(Unicode絵文字もこっち) -->
|
||||||
|
<section v-if="!isChildrenExits">
|
||||||
<header class="_acrylic" @click="shown = !shown">
|
<header class="_acrylic" @click="shown = !shown">
|
||||||
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> ({{ emojis.length }})
|
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> ({{ emojis.length }})
|
||||||
</header>
|
</header>
|
||||||
@ -23,15 +24,54 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<!-- フォルダの中にはカスタム絵文字やフォルダがある -->
|
||||||
|
<section v-else>
|
||||||
|
<header class="_acrylic" @click="shown = !shown">
|
||||||
|
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> ({{ i18n.ts.Folder }} : {{customEmojiTree.length}} {{ i18n.ts.customEmojis}} : {{emojis.length}})
|
||||||
|
</header>
|
||||||
|
<div v-if="shown" class="body">
|
||||||
|
<button
|
||||||
|
v-for="emoji in emojis"
|
||||||
|
:key="emoji"
|
||||||
|
:data-emoji="emoji"
|
||||||
|
class="_button item"
|
||||||
|
@pointerenter="computeButtonTitle"
|
||||||
|
@click="emit('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>
|
||||||
|
<div v-if="shown" style="padding-left: 18px;">
|
||||||
|
<!-- TODO: 再帰へのイベントの渡し方が微妙なのか反応はするがエフェクトが出ない -->
|
||||||
|
<MkEmojiPickerSection
|
||||||
|
v-if="shown"
|
||||||
|
v-for="child in customEmojiTree"
|
||||||
|
:key="`custom:${child.value}`"
|
||||||
|
:initialShown="initialShown"
|
||||||
|
:emojis="computed(() => customEmojis.filter(e => e.category === child.category).map(e => `:${e.name}:`))"
|
||||||
|
:isChildrenExits="child.children.length!==0"
|
||||||
|
:customEmojiTree="child.children"
|
||||||
|
@chosen="emit('chosen', $event)"
|
||||||
|
>
|
||||||
|
{{ child.value }}
|
||||||
|
</MkEmojiPickerSection>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, Ref } from 'vue';
|
import { ref, computed, Ref } from 'vue';
|
||||||
import { getEmojiName } from '@/scripts/emojilist.js';
|
import {CustomEmojiFolderTree, getEmojiName} from '@/scripts/emojilist.js';
|
||||||
|
import {i18n} from "../i18n.js";
|
||||||
|
import {customEmojis} from "@/custom-emojis.js";
|
||||||
|
import MkEmojiPickerSection from "@/components/MkEmojiPicker.section.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
emojis: string[] | Ref<string[]>;
|
emojis: string[] | Ref<string[]>;
|
||||||
initialShown?: boolean;
|
initialShown?: boolean;
|
||||||
|
isChildrenExits?: boolean;
|
||||||
|
customEmojiTree?: CustomEmojiFolderTree[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -48,5 +88,4 @@ function computeButtonTitle(ev: MouseEvent): void {
|
|||||||
const emoji = elm.dataset.emoji as string;
|
const emoji = elm.dataset.emoji as string;
|
||||||
elm.title = getEmojiName(emoji) ?? emoji;
|
elm.title = getEmojiName(emoji) ?? emoji;
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -73,18 +73,20 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<div v-once class="group">
|
<div v-once class="group">
|
||||||
<header class="_acrylic">{{ i18n.ts.customEmojis }}</header>
|
<header class="_acrylic">{{ i18n.ts.customEmojis }}</header>
|
||||||
<XSection
|
<XSection
|
||||||
v-for="category in customEmojiCategories"
|
v-for="child in customEmojiFolderRoot.children"
|
||||||
:key="`custom:${category}`"
|
:key="`custom:${child.value}`"
|
||||||
:initialShown="false"
|
:initialShown="false"
|
||||||
:emojis="computed(() => customEmojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category).filter(filterAvailable).map(e => `:${e.name}:`))"
|
:emojis="computed(() => customEmojis.filter(e => child.value === i18n.ts.other ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
|
||||||
|
:isChildrenExits="child.children.length!==0"
|
||||||
|
:customEmojiTree="child.children"
|
||||||
@chosen="chosen"
|
@chosen="chosen"
|
||||||
>
|
>
|
||||||
{{ category || i18n.ts.other }}
|
{{ child.value }}
|
||||||
</XSection>
|
</XSection>
|
||||||
</div>
|
</div>
|
||||||
<div v-once class="group">
|
<div v-once class="group">
|
||||||
<header class="_acrylic">{{ i18n.ts.emoji }}</header>
|
<header class="_acrylic">{{ i18n.ts.emoji }}</header>
|
||||||
<XSection v-for="category in categories" :key="category" :emojis="emojiCharByCategory.get(category) ?? []" @chosen="chosen">{{ category }}</XSection>
|
<XSection v-for="category in categories" :key="category" :emojis="emojiCharByCategory.get(category) ?? []" :isChildrenExits="false" @chosen="chosen">{{ category }}</XSection>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
@ -100,7 +102,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
import { ref, shallowRef, computed, watch, onMounted } from 'vue';
|
import { ref, shallowRef, computed, watch, onMounted } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import XSection from '@/components/MkEmojiPicker.section.vue';
|
import XSection from '@/components/MkEmojiPicker.section.vue';
|
||||||
import { emojilist, emojiCharByCategory, UnicodeEmojiDef, unicodeEmojiCategories as categories, getEmojiName } from '@/scripts/emojilist.js';
|
import {
|
||||||
|
emojilist,
|
||||||
|
emojiCharByCategory,
|
||||||
|
UnicodeEmojiDef,
|
||||||
|
unicodeEmojiCategories as categories,
|
||||||
|
getEmojiName,
|
||||||
|
CustomEmojiFolderTree
|
||||||
|
} from '@/scripts/emojilist.js';
|
||||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { isTouchUsing } from '@/scripts/touch.js';
|
import { isTouchUsing } from '@/scripts/touch.js';
|
||||||
@ -144,6 +153,43 @@ const searchResultCustom = ref<Misskey.entities.CustomEmoji[]>([]);
|
|||||||
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
|
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
|
||||||
const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
|
const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
|
||||||
|
|
||||||
|
|
||||||
|
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };
|
||||||
|
|
||||||
|
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
|
||||||
|
const parts = input.split('/');
|
||||||
|
var category = ""
|
||||||
|
let currentNode: CustomEmojiFolderTree = root;
|
||||||
|
|
||||||
|
for (const part of parts) {
|
||||||
|
if (part) {
|
||||||
|
category += `/${part}`;
|
||||||
|
category = category.replace(/^\//, '');
|
||||||
|
let existingNode = currentNode.children.find((node) => node.value === part);
|
||||||
|
|
||||||
|
if (!existingNode) {
|
||||||
|
const newNode: CustomEmojiFolderTree = { value: part, category, children: [] };
|
||||||
|
currentNode.children.push(newNode);
|
||||||
|
existingNode = newNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentNode = existingNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
customEmojiCategories.value.forEach(e => {
|
||||||
|
if (e !== null){
|
||||||
|
parseAndMergeCategories(e, customEmojiFolderRoot);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
parseAndMergeCategories(i18n.ts.other, customEmojiFolderRoot);
|
||||||
|
|
||||||
|
console.log(customEmojiFolderRoot)
|
||||||
|
|
||||||
watch(q, () => {
|
watch(q, () => {
|
||||||
if (emojisEl.value) emojisEl.value.scrollTop = 0;
|
if (emojisEl.value) emojisEl.value.scrollTop = 0;
|
||||||
|
|
||||||
|
@ -43,3 +43,9 @@ export function getEmojiName(char: string): string | null {
|
|||||||
return emojilist[idx].name;
|
return emojilist[idx].name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CustomEmojiFolderTree {
|
||||||
|
value: string;
|
||||||
|
category: string;
|
||||||
|
children: CustomEmojiFolderTree[];
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user