ContextMenuExtension
Powerful, extensible context menu system
Build rich, context-aware menus that appear on right-click. Perfect for content-specific actions like table operations, link editing, and custom workflows.
Key Features
Everything you need for professional context menu experiences.
Register multiple providers that can handle different content types and selection contexts with priority-based resolution.
Smart initialization ordering ensures context menu providers register before dependent extensions, eliminating timing issues.
Complete control over appearance with custom renderers, themes, and styles. Works with any design system.
Quick Start
Get context menus working in your editor with minimal setup.
Import and add ContextMenuExtension
Enable context menus for table operations
The ContextMenuExtension automatically handles initialization ordering, so table context menus work without manual array positioning.
Try ContextMenuExtension
Interactive demos showcasing different levels of context menu functionality.
Headless Context Menu
Basic context menu functionality without tables or other extensions
Table Context Menu
Context menu with table support and improved theming
Advanced Context Menu
Custom providers for different content types with enhanced theming
Provider System
The core of ContextMenuExtension - register providers for different content types.
Add context menu items for specific content
Provider Properties:
- id: Unique identifier for the provider
- priority: Higher numbers checked first (default: 0)
- canHandle: Function to determine if this provider should handle the context
- getItems: Function returning menu items for this context
- renderer: Optional custom renderer for this provider's menu
Customization
Complete control over appearance and behavior.
Create custom context menu styling
Customize behavior and appearance
API Reference
Commands and state queries for programmatic control.
registerProvider(provider)Register a context menu provider
unregisterProvider(id)Remove a provider by ID
showContextMenu(config)Show context menu programmatically
hideContextMenu()Hide the current context menu
isContextMenuOpen()Check if context menu is visible
Control context menus programmatically
Best Practices
Tips for the best context menu experience.
Use appropriate priority values. Higher priority providers (like tables) should have higher numbers to be checked first.
The ContextMenuExtension uses initPriority to ensure it registers before dependent extensions, eliminating manual array ordering.
Keep canHandle functions lightweight. Avoid complex DOM queries or heavy computations in provider registration.
Ensure menu items have clear labels and consider keyboard navigation support for comprehensive accessibility.