mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-03 04:00:31 +00:00
Complete context menu migration for Load3D, Preview3D, and SaveGLB (#6454)
This pull request refactors how export menu options are added to 3D-related nodes, updating the API to use a new `getNodeMenuItems` hook and simplifying the menu item creation logic. The changes improve consistency and maintainability across extensions handling 3D nodes, and clarify the expected return types for menu item hooks. **Refactoring and API updates for node menu items:** * Replaced usage of the legacy `createExportMenuOptions` function with the new `createExportMenuItems` function in `load3d.ts`, `saveMesh.ts`, and related imports, aligning all 3D node extensions to the new API. [[1]](diffhunk://#diff-a5c612d9322ca4cbbeda097d13e2fa1ef017d4c3076d23fc228afee5a79a56e3L6-R12) [[2]](diffhunk://#diff-7dede72060130d77ce5191fc86d115bd9b93311cb0438400730d8e20b2aa8e43L4-R7) * Introduced and implemented the `getNodeMenuItems` hook in the extension registration for `Load3D`, `Preview3D`, and `SaveGLB` nodes, ensuring export menu items are only shown for the appropriate node types. [[1]](diffhunk://#diff-a5c612d9322ca4cbbeda097d13e2fa1ef017d4c3076d23fc228afee5a79a56e3R293-R302) [[2]](diffhunk://#diff-a5c612d9322ca4cbbeda097d13e2fa1ef017d4c3076d23fc228afee5a79a56e3R521-R530) [[3]](diffhunk://#diff-7dede72060130d77ce5191fc86d115bd9b93311cb0438400730d8e20b2aa8e43R48-R57) * Removed assignment of `getExtraMenuOptions` to nodes, fully migrating to the new menu item hook approach for context menus. [[1]](diffhunk://#diff-a5c612d9322ca4cbbeda097d13e2fa1ef017d4c3076d23fc228afee5a79a56e3L301-L302) [[2]](diffhunk://#diff-a5c612d9322ca4cbbeda097d13e2fa1ef017d4c3076d23fc228afee5a79a56e3L548-L549) [[3]](diffhunk://#diff-7dede72060130d77ce5191fc86d115bd9b93311cb0438400730d8e20b2aa8e43L64-L67) **Menu item creation logic simplification:** * Refactored `createExportMenuOptions` to `createExportMenuItems` in `exportMenuHelper.ts`, changing it to directly return an array of menu items (with separators) instead of a function, simplifying its usage and reducing boilerplate. [[1]](diffhunk://#diff-42404da1a87a52d304371a13d5f021bdad837765b94d86d186abb2d99a8cb707L14-R22) [[2]](diffhunk://#diff-42404da1a87a52d304371a13d5f021bdad837765b94d86d186abb2d99a8cb707L59-R58) **Type and documentation improvements:** * Updated the `ComfyExtension` interface in `comfy.ts` to clarify that menu item hooks (`getCanvasMenuItems`, `getNodeMenuItems`) now return arrays that may include `null` values as separators, improving type safety and documentation. See before and after below <img width="1459" height="897" alt="Screenshot 2025-10-30 at 07 08 04" src="https://github.com/user-attachments/assets/ec4464c9-f733-4b4c-87c4-bb5060ccaa68" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6454-Complete-context-menu-migration-for-Load3D-Preview3D-and-SaveGLB-29c6d73d3650819995b4c4dc1582cd86) by [Unito](https://www.unito.io)
This commit is contained in:
committed by
GitHub
parent
9e309308ed
commit
c642ed5703
@@ -140,16 +140,16 @@ export interface ComfyExtension {
|
||||
/**
|
||||
* Allows the extension to add context menu items to canvas right-click menus
|
||||
* @param canvas The canvas instance
|
||||
* @returns An array of context menu items to add
|
||||
* @returns An array of context menu items to add (null values represent separators)
|
||||
*/
|
||||
getCanvasMenuItems?(canvas: LGraphCanvas): IContextMenuValue[]
|
||||
getCanvasMenuItems?(canvas: LGraphCanvas): (IContextMenuValue | null)[]
|
||||
|
||||
/**
|
||||
* Allows the extension to add context menu items to node right-click menus
|
||||
* @param node The node being right-clicked
|
||||
* @returns An array of context menu items to add
|
||||
* @returns An array of context menu items to add (null values represent separators)
|
||||
*/
|
||||
getNodeMenuItems?(node: LGraphNode): IContextMenuValue[]
|
||||
getNodeMenuItems?(node: LGraphNode): (IContextMenuValue | null)[]
|
||||
|
||||
/**
|
||||
* Allows the extension to add additional handling to the node before it is registered with **LGraph**
|
||||
|
||||
Reference in New Issue
Block a user