All Events
Listen with editor.attachEvent(name, handler) and stop listening with editor.detachEvent(name, handler). Inside a handler, this is the editor instance. A few events are cancellable: they receive a state object first, and setting state.returnValue = true tells the editor you handled it.
Example
Code example
editor.attachEvent("change", function () {
document.getElementById("dirty").hidden = false;
});
// Some events let you take over. Set state.returnValue = true to say "handled",
// and the editor skips its own action.
editor.attachEvent("exec_command_newdoc", function (state, cmd, value) {
state.returnValue = true;
this.setHTMLCode("<p>New document</p>");
});
editor.detachEvent("change", myHandler);Editing and lifecycle
| Event | Handler receives | Fires when |
|---|---|---|
ready | () | From core 2.6.10. Once, after the editor is built and its initial content is loaded. Fired asynchronously, so a handler attached right after new RichTextEditor(...) still receives it; one attached later is called on the next tick. config.onready receives it too. |
aftersethtml | () | From core 2.6.10. After setHTMLCode replaced the content (also with { undoable: true }), once per call, and when the editor switches back from HTML source view. Not while source view is shown. A load is not an edit: no change event follows, and refreshes your handler makes become part of the loaded document. |
panelresized | (info) | From core 2.6.11. A side panel made resizable with editor.makePanelResizable (comments, outline and similar) was resized by dragging its edge or with ArrowLeft / ArrowRight / Home / End. info is { panel, width }, the panel element and its new width in pixels. |
change | () | The content changed: typing, a command, paste, undo. Debounced, so a burst of typing is one event. |
contentchange | () | The content changed, reported by the content-safety plugin after its own pass. |
selectionchange | () | The caret moved or the selection changed, including when a control is selected. |
focus | (event) | The editing area gained focus (focusin from the editable document). |
blur | (event) | The editing area lost focus (focusout). |
documentreplaced | (document) | From core 2.6.10. The editing frame was moved and now has a NEW document (some plugins wrap the editing area in a panel at start-up). Listeners bound with editor.bindDocumentEvent / bindEditableEvent are re-attached for you; re-read anything you kept from getDocument() or getEditable(). |
keydown | (event) | A key went down inside the editing area. The native KeyboardEvent is passed through. |
keyup | (event) | A key came up inside the editing area. |
keypress | (event) | A character key was pressed inside the editing area. |
resize | () | The editor was resized, including by the user dragging the resize corner. |
change_html_view | (isCodeMode) | The editor switched between the WYSIWYG view and the HTML source view. |
copyheadinglink | (url, headingId) | The user clicked the link button beside a heading (config.copyHeadingLink). url is the page address with #headingId; the editor has already tried to copy it to the clipboard. |
destroy | () | destroy() was called. Disconnect your own listeners and sockets here. |
Commands and dialogs
| Event | Handler receives | Fires when |
|---|---|---|
exec_command | (state, command, value) | Any command is about to run. Fires for every command, after the command-specific event below. Cancellable: set state.returnValue = true to handle it yourself. |
exec_command_<name> | (state, command, value) | One named command is about to run, e.g. exec_command_newdoc, exec_command_bold. Use it to replace that command. Cancellable: set state.returnValue = true to handle it yourself. |
customdialog | (state, name, message) | The editor is about to show one of its own dialogs or alerts, e.g. uploadfailed, uploadtoobig, reachmaxlength. Show your own instead. Cancellable: set state.returnValue = true to handle it yourself. |
charlimit | ({ chars, words, overChars, overWords }) | The content passed a character or word limit set by the statistics plugin. |
Uploads
| Event | Handler receives | Fires when |
|---|---|---|
uploadprogress | (file, loaded, total) | Bytes were sent, when the built-in uploader (file_upload_url) is in use and the browser reports progress. |
uploadretry | (file, attempt, error) | An upload failed and is being retried, once per attempt. See uploadRetryCount. |
uploadcancel | (file, reason) | An upload was cancelled: "cancel" from cancelUploads(), "removed" when its image was deleted, or "destroy". |
Autosave
| Event | Handler receives | Fires when |
|---|---|---|
autosaved | (timestamp) | config.autoSave saved the content successfully. |
autosavefailed | (error, attempt) | An autosave failed. attempt is 0 for the first failure, then 1, 2… as it retries. |
Comments, track changes and revisions
| Event | Handler receives | Fires when |
|---|---|---|
comment_added | ({ id, text, author }) | A comment was added. |
comment_resolved | ({ id }) | A comment was resolved. |
commentsonlychanged | (name, isCommentsOnly) | The editor entered or left comments-only mode. |
review_decision_denied | (detail) | A user without permission tried to accept or reject a tracked change. |
revision_snapshot | ({ id, label, isNamed, createdAt }) | The revision history plugin stored a version. |
revision_history_sync_error | (detail) | The revision history plugin could not reach its store. |
linkcheck | (issues) | The link checker finished a pass; issues is the array it found. |
Source-build preview
These events exist in newer source builds, not every released bundle or this site's current demo assets. Use a matching tested core/plugin build; attaching a handler cannot add an event to an older runtime.
Version-dependent event notifications
| Event | Handler receives | Fires when |
|---|---|---|
autolink | (href, typedText) | Newer source core builds: after typed text has been converted into a link. href is the resulting address; typedText is the original word. This is a notification, not a cancellable before-link hook. Older released cores may not fire it. |
comment_reacted | ({ id, emoji, user }) | Newer comment-reaction plugin builds: a person toggled an emoji on a comment. id is the comment id and user is the current user's id as a string. It fires for both adding and removing a reaction; read the entry's reactions from reviewLedger for the resulting state. It does not send email or authorize a server operation. |
Upload, autosave and review events require the corresponding feature/plugin to be loaded. See exec_command for intercepting commands, Upload files for the upload options, and Configuration reference for autoSave.