Returns a reference to the currently attached document.
Retrieves the DocAuthSystem
instance this editor is bound to.
Adds an event listener that will be called every time the specified event is emitted.
The editor instance for method chaining
// Get the latest document content
editor.on('content.change', async () => console.log(await editor.currentDocument().saveDocument()));
Event name | Event payload | Description |
---|---|---|
document.load |
none | Fired when a document is initially loaded into the editor. This event is triggered once per document load, including when switching documents. |
content.change |
none | Fired when the document content has changed due to user editing or programmatic modifications. Use this event to react to document changes, such as saving drafts or updating UI state. |
Removes an event listener. If no handler is provided, removes all listeners for the event.
Optional
handler: (payload: EventPayload) => voidThe editor instance for method chaining
// Remove specific handler
editor.off('content.change', myHandler);
// Remove all handlers for an event
editor.off('content.change');
Event name | Event payload | Description |
---|---|---|
document.load |
none | Fired when a document is initially loaded into the editor. This event is triggered once per document load, including when switching documents. |
content.change |
none | Fired when the document content has changed due to user editing or programmatic modifications. Use this event to react to document changes, such as saving drafts or updating UI state. |
Adds an event listener that will be called only once when the specified event is emitted. The listener is automatically removed after being called.
The editor instance for method chaining
editor.once('document.load', () => {
console.log('Document loaded for the first time');
});
Event name | Event payload | Description |
---|---|---|
document.load |
none | Fired when a document is initially loaded into the editor. This event is triggered once per document load, including when switching documents. |
content.change |
none | Fired when the document content has changed due to user editing or programmatic modifications. Use this event to react to document changes, such as saving drafts or updating UI state. |
Attaches the provided document as the current document to the editor.