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
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 |
|---|
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). |
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. |
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. |
Events in the last three groups come from plugins, so they only fire when that plugin is loaded. See exec_command for intercepting commands, Upload files for the upload options, and Configuration reference for autoSave.