Angular HtmlEditor - Predefined Items

Toolbar items allow users to format HTML Editor content and perform actions in it.

Predefined toolbar items include:

  • Buttons that apply single-choice formats to the text
  • Action buttons
  • Select boxes that apply multiple-choice formats
  • Separators that are not user-interactive and only divide other elements

DevExtreme HTML5 JavaScript HTML Editor Toolbar

The following table lists toolbar items and the formats they apply (if applicable):

Toolbar item nameFormatacceptedValues
"background""background"Any value the background-color CSS property accepts.
"bold""bold"true or false
"color""color"Any value the color CSS property accepts.
"italic""italic"true or false
"link""link"String
or
Object ({ href: String, text: String, target: Boolean })
"image""extendedImage"String
or
Object ({ src: String, width: Number, height: Number, alt: String })
"strike""strike"true or false
"subscript""script""sub"
"superscript""script""super"
"underline""underline"true or false
"blockquote""blockquote"true or false
"header""header"1, 2, 3, 4, 5, or 6
"increaseIndent""indent""+1"
"decreaseIndent""indent""-1"
"orderedList""list""ordered"
"bulletList""list""bullet"
"alignLeft""align""left"
"alignCenter""align""center"
"alignRight""align""right"
"alignJustify""align""justify"
"codeBlock""code-block"true or false
"variable""variable"Object ({ value: String, escapeChar: String | Array<String> })
"font""font"Any value the font-family CSS property accepts.
"size""size"Any value the font-size CSS property accepts.
"undo"--
"redo"--
"clear"--
"separator"--
"cellProperties"--
"tableProperties"--
"insertTable"--
"insertHeaderRow"--
"insertRowAbove"--
"insertRowBelow"--
"insertColumnLeft"--
"insertColumnRight"--
"deleteColumn"--
"deleteRow"--
"deleteTable"--
"ai"--
NOTE
Configure aiIntegration to use the "ai" item.

To add a button to the toolbar, add its name to the items array:

HTML
TypeScript
  • <dx-html-editor>
  • <dxo-html-editor-toolbar>
  • <dxi-html-editor-item name="bold"></dxi-html-editor-item>
  • <dxi-html-editor-item name="italic"></dxi-html-editor-item>
  • <dxi-html-editor-item name="alignRight"></dxi-html-editor-item>
  • <dxi-html-editor-item name="alignLeft"></dxi-html-editor-item>
  • </dxo-html-editor-toolbar>
  • </dx-html-editor>
  • import { DxHtmlEditorModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • // ...
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxHtmlEditorModule
  • ],
  • // ...
  • })

To add a select box, specify the name and acceptedValues:

HTML
TypeScript
  • <dx-html-editor>
  • <dxo-html-editor-toolbar>
  • <dxi-html-editor-item
  • [acceptedValues]="headerAcceptedValues"
  • name="header"
  • />
  • <dxi-html-editor-item
  • [acceptedValues]="alignAcceptedValues"
  • name="align"
  • />
  • </dxo-html-editor-toolbar>
  • </dx-html-editor>
  • import { DxHtmlEditorModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • headerAcceptedValues = [1, 2, 3, false];
  • alignAcceptedValues = ["left", "right", "center"];
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxHtmlEditorModule
  • ],
  • // ...
  • })

Customize Predefined Items

To customize a button, assign its name to the name property and specify button properties in the options object:

HTML
TypeScript
  • <dx-html-editor>
  • <dxo-html-editor-toolbar>
  • <dxi-html-editor-item
  • [options]="clearFormatOptions"
  • name="clear">
  • </dxi-html-editor-item>
  • </dxo-html-editor-toolbar>
  • </dx-html-editor>
  • import { DxHtmlEditorModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • clearFormatOptions = { icon: "clear", type: "danger" };
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxHtmlEditorModule
  • ],
  • // ...
  • })

To customize a select box, specify select box properties in the options object in addition to the name and acceptedValues properties:

HTML
TypeScript
  • <dx-html-editor>
  • <dxo-html-editor-toolbar>
  • <dxi-html-editor-item
  • [options]="sizeFormatOptions"
  • [acceptedValues]="sizeAcceptedValues"
  • name="size"
  • />
  • </dxo-html-editor-toolbar>
  • </dx-html-editor>
  • import { DxHtmlEditorModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • sizeAcceptedValues = ["11px", "14px", "16px"];
  • sizeFormatOptions = { width: 150 };
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxHtmlEditorModule
  • ],
  • // ...
  • })
See Also