Skip to content

Commit d94821b

Browse files
committed
feat(contextMenu): migrate core extensions to new context menu API
Migrates core extensions from monkey-patching to the new context menu extension API, demonstrating the migration path for extension developers. **Migrated extensions:** - `groupOptions.ts`: Group management context menu items - `nodeTemplates.ts`: Template save/load context menu items **Legacy compatibility test:** - `groupNode.ts`: Kept with monkey-patching as compatibility test case - Includes documentation explaining the old vs new approach **Benefits:** - Type-safe menu item registration - No prototype pollution - Easier to test and maintain - Clear separation of concerns Depends on PR #5977 (context menu extension API)
1 parent 0685a1d commit d94821b

File tree

3 files changed

+301
-284
lines changed

3 files changed

+301
-284
lines changed

src/extensions/core/groupNode.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,18 @@ export class GroupNodeHandler {
16301630
}
16311631
}
16321632

1633+
/**
1634+
* LEGACY COMPATIBILITY TEST CASE
1635+
*
1636+
* This extension uses the old monkey-patching approach to modifying context menus.
1637+
* It is kept as-is to test backward compatibility with the new context menu API.
1638+
*
1639+
* New extensions should use the new ComfyExtension interface methods:
1640+
* - getCanvasMenuItems(canvas): IContextMenuValue[]
1641+
* - getNodeMenuItems(node): IContextMenuValue[]
1642+
*
1643+
* See nodeTemplates.ts and groupOptions.ts for examples of the new API.
1644+
*/
16331645
function addConvertToGroupOptions() {
16341646
// @ts-expect-error fixme ts strict error
16351647
function addConvertOption(options, index) {

0 commit comments

Comments
 (0)