The following tables show the existing editor commands. These commands are provided by tinymce and not by the browser’s internal commands. These commands can be executed using the execCommand function.
To retrieve a list of available commands from the active editor, run the following command from the browser console:
tinymce.activeEditor.editorCommands.commands.exec;The commands in the following table are provided by the {productname} editor and provide the same or similar functionality to the native browser commands.
| Command | Description |
|---|---|
Bold |
Toggles bold formatting to selection. |
Italic |
Toggles italic formatting to selection. |
Underline |
Toggles underline formatting to selection. |
Strikethrough |
Toggles strikethrough formatting to selection. |
Superscript |
Toggles superscript formatting to selection. |
Subscript |
Toggles subscript formatting to selection. |
Cut |
Cuts the selected contents and puts in into users clipboard. |
Copy |
Copies the selected contents and puts in into users clipboard. |
Paste |
Pastes the current clipboard contents into the editor. |
ForeColor |
Changes the text color of the text. The value passed in should be the color. |
BackColor |
Changes the background color of the text. The value passed in should be the color. |
JustifyLeft |
Left aligns the current text block/image. |
JustifyCenter |
Center aligns the current text block/image. |
JustifyRight |
Right aligns the current text block/image. |
JustifyFull |
Full aligns the current text block/image. |
FontName |
Font name to apply to the text. The value passed in should be the font family name. |
FontSize |
Font size of the text. The value passed in should be a valid CSS font size. |
FormatBlock |
Toggles the format of the current selection. The value passed in should be the format name. If no format is specified, the paragraph ( |
RemoveFormat |
Removes any formats from the current selection. |
Indent |
Indents the current selection. |
Outdent |
Outdents the current selection. |
CreateLink |
Inserts a link at the current selection. The value is the URL to add to the link(s). |
Unlink |
Removes any links from the current selection. |
InsertHorizontalRule |
Inserts a horizontal rule at the cursor location or inplace of the current selection. |
InsertParagraph |
Inserts a new paragraph or new line at the current cursor or selection. |
InsertText |
Inserts the passed value as plain text at the current cursor or selection. |
InsertHTML |
Inserts the passed value as HTML at the current cursor or selection. |
InsertImage |
Adds an image |
SelectAll |
Selects all content in the editor. |
Delete |
Deletes the current selection from the editor. |
ForwardDelete |
Deletes the current selection or the character to the right of the cursor for a collapsed selection. |
Redo |
Redoes the last change to the editor. |
Undo |
Undoes the last change to the editor. |
tinymce.activeEditor.execCommand('Bold');
tinymce.activeEditor.execCommand('Italic');
tinymce.activeEditor.execCommand('Underline');
tinymce.activeEditor.execCommand('Strikethrough');
tinymce.activeEditor.execCommand('Superscript');
tinymce.activeEditor.execCommand('Subscript');
tinymce.activeEditor.execCommand('Cut');
tinymce.activeEditor.execCommand('Copy');
tinymce.activeEditor.execCommand('Paste');
tinymce.activeEditor.execCommand('JustifyLeft');
tinymce.activeEditor.execCommand('JustifyCenter');
tinymce.activeEditor.execCommand('JustifyRight');
tinymce.activeEditor.execCommand('JustifyFull');
tinymce.activeEditor.execCommand('ForeColor', false, '#FF0000');
tinymce.activeEditor.execCommand('BackColor', false, '#FF0000');
tinymce.activeEditor.execCommand('FontName', false, 'courier new');
tinymce.activeEditor.execCommand('FontSize', false, '30px');
tinymce.activeEditor.execCommand('FormatBlock', false, 'bold');
tinymce.activeEditor.execCommand('RemoveFormat');
tinymce.activeEditor.execCommand('Indent');
tinymce.activeEditor.execCommand('Outdent');
tinymce.activeEditor.execCommand('CreateLink', false, 'https://www.tiny.cloud');
tinymce.activeEditor.execCommand('Unlink');
tinymce.activeEditor.execCommand('InsertHorizontalRule');
tinymce.activeEditor.execCommand('InsertParagraph');
tinymce.activeEditor.execCommand('InsertText', false, 'My text content');
tinymce.activeEditor.execCommand('InsertHTML', false, 'My HTML content');
tinymce.activeEditor.execCommand('InsertImage', false, 'https://www.example.com/image.png');
tinymce.activeEditor.execCommand('SelectAll');
tinymce.activeEditor.execCommand('Delete');
tinymce.activeEditor.execCommand('ForwardDelete');
tinymce.activeEditor.execCommand('Redo');
tinymce.activeEditor.execCommand('Undo');The commands in the following table are provided by the {productname} editor and provide additional functionality that does not require any plugins to be enabled.
| Command | Description |
|---|---|
HiliteColor |
Changes the background color of the text. The value passed in should be the color. NOTE: This is an alias for the |
InsertLineBreak |
Adds a line break |
InsertNewBlockAfter |
inserts an empty block at the root level of the current {productname} document immediately after the block containing the current selection. |
InsertNewBlockBefore |
inserts an empty block at the root level of the current {productname} document immediately before the block containing the current selection. |
JustifyNone |
Removes any alignment to the selected text. |
Lang |
Sets the language of the current selection. The value passed in should be a language spec described in Content appearance options - |
LineHeight |
Sets the line height of the text. The value passed in should be a valid CSS line height. |
mceAddUndoLevel |
Adds an undo level. |
mceApplyTextcolor |
Applies text color or background color to the current selection. Requires an argument of either |
mceAutocompleterClose |
Closes any active autocompleter menu. |
mceAutocompleterReload |
Reloads the autocompleter menu with new items. For the data to provide, see the Autocompleter reload API. |
mceBlockQuote |
Wraps the selected text blocks into a block quote. |
mceCleanup |
Copies the current editor content and sets the content using the copy. |
mceEndUndoLevel |
Adds an undo level. |
mceFocus |
Focuses and activates the editor. Places DOM focus inside the editor and also sets the editor as the active editor instance on the page. |
mceInsertClipboardContent |
Triggers a paste event at the cursor location or over the current selection. The command requires an object with: |
mceInsertContent |
Inserts contents at the current selection. The value passed in should be the contents to be inserted. |
mceInsertLink |
Inserts a link at the current selection. The value is the URL to add to the link(s). NOTE: This is an alias for the |
mceInsertNewLine |
Adds a new line at the current cursor or selection, such as splitting the current paragraph element. The behavior of this setting can be controlled with the newline_behavior option. |
mceNewDocument |
Removes all contents of the editor. |
mcePrint |
Opens the browser’s print dialog for the current page. |
mceRemoveNode |
Removes the current node or the target node passed as the value ( |
mceRemoveTextcolor |
Removes the text color or background color from the current selection. Requires an argument of either |
mceReplaceContent |
Replaces the current selection. The value passed in should be the new content. |
mceSelectNode |
Selects a node in the editor. The target node is passed as the value ( |
mceSelectNodeDepth |
Selects the parent DOM node 'n' levels above the current node. |
mceSetContent |
Sets the contents of the editor. The value is the contents to set as the editor contents. |
mceToggleFormat |
Toggles a specified format by name. The value is the name of the format to toggle. For a list of options, see: Content formatting options - Built-in formats. |
mceTogglePlainTextPaste |
Toggles paste as plain text. |
mceToggleVisualAid |
Toggles the visual aids for: tables without borders and anchors. |
ToggleSidebar |
Closes the current sidebar, or toggles the sidebar if the sidebar name is provided as a value ( |
ToggleToolbarDrawer |
Toggles the Toolbar Drawer. Can be used with the |
tinymce.activeEditor.execCommand('HiliteColor', false, '#FF0000');
tinymce.activeEditor.execCommand('InsertLineBreak');
tinymce.activeEditor.execCommand('InsertNewBlockAfter')
tinymce.activeEditor.execCommand('InsertNewBlockBefore')
tinymce.activeEditor.execCommand('JustifyNone');
tinymce.activeEditor.execCommand('Lang', false, { code: 'en_US' }); /* OR */
tinymce.activeEditor.execCommand('Lang', false, { code: 'en_US', customCode: 'en-us-medical' });
tinymce.activeEditor.execCommand('LineHeight', false, '1.4');
tinymce.activeEditor.execCommand('mceAddUndoLevel');
tinymce.activeEditor.execCommand('mceApplyTextcolor', 'hilitecolor', '#FF0000');
tinymce.activeEditor.execCommand('mceAutocompleterClose');
tinymce.activeEditor.execCommand('mceAutocompleterReload', false, {
fetchOptions: {}
});
tinymce.activeEditor.execCommand('mceBlockQuote');
tinymce.activeEditor.execCommand('mceCleanup');
tinymce.activeEditor.execCommand('mceEndUndoLevel');
tinymce.activeEditor.execCommand('mceFocus');
tinymce.activeEditor.execCommand('mceInsertClipboardContent', false, {
html: '<p>Hello, World!</p>'
});
tinymce.activeEditor.execCommand('mceInsertContent', false, 'My new content');
tinymce.activeEditor.execCommand('mceInsertLink', false, 'https://www.tiny.cloud');
tinymce.activeEditor.execCommand('mceInsertNewLine');
tinymce.activeEditor.execCommand('mceNewDocument');
tinymce.activeEditor.execCommand('mcePrint');
tinymce.activeEditor.execCommand('mceRemoveNode'); /* OR */
tinymce.activeEditor.execCommand('mceRemoveNode', false, '<DOM_node>');
tinymce.activeEditor.execCommand('mceSelectNode', false, '<DOM_node>');
tinymce.activeEditor.execCommand('mceSelectNodeDepth', false, 2); // For two nodes up.
tinymce.activeEditor.execCommand('mceSetContent', false, 'My content');
tinymce.activeEditor.execCommand('mceRemoveTextcolor', 'hilitecolor');
tinymce.activeEditor.execCommand('mceReplaceContent', false, 'My replacement content');
tinymce.activeEditor.execCommand('mceToggleFormat', false, 'bold');
tinymce.activeEditor.execCommand('mceTogglePlainTextPaste');
tinymce.activeEditor.execCommand('mceToggleVisualAid');
tinymce.activeEditor.execCommand('ToggleSidebar'); /* OR */
tinymce.activeEditor.execCommand('ToggleSidebar', false, '<sidebar-name>');
tinymce.activeEditor.execCommand('ToggleToolbarDrawer', false, null, { skip_focus: true });Commands are available for the following plugins:
The following commands require the Advanced Lists (advlist) plugin.
[[Enhanced Tables]] ==== Enhanced Tables
The following commands require the Enhanced Tables (advtable) plugin.
The following command requires the Autoresize (autoresize) plugin.
The following commands require the Case Change (casechange) plugin.
The following command requires the Character Map (charmap) plugin.
The following command requires the Code Sample (codesample) plugin.
The following commands require the Comments (tinycomments) plugin.
The following commands require the Directionality (directionality) plugin.
The following command requires the Enhanced Code Editor (advcode) plugin.
The following commands require the Emoticons (emoticons) plugin.
The following commands require the Export to PDF (exportpdf) plugin.
The following commands require the Export to Word (exportword) plugin.
The following commands require the Footnotes (footnotes) plugin.
The following commands require the Format Painter (formatpainter) plugin.
The following command requires the Full Screen (fullscreen) plugin and is only applicable when the editor is in classic mode.
The following command requires the Import from Word (importword) plugin.
The following commands require the Image Editing (editimage) plugin.
The following commands require the Insert Date/Time (insertdatetime) plugin.
The following commands require the List Styles (advlist) plugin.
The following command requires the Nonbreaking Space (nonbreaking) plugin.
The following command requires the Page Break (pagebreak) plugin.
The following commands require the Permanent Pen (permanentpen) plugin.
The following command requires the PowerPaste (powerpaste) plugin.
The following command requires the Preview (preview) plugin.
The following commands require the Revision History (revisionhistory) plugin.
The following command requires the Search and Replace (searchreplace) plugin.
The following commands require the Spell Checker (tinymcespellchecker) plugin.
For additional commands that are provided by the core table functionality, see Core Table Commands.
The following commands require the Table (table) plugin.
The following commands require the Table of Contents (tableofcontents) plugin.
The following commands require the Templates (advtemplate) plugin.
The following command requires the Visual Blocks (visualblocks) plugin.
The following command requires the Visual Characters (visualchars) plugin.
The following command requires the Word Count (wordcount) plugin.
The following commands are used to manage editor instances.
For example:
tinymce.execCommand('mceAddEditor', false, { id: '<editor_id>', options: {} });
tinymce.execCommand('mceRemoveEditor', false, '<editor_id>');
tinymce.execCommand('mceToggleEditor', false, { id: '<editor_id>' });
tinymce.execCommand('mceToggleEditor', false, { index: '<editor_index>' });| Command | Description |
|---|---|
mceAddEditor |
Converts an HTML or DOM element with the specified ID into an editor instance that uses the specified editor configuration options. For information on configuring the editor, see: Basic Setup. |
mceRemoveEditor |
Removes an editor instance with the specified ID. |
mceToggleEditor |
Runs |
{productname} provides the queryCommandState API to allow developers to determine the current state of selected content. The query will return true if the content is formatted using the same CSS styles and elements used by the corresponding command.
To retrieve a list of avaliable queryable states from the active editor, run the following command from the browser console:
tinymce.activeEditor.editorCommands.commands.state;The following command states can be queried using the queryCommandState API.
| Command | Description |
|---|---|
Bold |
Returns |
InsertDefinitionList |
Returns |
InsertOrderedList |
Returns |
InsertUnorderedList |
Returns |
Italic |
Returns |
JustifyCenter |
Returns |
JustifyFull |
Returns |
JustifyLeft |
Returns |
JustifyRight |
Returns |
mceBlockQuote |
Returns |
mceTogglePlainTextPaste |
Returns |
Outdent |
Returns |
Strikethrough |
Returns |
Subscript |
Returns |
Superscript |
Returns |
ToggleToolbarDrawer |
Returns |
Underline |
Returns |
tinymce.activeEditor.queryCommandState('Bold');
tinymce.activeEditor.queryCommandState('InsertDefinitionList');
tinymce.activeEditor.queryCommandState('InsertOrderedList');
tinymce.activeEditor.queryCommandState('InsertUnorderedList');
tinymce.activeEditor.queryCommandState('Italic');
tinymce.activeEditor.queryCommandState('JustifyCenter');
tinymce.activeEditor.queryCommandState('JustifyFull');
tinymce.activeEditor.queryCommandState('JustifyLeft');
tinymce.activeEditor.queryCommandState('JustifyRight');
tinymce.activeEditor.queryCommandState('mceBlockQuote');
tinymce.activeEditor.queryCommandState('mceTogglePlainTextPaste');
tinymce.activeEditor.queryCommandState('Outdent');
tinymce.activeEditor.queryCommandState('Strikethrough');
tinymce.activeEditor.queryCommandState('Subscript');
tinymce.activeEditor.queryCommandState('Superscript');
tinymce.activeEditor.queryCommandState('ToggleToolbarDrawer');
tinymce.activeEditor.queryCommandState('Underline');{productname} provides the queryCommandValue API to allow developers to determine the current state of selected content. The query will return an object containing the relevant value.
To retrieve a list of available queryable command values from the active editor, run the following command from the browser console:
tinymce.activeEditor.editorCommands.commands.value;The following command values can be queried using the queryCommandValue API.
| Command | Description |
|---|---|
FontName |
Returns the font name of the current selection. |
FontSize |
Returns the font size of the current selection. |
LineHeight |
Returns the line height of the current selection. |
ToggleSidebar |
Returns the current state of sidebar (open or closed). |
ToggleView |
Returns the current state of the view, for example: |
tinymce.activeEditor.queryCommandValue('FontName');
tinymce.activeEditor.queryCommandValue('FontSize');
tinymce.activeEditor.queryCommandValue('LineHeight');
tinymce.activeEditor.queryCommandValue('ToggleSidebar');
tinymce.activeEditor.queryCommandValue('ToggleView');