mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-26 17:54:14 +00:00
feat: read category from blueprint subgraph definition (#9053)
Read `category` from `definitions.subgraphs[0].category` in blueprint JSON files as a fallback default for node categorization. This allows blueprint authors to set the category directly in the blueprint file without needing backend `index.json` support. The precedence order is: 1. Explicit overrides (e.g. `info.category` from API, or `'Subgraph Blueprints/User'` for user blueprints) 2. `definitions.subgraphs[0].category` from the blueprint JSON content 3. Bare `'Subgraph Blueprints'` fallback Companion PR: Comfy-Org/ComfyUI#12552 (adds essential blueprints with categories matching the Figma design) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9053-feat-read-category-from-blueprint-subgraph-definition-30e6d73d3650810ca23bfc5a1e97cb31) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -14,6 +14,46 @@ import { upperCase } from 'es-toolkit/string'
|
||||
|
||||
const DEFAULT_ICON = 'pi pi-sort'
|
||||
|
||||
const NODE_ORDER_BY_FOLDER = {
|
||||
basics: [
|
||||
'LoadImage',
|
||||
'LoadVideo',
|
||||
'Load3D',
|
||||
'SaveImage',
|
||||
'SaveVideo',
|
||||
'SaveGLB',
|
||||
'PrimitiveStringMultiline',
|
||||
'PreviewImage'
|
||||
],
|
||||
'image tools': [
|
||||
'ImageBatch',
|
||||
'ImageCrop',
|
||||
'ImageCropV2',
|
||||
'ImageScale',
|
||||
'ImageScaleBy',
|
||||
'ImageRotate',
|
||||
'ImageBlur',
|
||||
'ImageBlend',
|
||||
'ImageInvert',
|
||||
'Canny',
|
||||
'RecraftRemoveBackgroundNode',
|
||||
'LoadImageMask'
|
||||
],
|
||||
'video tools': ['GetVideoComponents', 'CreateVideo'],
|
||||
'image generation': [
|
||||
'LoraLoader',
|
||||
'LoraLoaderModelOnly',
|
||||
'ConditioningCombine'
|
||||
],
|
||||
audio: [
|
||||
'LoadAudio',
|
||||
'SaveAudio',
|
||||
'SaveAudioMP3',
|
||||
'StabilityTextToAudio',
|
||||
'EmptyLatentAudio'
|
||||
]
|
||||
} as const satisfies Record<string, readonly string[]>
|
||||
|
||||
export const DEFAULT_GROUPING_ID = 'category' as const
|
||||
export const DEFAULT_SORTING_ID = 'original' as const
|
||||
export const DEFAULT_TAB_ID = 'all' as const
|
||||
@@ -160,6 +200,25 @@ class NodeOrganizationService {
|
||||
const orderB = bi === -1 ? len + originalIndex.get(b)! : bi
|
||||
return orderA - orderB
|
||||
})
|
||||
for (const folder of tree.children) {
|
||||
if (!folder.children) continue
|
||||
const order =
|
||||
NODE_ORDER_BY_FOLDER[
|
||||
folder.label as keyof typeof NODE_ORDER_BY_FOLDER
|
||||
]
|
||||
if (!order) continue
|
||||
const nodeOrder: readonly string[] = order
|
||||
const orderLen = nodeOrder.length
|
||||
folder.children.sort((a, b) => {
|
||||
const nameA = a.data?.name ?? a.label ?? ''
|
||||
const nameB = b.data?.name ?? b.label ?? ''
|
||||
const ai = nodeOrder.indexOf(nameA)
|
||||
const bi = nodeOrder.indexOf(nameB)
|
||||
const orderA = ai === -1 ? orderLen : ai
|
||||
const orderB = bi === -1 ? orderLen : bi
|
||||
return orderA - orderB
|
||||
})
|
||||
}
|
||||
}
|
||||
return [{ tree }]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user