Skip to main content

Overview

The editor provides a typed event bus for communication between components. It’s a singleton instance built on the browser’s native CustomEvent API with events prefixed as @vuemaildev/editor:.

Dispatching events

Fire an event with a payload:

Listening to events

Subscribe to events and clean up when done:
The on method returns an object with an unsubscribe function. Always unsubscribe when the component unmounts to avoid memory leaks. The useEditorEvent composable does both for you, listening while the component is mounted:

Built-in events

Adding custom events

Use TypeScript module augmentation to register custom events with full type safety:
Then dispatch and listen with full type checking:

Event targets

By default, events are dispatched on window. You can scope events to a specific DOM element using the target option:
This is useful when you have multiple editor instances on the same page and want events to stay scoped to their respective editors.