絵文字ピッカーのカテゴリの階層を表示するように・サブカテゴリを絵文字より上に (MisskeyIO#202)
This commit is contained in:
parent
2bad8941d0
commit
343ae413ae
2 changed files with 22 additions and 16 deletions
|
@ -156,13 +156,19 @@ 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());
|
||||
const parts = (input && input !== 'null' ? input : '').split('/');
|
||||
let currentNode: CustomEmojiFolderTree = root;
|
||||
|
||||
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) {
|
||||
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);
|
||||
existingNode = newNode;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue