LGraphCanvas.prototype.getCanvasMenuOptions and nodeType.prototype.getExtraMenuOptions is deprecated:
Migrating Canvas Menus
Old Approach (Deprecated)
The old approach modified the prototype during extension setup:New Approach (Recommended)
The new approach uses a dedicated extension hook:Key Differences
| Old Approach | New Approach |
|---|---|
Modified in setup() | Uses getCanvasMenuItems() hook |
| Wraps existing function | Returns menu items directly |
Modifies options array | Returns new array |
Canvas accessed via this | Canvas passed as parameter |
Migrating Node Menus
Old Approach (Deprecated)
The old approach modified the node type prototype:New Approach (Recommended)
The new approach uses a dedicated extension hook:Key Differences
| Old Approach | New Approach |
|---|---|
Modified in beforeRegisterNodeDef() | Uses getNodeMenuItems() hook |
Type-specific via if check | Type-specific via if check in hook |
Modifies options array | Returns new array |
Node accessed via this | Node passed as parameter |
Common Patterns
Conditional Menu Items
Both approaches support conditional items, but the new API is cleaner:Adding Separators
Separators are added the same way in both approaches:Creating Submenus
The recommended way to create submenus is using the declarativesubmenu property:
Accessing State
Troubleshooting
How to Identify Old API Usage
Look for these patterns in your code:Understanding Deprecation Warnings
If you see this warning in the console:Verifying Migration Success
After migration:- Remove all prototype modifications from
setup()andbeforeRegisterNodeDef() - Add
getCanvasMenuItems()and/orgetNodeMenuItems()hooks - Test that your menu items still appear correctly
- Verify no deprecation warnings appear in the console
Complete Migration Example
Before:Additional Resources
- Annotated Examples - More examples using the new API
- Extension Hooks - Complete list of available extension hooks
- Commands and Keybindings - Add keyboard shortcuts to your menu actions