Auto expand tree on search in node library tab (#558)

* Add custom nodelib searchbox

* Auto expand on search

* Support alphabetical sort in filtered tree
This commit is contained in:
Chenlei Hu
2024-08-20 11:01:05 -04:00
committed by GitHub
parent f3ab9cfb8e
commit c4bc0e8430
6 changed files with 96 additions and 44 deletions

View File

@@ -226,27 +226,6 @@ export const SYSTEM_NODE_DEFS: Record<string, ComfyNodeDef> = {
}
}
function sortedTree(node: TreeNode): TreeNode {
// Create a new node with the same label and data
const newNode: TreeNode = {
...node
}
if (node.children) {
// Sort the children of the current node
const sortedChildren = [...node.children].sort((a, b) =>
a.label.localeCompare(b.label)
)
// Recursively sort the children and add them to the new node
newNode.children = []
for (const child of sortedChildren) {
newNode.children.push(sortedTree(child))
}
}
return newNode
}
interface State {
nodeDefsByName: Record<string, ComfyNodeDefImpl>
widgets: Record<string, ComfyWidgetConstructor>
@@ -269,9 +248,6 @@ export const useNodeDefStore = defineStore('nodeDef', {
...nodeDef.category.split('/'),
nodeDef.display_name
])
},
sortedNodeTree(): TreeNode {
return sortedTree(this.nodeTree)
}
},
actions: {