TEXT EDIT
Text-related commands executed via editor.execCommand — text input/deletion, text style (bold/italic/underline/strike), font family/size, color, case conversion, run-style copy/paste, and more.
Commands
command - addRunPropertiescommand - addRunStylecommand - boldcommand - copyRunStylecommand - decreaseFontSizecommand - deleteLeftcommand - deleteRightcommand - entercommand - fillcommand - fontNamecommand - fontSizecommand - increaseFontSizecommand - insertLineBreakcommand - insertTextcommand - italiccommand - lowerCasecommand - pasteRunStylecommand - removeTextStylecommand - replaceTextcommand - replaceTextByIndexcommand - setTextVertAligncommand - strikecommand - tabcommand - textFillcommand - titleCasecommand - toggleCasecommand - underlinecommand - untabcommand - upperCase
command - addRunProperties
Release 3.2.2507+
Adds className and HTML attributes to the selected text. Properties accumulate on top of existing ones. If an attribute value is null (or empty string), that attribute is removed.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
properties | object | Properties to apply |
properties.className | string | Class name to add |
properties.attributes | object | HTML attributes to add (value null removes the attribute) |
editor.execCommand('addRunProperties', {
className: 'Butterfly',
attributes: {
'title': 'Beautiful butterfly',
'aria-label': 'Beautiful butterfly'
}
});
editor.execCommand('addRunProperties', {
className: 'Beautiful',
attributes: { 'title': '' } // empty string removes the attribute
});
command - addRunStyle
Adds a style to the selected text. The style accumulates on top of existing styles.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
style | object | Style to apply |
editor.execCommand('addRunStyle', { fontSize: { value: 20, unit: 'pt' } }); // add font size
editor.execCommand('addRunStyle', { color: { r: 255, g: 0, b: 0 } }); // add text color
editor.execCommand('addRunStyle', { backgroundColor: { r: 0, g: 0, b: 255 } }); // add background color
command - bold
Bolds the selected text. With only a caret, sets bold for upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('bold');
command - copyRunStyle
Copies the text style at the caret position. Related: command - pasteRunStyle.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('copyRunStyle');
command - decreaseFontSize
Decreases the font size of the selected text by one step. With only a caret, applies to upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('decreaseFontSize');
command - deleteLeft
Deletes the character to the left of the caret. If a selection exists, removes the selection.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('deleteLeft');
command - deleteRight
Deletes the character to the right of the caret. If a selection exists, removes the selection.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('deleteRight');
command - enter
Splits the paragraph at the caret position. If a selection exists, removes the selection first, then splits.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('enter');
command - fill
Sets the background color of the selected text. With only a caret, applies to upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
colorCode | string | Hex color (e.g. '#000000') |
editor.execCommand('fill', '#000000');
command - fontName
Sets the font family of the selected text. With only a caret, applies to upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
fontName | string | Font name |
editor.execCommand('fontName', 'Arial');
command - fontSize
Sets the font size of the selected text. With only a caret, applies to upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
fontSize | number | Text size in pt |
editor.execCommand('fontSize', 12);
command - increaseFontSize
Increases the font size of the selected text by one step. With only a caret, applies to upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('increaseFontSize');
command - insertLineBreak
Inserts a <br> at the caret position. If a selection exists, removes the selection first.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('insertLineBreak');
command - insertText
Inserts text at the caret position. If a selection exists, removes the selection first.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
text | string | Text to insert |
editor.execCommand('insertText', 'text');
command - italic
Italicizes the selected text. With only a caret, sets italic for upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('italic');
command - lowerCase
Converts letters in the selected text to lowercase.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('lowerCase');
command - pasteRunStyle
Applies the previously-copied text style to the selected text. Related: command - copyRunStyle.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('pasteRunStyle');
command - removeTextStyle
Removes the style from the selected text.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('removeTextStyle');
command - replaceText
Replaces the selected text with the given text.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
text | string | Replacement text |
editor.execCommand('replaceText', 'text');
command - replaceTextByIndex
Replaces text at the positions specified by targets with the given text.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
text | string | Replacement text |
targets | Object[] | [{ id: string, startIndex: number, endIndex: number }, ...] — id is a paragraph ID; startIndex / endIndex mark the range to replace |
editor.execCommand('replaceTextByIndex', 'text', [
{ id: 'paragraphId1', startIndex: 0, endIndex: 3 },
{ id: 'paragraphId2', startIndex: 5, endIndex: 15 }
]);
command - setTextVertAlign
Sets a superscript or subscript on the selected text. With only a caret, applies to upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
value | string | 'superscript' or 'subscript' |
editor.execCommand('setTextVertAlign', 'superscript'); // superscript
editor.execCommand('setTextVertAlign', 'subscript'); // subscript
command - strike
Strikes through the selected text. With only a caret, sets strike for upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('strike');
command - tab
Inserts a tab at the caret position. If a selection exists, the selection is removed first. Inside a table cell, moves to the next cell. At the start of a paragraph, increases the indent.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('tab');
command - textFill
Sets the text color of the selected text. With only a caret, applies to upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
colorCode | string | Hex color (e.g. '#000000') |
editor.execCommand('textFill', '#000000');
command - titleCase
Capitalizes the first letter of each word in the selected text.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('titleCase');
command - toggleCase
Toggles the case of letters in the selected text — uppercase becomes lowercase and vice versa.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('toggleCase');
command - underline
Underlines the selected text. With only a caret, sets underline for upcoming input.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('underline');
command - untab
Inside a table cell, moves to the previous cell. At the start of a paragraph, decreases the indent.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('untab');
command - upperCase
Converts letters in the selected text to uppercase.
| Name | Type | Description |
|---|---|---|
actionName | string | Action name |
editor.execCommand('upperCase');