New to Kendo UI for Angular? Start a free 30-day trial

Toolbar Tools

The Editor provides user interface tools and directives for associating these tools with edit-action commands through the Kendo UI for Angular ToolBarComponent.

By default, the Editor supports a default toolbar configuration which includes basic formatting controls and list options.

To add, remove, or regroup the default tools:

  1. Nest the kendo-toolbar tag inside the kendo-editor tag.
  2. Either include specific built-in tools or create and implement custom tools.

Built-In Tools

Out of the box, the Editor provides text formatting, list, images and link management options.

Example
View Source
Change Theme:

Available Control Types

Depending on their visual implementation, the built-in tools are grouped in toolbar control types. The Kendo UI for Angular Editor provides the following control types:

Each control type supports a set of commands. For a list of all Editor commands, refer to the Editor API.

The following tables list the directives and components with their associated commands by control type.

Buttons

The built-in tools are implemented through specific directives and components, which automatically sets the icon of the button, click action, and the selected or disabled state.

DirectiveAssociated Command
Typographical Emphases
kendoEditorBoldButtonbold
kendoEditorItalicButtonitalic
kendoEditorStrikethroughButtonstrikethrough
kendoEditorSubscriptButtonsubscript
kendoEditorSuperscriptButtonsuperscript
kendoEditorUnderlineButtonunderline
Alignment Actions
kendoEditorAlignCenterButtonalignCenter
kendoEditorAlignJustifyButtonalignJustify
kendoEditorAlignLeftButtonalignLeft
kendoEditorAlignRightButtonalignRight
Historical Context
kendoEditorRedoButtonredo
kendoEditorUndoButtonundo
Links Handling
kendoEditorUnlinkButtonunlink
Lists Implementation
kendoEditorInsertOrderedListButtoninsertOrderedList
kendoEditorInsertUnorderedListButtoninsertUnorderedList
Handle Indentation
kendoEditorIndentButtonindent
kendoEditorOutdentButtonoutdent
Common Buttons Behavior
kendoEditorCleanFormattingButtoncleanFormatting
kendoEditorPrintButtonprint
kendoEditorSelectAllButtonselectAll
Tables Creation and Editing
kendoEditorAddColumnAfterButtonaddColumnAfter
kendoEditorAddColumnBeforeButtonaddColumnBefore
kendoEditorAddRowAfterButtonaddRowAfter
kendoEditorAddRowBeforeButtonaddRowBefore
kendoEditorDeleteColumnButtondeleteColumn
kendoEditorDeleteRowButtondeleteRow
kendoEditorDeleteTableButtondeleteTable
kendo-editor-insert-table-buttonOpens a popup with table configurator

The following directives open various Editor insert dialogs.

DirectiveAction
kendoEditorInsertImageButtonOpen image options dialog
kendoEditorCreateLinkButtonOpen link options dialog
kendoEditorInsertFileButtonOpen file options dialog
kendoEditorViewSourceButtonOpen view source dialog

Dialogs

The following commands are executed when the corresponding Dialog action is confirmed.

ActionAssociated Command
Insert imageinsertImage
Create linkcreateLink
Insert fileinsertFile
Update the sourcesetHTML

DropDownLists

Each directive automatically defines the options of the drop-down list and sets its value.

DirectiveAssociated Command
kendoEditorFontFamilyfontFamily (accepts FontFamilyItem parameter)
kendoEditorFontSizefontSize (accepts FontSizeItem parameter)
kendoEditorFormatformat (accepts FormatItem parameter)

All of these tools allow providing a customized options collection for their respective styling setting.

For example, the font size tool can be used with all valid font-size units, e.g. px, rem, etc. Its data option takes a collection of FontSizeItem objects that constitute the custom font-sizes.

Example
View Source
Change Theme:

ColorPickers

Each directive automatically defines the icon and the target of the operation over the color or background-color CSS properties.

The supported commands associate a kendo-toolbar-colorpicker component that changes the foreground and background color of the current selection.

DirectiveAssociated Command
kendoEditorForeColorforeColor
kendoEditorBackColorbackColor

Applying Commands to Words

By default, tools which apply text modifiers are affecting the current selection only (as in Google Docs). Those are the commands associated with:

  • Typographical emphases—bold, italic, underline, strikethrough, superscript, subscript
  • Fore and Background color—foreColor and backColor
  • Font size and family—fontSize and fontFamily
  • Link creation—createLink

To apply the respective tool command to the whole word the cursor is in, when no selection is present (as in MS Word), set the applyToWord option to true.

If there is an applied selection, the command will only affect that section, instead of the whole word.

The following example demonstrates how to apply text modifying commands to the whole word the cursor is in.

Example
View Source
Change Theme:

Customizing Word Delimiters

