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 avaliable commands from the active editor, run the following command from the browser console:
tinymce.activeEditor.editorCommands.commands.exec;The commands on the following table are provided by the {productname} editor and do not require any plugins to be enabled.
| Command | Description |
|---|---|
Bold |
Toggles bold formatting to selection. |
Italic |
Toggles italic formatting to selection. |
Underline |
Toggles underline formatting to selection. |
Strikethrough |
Toggles strikethough 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. |
Lang |
Sets the language of the current selection. The value passed in should be a language spec described in Content appearance options - |
Paste |
Pastes the current clipboard contents into the editor. |
mceInsertLink |
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. |
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. |
JustifyNone |
Removes any alignment to the selected text. |
ForeColor |
Changes the text color of the text. The value passed in should be the color. |
HiliteColor |
Changes the background color of the text. The value passed in should be the color. |
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. |
LineHeight |
Sets the line height of the text. The value passed in should be a valid CSS line height. partial$misc/requires_5_5v.adoc |
mceApplyTextcolor |
Applies text color or background color to the current selection. Requires an argument of either |
mceRemoveTextcolor |
Removes the text color or background color from the current selection. Requires an argument of either |
RemoveFormat |
Removes any formats from the current selection. |
mceBlockQuote |
Wraps the selected text blocks into a block quote. |
FormatBlock |
Toggles the format of the current selection. The value passed in should be the format name. If no format is specified, the paragraph ( |
mceInsertContent |
Inserts contents at the current selection. The value passed in should be the contents to be inserted. |
mceReplaceContent |
Replaces the current selection. The value passed in should be the new content. |
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. |
ToggleSidebar |
Closes the currrent sidebar, or toogles the sidebar if the sidebar name is provided as a value ( |
ToggleToolbarDrawer |
Toggles the Toolbar Drawer. For information on toolbars, see: User interface options - Toolbar. partial$misc/requires_5_5v.adoc |
Indent |
Indents the current selection. |
Outdent |
Outdents the current selection. |
InsertHorizontalRule |
Inserts a horizontal rule at the cursor location or inplace of the current selection. |
InsertLineBreak |
Adds a line break |
mceInsertNewLine |
Adds a new line at the current cursor or selection, such as splitting the current paragraph element. |
mceInsertRawHTML |
Inserts the RAW HTML passed as a value, overwriting the current selection or at the cursor position. Warning: This command allows dangerous |
mceToggleVisualAid |
Toggles the visual aids for: tables without borders and anchors. |
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. |
mceNewDocument |
Removes all contents of the editor. |
Redo |
Redoes the last change to the editor. |
Undo |
Undoes the last change to the editor. |
mceAddUndoLevel |
Adds an undo level. |
mceEndUndoLevel |
Adds an undo level. |
mceCleanup |
Copies the current editor content and sets the content using the copy. |
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. |
mceRemoveNode |
Removes the current node or the target node passed as the value ( |
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. partial$misc/requires_5_9v.adoc |
Examples
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('mceInsertLink', false, 'https://www.tiny.cloud');
tinymce.activeEditor.execCommand('Unlink');
tinymce.activeEditor.execCommand('JustifyLeft');
tinymce.activeEditor.execCommand('JustifyCenter');
tinymce.activeEditor.execCommand('JustifyRight');
tinymce.activeEditor.execCommand('JustifyFull');
tinymce.activeEditor.execCommand('JustifyNone');
tinymce.activeEditor.execCommand('ForeColor', false, '#FF0000');
tinymce.activeEditor.execCommand('HiliteColor', false, '#FF0000');
tinymce.activeEditor.execCommand('FontName', false, 'courier new');
tinymce.activeEditor.execCommand('FontSize', false, '30px');
tinymce.activeEditor.execCommand('LineHeight', false, '1.4');
tinymce.activeEditor.execCommand('mceApplyTextcolor', 'hilitecolor', '#FF0000');
tinymce.activeEditor.execCommand('mceRemoveTextcolor', 'hilitecolor');
tinymce.activeEditor.execCommand('RemoveFormat');
tinymce.activeEditor.execCommand('mceBlockQuote');
tinymce.activeEditor.execCommand('FormatBlock', false, 'bold');
tinymce.activeEditor.execCommand('mceInsertContent', false, 'My new content');
tinymce.activeEditor.execCommand('mceReplaceContent', false, 'My replacement content');
tinymce.activeEditor.execCommand('mceSetContent', false, 'My content');
tinymce.activeEditor.execCommand('mceToggleFormat', false, 'bold');
tinymce.activeEditor.execCommand('ToggleSidebar'); /* OR */
tinymce.activeEditor.execCommand('ToggleSidebar', false, '<sidebar-name>');
tinymce.activeEditor.execCommand('ToggleToolbarDrawer');
tinymce.activeEditor.execCommand('Indent');
tinymce.activeEditor.execCommand('Outdent');
tinymce.activeEditor.execCommand('InsertHorizontalRule');
tinymce.activeEditor.execCommand('InsertLineBreak');
tinymce.activeEditor.execCommand('mceInsertNewLine');
tinymce.activeEditor.execCommand('mceInsertRawHTML', false, '<p>Hello, World!</p>');
tinymce.activeEditor.execCommand('mceToggleVisualAid');
tinymce.activeEditor.execCommand('SelectAll');
tinymce.activeEditor.execCommand('Delete');
tinymce.activeEditor.execCommand('ForwardDelete');
tinymce.activeEditor.execCommand('mceNewDocument');
tinymce.activeEditor.execCommand('Redo');
tinymce.activeEditor.execCommand('Undo');
tinymce.activeEditor.execCommand('mceAddUndoLevel');
tinymce.activeEditor.execCommand('mceEndUndoLevel');
tinymce.activeEditor.execCommand('mceCleanup');
tinymce.activeEditor.execCommand('mceSelectNode', false, '<DOM_node>');
tinymce.activeEditor.execCommand('mceSelectNodeDepth', false, 2); // For two nodes up.
tinymce.activeEditor.execCommand('mceRemoveNode'); /* OR */
tinymce.activeEditor.execCommand('mceRemoveNode', false, '<DOM_node>');
tinymce.activeEditor.execCommand('mceFocus');Commands are available for the following plugins:
The following command requires the Advanced Code (advcode) plugin.
The following commands require the Advanced Lists (advlist) plugin.
The following commands require the Advanced 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 commands require the Emoticons (emoticons) plugin.
The following commands require the Format Painter (formatpainter) plugin.
The following command requires the Full Page (fullpage) plugin.
The following command requires the Full Screen (fullscreen) plugin.
The following commands require the Image Tools (imagetools) plugin.
The following commands require the Insert Date/Time (insertdatetime) 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 command requires the Search and Replace (searchreplace) plugin.
The following command requires the Spell Checker (spellchecker) plugin.
The following commands require the Spell Checker Pro (tinymcespellchecker) plugin.
The following command requires the Template (template) plugin.
The following commands require the Table of Contents (toc) 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, '<editor_id>');
tinymce.execCommand('mceRemoveEditor', false, '<editor_id>');
tinymce.execCommand('mceToggleEditor', false, '<editor_id>');| Command | Description |
|---|---|
mceAddEditor |
Converts the specified HTML or DOM element into an editor instance with the specified ID. |
mceRemoveEditor |
Removes an editor instance with the specified ID. |
mceToggleEditor |
Runs mceAddEditor if an editor is not detected for the specified ID, otherwise it runs either hide if the editor is visible or show if it is not visible. |
{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 |
Outdent |
Returns |
Strikethrough |
Returns |
Subscript |
Returns |
Superscript |
Returns |
ToggleToolbarDrawer |
Returns |
Underline |
Returns |
Examples
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('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 avaliable 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. partial$misc/requires_5_5v.adoc |
ToggleSidebar |
Returns the current state of sidebar (open or closed). |
Examples
tinymce.activeEditor.queryCommandValue('FontName');
tinymce.activeEditor.queryCommandValue('FontSize');
tinymce.activeEditor.queryCommandValue('LineHeight');
tinymce.activeEditor.queryCommandValue('ToggleSidebar');