絵文字ピッカーのカテゴリの階層を表示するように・サブカテゴリを絵文字より上に (MisskeyIO#202)
This commit is contained in:
parent
2bad8941d0
commit
343ae413ae
|
@ -29,6 +29,19 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<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> (<i class="ti ti-folder"></i>:{{ customEmojiTree.length }} <i class="ti ti-icons"></i>:{{ emojis.length }})
|
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-folder"></i>:{{ customEmojiTree.length }} <i class="ti ti-icons"></i>:{{ emojis.length }})
|
||||||
</header>
|
</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}:`))"
|
||||||
|
:hasChildSection="child.children.length !== 0"
|
||||||
|
:customEmojiTree="child.children"
|
||||||
|
@chosen="nestedChosen"
|
||||||
|
>
|
||||||
|
{{ child.value || i18n.ts.other }}
|
||||||
|
</MkEmojiPickerSection>
|
||||||
|
</div>
|
||||||
<div v-if="shown" class="body">
|
<div v-if="shown" class="body">
|
||||||
<button
|
<button
|
||||||
v-for="emoji in emojis"
|
v-for="emoji in emojis"
|
||||||
|
@ -42,19 +55,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
|
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<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}:`))"
|
|
||||||
:hasChildSection="child.children.length !== 0"
|
|
||||||
:customEmojiTree="child.children"
|
|
||||||
@chosen="nestedChosen"
|
|
||||||
>
|
|
||||||
{{ child.value || i18n.ts.other }}
|
|
||||||
</MkEmojiPickerSection>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -156,13 +156,19 @@ const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
|
||||||
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };
|
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };
|
||||||
|
|
||||||
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
|
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
|
||||||
const parts = input.split('/').map(p => p.trim());
|
const parts = (input && input !== 'null' ? input : '').split('/');
|
||||||
let currentNode: CustomEmojiFolderTree = root;
|
let currentNode: CustomEmojiFolderTree = root;
|
||||||
|
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
let existingNode = currentNode.children.find((node) => node.value === part);
|
const path = currentNode.value ? `${currentNode.value}/${part.trim()}` : part.trim();
|
||||||
|
|
||||||
|
let existingNode = currentNode.children.find((node) => node.value === path);
|
||||||
if (!existingNode) {
|
if (!existingNode) {
|
||||||
const newNode: CustomEmojiFolderTree = { value: part, category: input, children: [] };
|
const newNode: CustomEmojiFolderTree = {
|
||||||
|
value: path,
|
||||||
|
category: currentNode.category ? `${currentNode.category}/${part}` : part,
|
||||||
|
children: [],
|
||||||
|
};
|
||||||
currentNode.children.push(newNode);
|
currentNode.children.push(newNode);
|
||||||
existingNode = newNode;
|
existingNode = newNode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue