Events Available for TinyMCE
TinyMCE supports some browser-native events, and provides additional events for working with the editor and plugins.
Handling Editor events
The following examples illustrate how to use supported native events, editor core events, and plugin events with TinyMCE.
The following example uses a function to create a console log entry when the editor has initialized. This is also an example of handling an event which does not return any data.
tinymce.init({
selector: 'textarea',
setup: function(editor) {
editor.on('init', function(e) {
console.log('The Editor has initialized.');
});
}
});
The following example uses a function to create a console log entry when a command is executed in the editor. This is also an example of handling an event that returns data.
tinymce.init({
selector: 'textarea',
init_instance_callback: function(editor) {
editor.on('ExecCommand', function(e) {
console.log('The ' + e.command + ' command was fired.');
});
}
});
Supported browser-native events
TinyMCE supports the following browser-native events. Click the event name for details (links open MDN Web Docs).
Editor core events
The following events are provided by the TinyMCE editor.
Name | Data | Description |
---|---|---|
activate |
|
Fired when the editor is activated. |
deactivate |
|
Fired when the editor is deactivated. |
remove |
N/A |
Fired before the editor is removed/destroyed. |
detach |
N/A |
Fired after the remove event, before the editor container is detached from the DOM. |
init |
N/A |
Fired when the editor is fully initialized. |
ScrollIntoView |
|
Fired when an element is about to be scrolled into view. |
AfterScrollIntoView |
|
Fired when an element has been scrolled into view. NOTE: This feature is only available for TinyMCE 5.2 and later. |
ObjectResized |
|
Fired when an object (such as an image) has finished being resized. |
ObjectResizeStart |
|
Fired when an object (such as an image) is about to be resized. |
SwitchMode |
|
Fired when the editor mode is changed. The available modes are "design" and "readonly". Additional modes can be registered using TinyMCE API 'tinymce.activeEditor.mode.register()'. |
ScrollWindow |
(Same data as the native scroll event) |
Fired when the window has scrolled. |
ResizeWindow |
(Same data as the native resize event) |
Fired when the window is resized. |
BeforeExecCommand |
|
Fired before a command is executed. |
ExecCommand |
|
Fired after a command has executed. |
NodeChange |
|
Fired when the selected node inside the editor content has changed. |
FormatApply |
|
Fired after a format is applied. NOTE: This feature is only available for TinyMCE 5.9 and later. |
FormatRemove |
|
Fired after a format is removed. NOTE: This feature is only available for TinyMCE 5.9 and later. |
ShowCaret |
|
Fired before a fake caret element is shown in the editor. The fake caret will appear where the cursor is normally not shown, such as at the start or end of tables and non-editable content. |
SelectionChange |
N/A |
Fired when the content selection in the editor changes. |
ObjectSelected |
|
Fired when an object (such as an image) is selected in the editor and the selection elements have rendered. |
BeforeObjectSelected |
|
Fired when an object (such as an image) is selected in the editor, before it is rendered as selected. |
GetSelectionRange |
|
Fired when the selection range is being fetched from the editor. |
SetSelectionRange |
|
Fired before the selection range is set in the editor. |
AfterSetSelectionRange |
|
Fired after the selection range is set in the editor. |
BeforeGetContent |
|
Fired before the content is serialized from the editor. |
GetContent |
|
Fired after the content is serialized from the editor. |
BeforeSetContent |
|
Fired before the content is parsed and rendered in the editor. |
SetContent |
|
Fired after the content is parsed and rendered in the editor. |
LoadContent |
N/A |
Fired after the initial content has loaded into the editor. |
PreviewFormats |
N/A |
Fired before a formats CSS is generated when the format is being previewed in the editor. |
AfterPreviewFormats |
N/A |
Fired after a formats CSS is generated when the format is being previewed in the editor. |
ScriptsLoaded |
N/A |
Fired when all the scripts required for the editor to run (such as plugins and theme) have loaded. |
PreInit |
N/A |
Fired after loading the editor and before starting to load the editor content. |
PostRender |
N/A |
Fired after the theme has rendered. |
NewBlock |
|
Fired when a new block is created in the editor, such as when the user presses the enter key. |
ClearUndos |
N/A |
Fired when the undo levels have been cleared. |
TypingUndo |
N/A |
Fired when a new undo level is created by typing content into the editor. |
Change |
|
Fired when the editor content changes have been committed, such as when moving focus away from the editor. |
Redo |
|
Fired when a change is been re-applied. |
Undo |
|
Fired when a change has been undone. |
BeforeAddUndo |
|
Fired before a new undo level is created. |
AddUndo |
|
Fired after a new undo level has been created. |
Dirty |
N/A |
Fired when the editor transitions from a "pristine" state to a "dirty" state. The editor is "dirty" when an undo level has been created since initialization or the last saved state. To check if the editor is "dirty", use the |
CloseWindow |
|
Fired when a dialog has been closed. |
OpenWindow |
|
Fired when a dialog has been opened. |
ProgressState |
|
Fired when a change to the editor progress state is scheduled using the TinyMCE API |
AfterProgressState |
|
Fired after the editor progress state is changed, and the new progress state is in effect. |
PreProcess |
|
Fired before serializing a DOM node to HTML content. |
PostProcess |
|
Fired after serializing a DOM node to HTML content. |
SetAttrib |
|
Fired when an attribute is updated using the editor DOMUtils API. |
ResizeEditor |
N/A |
Fired when the editor is resized, either by the resize handles or the auto-resize plugin. As of TinyMCE 5.10.6, this event is also fired when fullscreen mode is toggled. Toggling fullscreen mode requires the |
SkinLoaded |
N/A |
Fired when the editor skin has been loaded. |
SkinLoadError |
|
Fired when the editor skin fails to load. NOTE: This feature is only available for TinyMCE 5.2 and later. |
PluginLoadError |
|
Fired when an editor plugin fails to load. NOTE: This feature is only available for TinyMCE 5.2 and later. |
IconsLoadError |
|
Fired when the editor icon pack fails to load. NOTE: This feature is only available for TinyMCE 5.2 and later. |
LanguageLoadError |
|
Fired when the editor language pack fails to load. NOTE: This feature is only available for TinyMCE 5.2 and later. |
BeforeRenderUI |
N/A |
Fired before the theme UI is rendered. |
ToggleSidebar |
N/A |
Fired when a sidebar is toggled opened/closed. |
longpress |
(Same data as the native touchstart event) |
Fired when a long press occurs on a touch device inside the editor. |
tap |
(Same data as the native touchend event) |
Fired when a tap occurs on a touch device inside the editor (simulated event similar to click). |
ScrollContent |
(Same data as the native scroll event) |
(iframe mode only) Fired when the content inside an iframe window has been scrolled. |
ResizeContent |
(Same data as the native resize event) |
(iframe mode only) Fired when the iframe window is resized. |
Load |
N/A |
(iframe mode only) Fired when the editor iframe content has finished loading. |
ResolveName |
|
(iframe mode only) Fired when the editor tries to resolve the name of an element to render the status bar path. |
BeforeOpenNotification |
|
Fired before a notification is displayed. For information on the Notifications Specification ( |
OpenNotification |
|
Fired after a notification is displayed. For information on the Notifications API ( |
Plugin events
The following plugins provide events.
Advanced Tables events
For events applicable to the Advanced Tables plugin, see: Table events.
Autosave events
The following events are provided by the Autosave plugin.
Name | Data | Description |
---|---|---|
RestoreDraft |
N/A |
Fired when a draft has been restored. |
StoreDraft |
N/A |
Fired when a draft is saved. |
RemoveDraft |
N/A |
Fired when a draft has been removed from memory. |
Character Map events
The following event is provided by the Character Map plugin.
Name | Data | Description |
---|---|---|
InsertCustomChar |
|
Fired before a special character is inserted into the editor. |
Comments events
The following event is provided by the Comments plugin.
Name | Data | Description |
---|---|---|
mce-tinycomments-update |
N/A |
Fired when the comments sidebar is opened or closed. |
Export events
The following event are provided by the Export plugin.
Name | Data | Description |
---|---|---|
ExportPdf |
N/A |
Fired when the editor content is about to be exported as a PDF. |
Format Painter events
The following event is provided by the Format Painter plugin.
Name | Data | Description |
---|---|---|
FormatPainterToggle |
|
Fired when the format painter state changes. |
Fullscreen events
The following event is provided by the Fullscreen plugin.
Name | Data | Description |
---|---|---|
FullscreenStateChanged |
|
Fired when the fullscreen state changes. |
Import CSS events
The following event is provided by the Import CSS plugin.
Name | Data | Description |
---|---|---|
AddStyleModifications |
|
Fired during editor initialization when the style modifications are parsed from the CSS. |
Link checker events
The following event is provided by the Link Checker plugin.
Name | Data | Description |
---|---|---|
LinkCheckerError |
|
Fired when a link checker error occurs, such as the Link Checker service can’t be reached. |
Lists events
The following event is provided by the Lists plugin.
Name | Data | Description |
---|---|---|
ListMutation |
|
Fired when a list is toggled on/off. |
Media Embed events
The following event is provided by the Media Embed plugin.
Name | Data | Description |
---|---|---|
MediaEmbedError |
|
Fired when a media embed error occurs, such as the Media Embed service can’t be reached. |
Paste events
The following events are provided by the Paste plugin.
Name | Data | Description |
---|---|---|
PastePreProcess |
|
Fired before the content is parsed from the clipboard. |
PastePostProcess |
|
Fired after the content has been parsed from the clipboard, but before it’s added to the editor. |
PastePlainTextToggle |
|
Fired when the plain text paste mode state changes. |
Permanent Pen events
The following events are provided by the Permanent Pen plugin.
Name | Data | Description |
---|---|---|
PermanentPenToggle |
|
Fired when the permanent pen state changes. |
PermanentPenProperties |
|
Fired when the permanent pen properties are changed. |
PowerPaste events
The following events are provided by the PowerPaste plugin.
Name | Data | Description |
---|---|---|
PastePreProcess |
|
Fired before the content is parsed from the clipboard. |
PastePostProcess |
|
Fired after the content has been parsed from the clipboard, but before it’s added to the editor. |
PastePlainTextToggle |
|
Fired when the plain text paste mode state changes. |
Spell Checker events
The following events are provided by the Spell Checker plugin.
The free TinyMCE Spell Checker plugin (spellchecker ) was deprecated with the release of TinyMCE 5.4. For details, see the free TinyMCE Spell Checker plugin deprecation notice. The free Spell Checker plugin will be removed in TinyMCE 6.0.
|
Name | Data | Description |
---|---|---|
SpellcheckStart |
N/A |
Fired when spellchecking is enabled. |
SpellcheckEnd |
N/A |
Fired when spellchecking is disabled. |
Spell Checker Pro events
The following events are provided by the Spell Checker Pro plugin.
Name | Data | Description | ||
---|---|---|---|---|
SpellcheckerIgnore |
|
Fired when a single instance of a word has been marked as ignored. |
||
SpellcheckerIgnoreAll |
|
Fired when all instances of a word (in a certain language) have been marked as ignored.
|
||
SpellcheckError |
|
Fired when a spellchecker error occurs, such as when the Spell Checker Pro service can’t be reached. |
||
SpellcheckStart |
N/A |
Fired when spellchecking is enabled. |
||
SpellcheckEnd |
N/A |
Fired when spellchecking is disabled. |
||
SpellcheckerLanguageChanged |
|
Fired when the spellchecking language is changed. |
Table events
The following events are provided by the Table plugin.
Name | Data | Description |
---|---|---|
newrow |
N/A |
Fired when a row is created |
newcell |
N/A |
Fired when a cell is created |
ObjectResizeStart |
N/A |
Fired when a resize action is started on a table, row, column or cell using the resize bars |
ObjectResized |
N/A |
Fired when a resize action is finished on a table, row, column or cell using the resize bars |
TableModified |
|
Fired when style or structural changes are made to a table. |
TableSelectionClear |
N/A |
Fired when the table selection is cleared. |
Visual Blocks events
The following event is provided by the Visual Blocks plugin.
Name | Data | Description |
---|---|---|
VisualBlocks |
|
Fired when the Visual Blocks state changes. |
Visual Characters events
The following event is provided by the Visual Characters plugin.
Name | Data | Description |
---|---|---|
VisualChars |
|
Fired when the Visual Characters state changes. |
Word Count events
The following event is provided by the Word Count plugin.
Name | Data | Description |
---|---|---|
WordCountUpdate |
|
Fired when the editor word count is updated. |
Editor Manager events
The following events are used for editor management. These events are handled using tinymce.on
, rather than editor.on
or editor.fire
, as shown in Examples: Handling Editor Manager events.
Name | Data | Description |
---|---|---|
AddEditor |
|
Fired when a new editor is created. |
RemoveEditor |
|
Fired when an editor is removed/destroyed. |
BeforeUnload |
N/A |
Fired before the browser window is closed (same as native |