Event Methods
Subscribe to Events
Event name to listen for
Callback function
Event Categories
Lifecycle
Initialization and teardown
Content
Document changes
Collaboration
Multi-user events
UI
Interface changes
Lifecycle Events
ready
Fired when SuperDoc is fully initialized.
SuperDoc instance
editorCreate
When an editor is created.
Created editor instance
editorDestroy
When an editor is destroyed.
No parameters passed
Content Events
editor-update
When editor content changes.
Editor with updated content
content-error
When content processing fails.
Error details
Related editor instance
Document identifier
Original file
fonts-resolved
When the document fonts are resolved.
Depending on the browser, the user might be prompted to grant access to their local system fonts.
Object with document fonts and unsupported fonts
Comments Events
comments-update
When comments are modified.
Event type: ‘add’, ‘update’, ‘delete’, ‘resolve’
Comment data
Collaboration Events
collaboration-ready
When collaboration is initialized.
Editor with collaboration
awareness-update
When user presence changes.
Awareness context
User states map
locked
When document lock state changes.
Lock state
User who locked the document
Configuration-Based Events
Events can also be configured during initialization
Common Patterns
Auto-save with Debouncing
Track Multiple Editors
Clean Up Pattern
Event Order
Understanding event order helps with initialization:
editorBeforeCreate
- Setup phaseeditorCreate
- Editor readyready
- All editors readycollaboration-ready
- If enabled- Runtime events
editorDestroy
- Cleanup
Performance Tips
Best practices:
- Use
once()
for one-time setup - Debounce expensive handlers
- Clean up with
off()
when done - Avoid heavy work in
awareness-update
- Batch updates in
editor-update