EventBus provides a publish-subscribe event system that allows multiple subscribers to listen to the same events.
Overview
Access the event bus through the editor instance:API Methods
on
Subscribes to an event.emit
Emits an event (typically used internally, but available for custom events).off
Unsubscribes from an event.isSubscribe
Checks if an event has any subscribers.Available Events
All events from the Listener API are available, plus additional events:Document Events
contentChange
saved
Selection & Styling
rangeStyleChange
Page Events
pageSizeChange
pageScaleChange
pageModeChange
visiblePageNoListChange
intersectionPageNoChange
Control Events
controlChange
controlContentChange
Zone Events
zoneChange
Mouse Events
click
mousedown
mouseup
mousemove
mouseenter
mouseleave
Input Events
input
Position Context
positionContextChange
Image Events
imageSizeChange
imageMousedown
imageDblclick
Label Events
labelMousedown
Complete Example
EventBus vs Listener
EventBus (pub-sub):- Multiple subscribers per event
- Must use
on/offmethods - Better for plugins and modular code
- Supports checking if subscribed
- Single callback per event
- Simple assignment (
editor.listener.eventName = callback) - Better for primary/simple event handlers
- Set to
nullto remove