Node library custom bookmark folder (#631)

* Add new folder button

* Add tree util test

* nit

* Support empty folder in node library

* Drag to bookmark folder

* Use bookmark icon for bookmark folder

* Highlight on dragover

* nit

* Auto-expand on item added

* Extract bookmark system as store

* Add context menu on bookmark folder

* Add editable text

* Fix reactivity

* Plumb editable text

* refactor

* Rename node

* Fix focus

* Prevent name collision

* nit

* Add new folder

* nested folder support

* Change drag behavior

* Add basic playwright tests

* nit

* Target tree-node-content instead of tree-node
This commit is contained in:
Chenlei Hu
2024-08-25 21:53:58 -04:00
committed by GitHub
parent f36c934d37
commit 090fda2f22
10 changed files with 692 additions and 82 deletions

View File

@@ -205,6 +205,14 @@ export class ComfyNodeDefImpl {
})
return new ComfyOutputsSpec(result)
}
get nodePath(): string {
return (this.category ? this.category + '/' : '') + this.display_name
}
get isDummyFolder(): boolean {
return this.name === ''
}
}
export const SYSTEM_NODE_DEFS: Record<string, ComfyNodeDef> = {
@@ -244,10 +252,19 @@ export const SYSTEM_NODE_DEFS: Record<string, ComfyNodeDef> = {
}
export function buildNodeDefTree(nodeDefs: ComfyNodeDefImpl[]): TreeNode {
return buildTree(nodeDefs, (nodeDef: ComfyNodeDefImpl) => [
...nodeDef.category.split('/').filter((s) => s !== ''),
nodeDef.display_name
])
return buildTree(nodeDefs, (nodeDef: ComfyNodeDefImpl) =>
nodeDef.nodePath.split('/')
)
}
export function createDummyFolderNodeDef(folderPath: string): ComfyNodeDefImpl {
return plainToClass(ComfyNodeDefImpl, {
name: '',
display_name: '',
category: folderPath.endsWith('/') ? folderPath.slice(0, -1) : folderPath,
python_module: 'nodes',
description: 'Dummy Folder Node (User should never see this string)'
})
}
interface State {