The applyToWord property also accepts an ApplyToWordOptions configuration object, which enables you to configure the following options:

  • before—Regular expression of consequtive characters which will delimit the start of a word, when applying a command. The default value is /[^ !,?.\[\]{}()]+$/i
  • after—Regular expression of consequtive characters which will delimit the end of a word, when applying a command. The default value is /^[^ !,?.\[\]{}()]+/i

The default word delimiters are white-space and the following characters ! , ? . [ ] { } ( )

The following example demonstrates how to specify custom word delimiters via regular expressions. For the purposes of the demo, only a line terminator will be considered a delimiter.

Example
View Source
Change Theme:

Custom Tools

Depending on the requirements of your project, the Editor enables you to create and implement your own custom tools.

Adding Custom UI Elements to the Toolbar

For more information, refer to the article on supported custom control types by the Kendo UI ToolBar for Angular.

Associating Command Tools with Directives

You can also create custom directives that control the look and behavior of the toolbar tools.

The following example demonstrates how to create a directive that sets the icon of the button and executes an Editor command on click. You can obtain a reference to the Editor through the Angular Host decorator.

Example
View Source
Change Theme:

Associating Toolbar Tools with Editor Commands

To execute commands that modify the text of the Editor, you can use the exec method of the component. The method accepts two arguments—command name and attributes (optional).

<kendo-toolbar-button
    ext="Insert HTML"
    (click)="editor.exec('setHTML', '<p>HTML content</p>')"
></kendo-toolbar-button>

The following example demonstrates how to call a bold command when the user clicks a toolbar button.

Example
View Source
Change Theme:

The table below lists all commands the exec method supports.

CommandDescriptionUsage
alignLeftAligns the text to the left.editor.exec('alignLeft');
alignCenterAligns the text to the center.editor.exec('alignCenter');
alignRightAligns the text to the right.editor.exec('alignRight');
alignJustifyJustifies the text.editor.exec('alignJustify');
addColumnBeforeAdds a column before the current position.editor.exec('addColumnBefore');
addColumnAfterAdds a column after the current position.editor.exec('addColumnAfter');
addRowBeforeAdds a row before the current position.editor.exec('addRowBefore');
addRowAfterAdds a row after the current position.editor.exec('addRowAfter');
boldToggles the bold styling.editor.exec('bold');
backColorSets the background color.editor.exec('backColor', { value: '#ffff00' });
blockquoteApplies a blockquote style.editor.exec('blockquote');
createLinkCreates a hyperlink.editor.exec('createLink', { href: 'www.progress.com', title: 'Progress', target: 'window' });
cleanFormatRemoves formatting.editor.exec('cleanFormat');
cleanFormattingCleans formatting.editor.exec('cleanFormatting');
deleteRowDeletes the current row.editor.exec('deleteRow');
deleteColumnDeletes the current column.editor.exec('deleteColumn');
deleteTableDeletes the table.editor.exec('deleteTable');
formatChanges the format of a text block.editor.exec('format', { tag: 'h2' });
fontFamilyChanges the font family.editor.exec('fontFamily', { value: 'Arial' });
fontSizeChanges the font size of the selected text.editor.exec('fontSize', 24);
foreColorSets the text color.editor.exec('foreColor', { value: '#ff0000' });
italicToggles the italic styling.editor.exec('italic');
insertFileInserts a file.editor.exec('insertFile', { href: 'fileLink', title: 'My file', target: 'window' });
insertImageInserts an image.editor.exec('insertImage', { src: 'imageLink', title: 'Progress', target: 'window' });
insertOrderedListInserts an ordered list.editor.exec('insertOrderedList');
insertUnorderedListInserts an bullet list.editor.exec('insertUnorderedList');
insertTextInserts a text at a given position. If no position is specified, the text will be inserted after the cursor.editor.exec('insertText', { text: 'Hello World!', from: 0, to: 0 });
indentIndents the text.editor.exec('indent');
insertTableCreates and inserts a table with the specified number of rows and columns. Numbers are zero based.editor.exec('insertTable', { rows: 3, cols: 5 });
mergeCellsMerges selected cells.editor.exec('mergeCells');
outdentOutdents the text.editor.exec('outdent');
redoRedoes the last undone action.editor.exec('redo');
strikethroughToggles the strikethrough styling.editor.exec('strikethrough');
subscriptToggles subscript styling.editor.exec('subscript');
superscriptToggles superscript styling.editor.exec('superscript');
splitCellSplits the current cell.editor.exec('splitCell');
selectAllSelects all content.editor.exec('selectAll');
setHTMLChanges the content of the Editor.editor.exec('setHTML', '<p>HTML content</p>');
underlineToggles the underline styling.editor.exec('underline');
undoUndoes the last action.editor.exec('undo');
unlinkRemoves the hyperlink.editor.exec('unlink');