mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 18:16:15 +08:00
opti: style improve of sidebar and topbar #572;
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { TreeItem, TreeItems } from './../workspace-sidebar/page-tree';
|
||||
|
||||
const pickPath = (treeItems: TreeItem | TreeItems, targetId: string) => {
|
||||
const pick = (tree: TreeItem, result: TreeItem[] = []) => {
|
||||
if (tree.id === targetId) {
|
||||
result.push(tree);
|
||||
return result;
|
||||
}
|
||||
|
||||
for (const child of tree?.children || []) {
|
||||
if (pick(child, result).length) {
|
||||
result.unshift(tree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return (Array.isArray(treeItems) ? treeItems : [treeItems]).map(treeItem =>
|
||||
pick(treeItem)
|
||||
);
|
||||
};
|
||||
|
||||
export { pickPath };
|
||||
Reference in New Issue
Block a user