fix: クソフォルダ改変
This commit is contained in:
parent
7313e13397
commit
1375a6fbdb
|
@ -6,9 +6,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template>
|
||||
<!-- このコンポーネントの要素のclassは親から利用されるのでむやみに弄らないこと -->
|
||||
<!-- フォルダの中にはカスタム絵文字だけ(Unicode絵文字もこっち) -->
|
||||
<section v-if="!hasChildSection" v-panel style="border-radius: 6px; border-bottom: 0.5px solid var(--divider);">
|
||||
<header class="_acrylic" @click="shown = !shown">
|
||||
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-icons"></i>:{{ emojis.length }})
|
||||
<section v-if="!hasChildSection" style="border-radius: 6px; padding-top: 9px;">
|
||||
<header class="_acrylic" @click="shown = !shown" style="border-radius: 6px;">
|
||||
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> ({{ emojis.length }})
|
||||
</header>
|
||||
<div v-if="shown" class="body">
|
||||
<button
|
||||
|
@ -25,16 +25,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</div>
|
||||
</section>
|
||||
<!-- フォルダの中にはカスタム絵文字やフォルダがある -->
|
||||
<section v-else v-panel style="border-radius: 6px; border-bottom: 0.5px solid var(--divider);">
|
||||
<section v-else style="border-radius: 6px; padding-top: 9px;">
|
||||
<header class="_acrylic" @click="shown = !shown">
|
||||
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-folder ti-fw"></i>:{{ customEmojiTree.length }} <i class="ti ti-icons ti-fw"></i>:{{ emojis.length }})
|
||||
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (フォルダー)
|
||||
</header>
|
||||
<div v-if="shown" style="padding-left: 9px; ">
|
||||
<MkEmojiPickerSection
|
||||
v-for="child in customEmojiTree"
|
||||
:key="`custom:${child.value}`"
|
||||
:initialShown="initialShown"
|
||||
:emojis="computed(() => customEmojis.filter(e => e.category === child.category).map(e => `:${e.name}:`))"
|
||||
:emojis="computed(() => customEmojis.filter(e => e.category === child.category || e.category === child.category+'/'+child.category).map(e => `:${e.name}:`))"
|
||||
:hasChildSection="child.children.length !== 0"
|
||||
:customEmojiTree="child.children"
|
||||
@chosen="nestedChosen"
|
||||
|
@ -51,7 +51,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
@pointerenter="computeButtonTitle"
|
||||
@click="emit('chosen', emoji, $event)"
|
||||
>
|
||||
jhkjh
|
||||
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
|
||||
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
|
||||
</button>
|
||||
|
@ -73,27 +72,13 @@ const props = defineProps<{
|
|||
hasChildSection?: boolean;
|
||||
customEmojiTree?: CustomEmojiFolderTree[];
|
||||
}>();
|
||||
|
||||
console.log(props.customEmojiTree);
|
||||
const emit = defineEmits<{
|
||||
(ev: 'chosen', v: string, event: MouseEvent): void;
|
||||
}>();
|
||||
|
||||
const toggleShown = (index) => {
|
||||
shown_fold.value[index] = !shown_fold.value[index];
|
||||
|
||||
};
|
||||
|
||||
const toggleShown_fol = () => {
|
||||
for (let i = 0; i < shown_fold.value.length; i++) {
|
||||
shown_fold.value[i] = false;
|
||||
}
|
||||
shown_fol.value = !shown_fol.value;
|
||||
};
|
||||
|
||||
const emojis = computed(() => Array.isArray(props.emojis) ? props.emojis : props.emojis.value);
|
||||
const shown_fold = ref(Array(props.category === undefined ? 0 : props.category.length).fill(false));
|
||||
const shown = ref(!!props.initialShown);
|
||||
const shown_fol = ref(!!props.initialShown);
|
||||
|
||||
/** @see MkEmojiPicker.vue */
|
||||
function computeButtonTitle(ev: MouseEvent): void {
|
||||
|
|
|
@ -76,7 +76,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
v-for="child in customEmojiFolderRoot.children"
|
||||
:key="`custom:${child.value}`"
|
||||
:initialShown="false"
|
||||
:emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
|
||||
:emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value && !e.category || e.category === child.category+'/'+child.category && !e.category).filter(filterAvailable).map(e => `:${e.name}:`))"
|
||||
:hasChildSection="child.children.length !== 0"
|
||||
:customEmojiTree="child.children"
|
||||
@chosen="chosen"
|
||||
|
@ -156,21 +156,25 @@ 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('/').map(p => p.trim());
|
||||
let currentNode: CustomEmojiFolderTree = root;
|
||||
const parts = input.split('/').map(p => p.trim()); // スラッシュで区切って配列にしてる
|
||||
let currentNode: CustomEmojiFolderTree = root; // currentNode は 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;
|
||||
if (parts.length === 1 && parts[0] !== '') { // parts が 1 つで空じゃなかったら
|
||||
parts.push(parts[0]) // parts に parts[0] を追加 (test category だったら test/test category になる)
|
||||
}
|
||||
|
||||
currentNode = existingNode;
|
||||
for (const part of parts) { // parts を順番に見ていく
|
||||
let existingNode = currentNode.children.find((node) => node.value === part); // currentNode の children から part と同じ value を持つ node を探す
|
||||
|
||||
if (!existingNode) { // なかったら
|
||||
const newNode: CustomEmojiFolderTree = { value: part, category: input, children: [] }; // 新しい node を作る
|
||||
|
||||
currentNode.children.push(newNode); // currentNode の children に newNode を追加
|
||||
existingNode = newNode; // existingNode に newNode を代入
|
||||
}
|
||||
|
||||
currentNode = existingNode; // currentNode に existingNode を代入
|
||||
}
|
||||
return currentNode;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue