DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Angular Html Editor - Toolbar Customization

This demo shows how to add a custom control to the toolbar. The Show markup button opens a popup that displays the HTML Editor's output markup.

Backend API
<dx-html-editor [(value)]="editorValue"> <dxo-html-editor-toolbar> <dxi-html-editor-item name="undo"></dxi-html-editor-item> <dxi-html-editor-item name="redo"></dxi-html-editor-item> <dxi-html-editor-item name="separator"></dxi-html-editor-item> <dxi-html-editor-item name="header" [acceptedValues]="[false, 1, 2, 3, 4, 5]" [options]="{ inputAttr: { 'aria-label': 'Header' } }" ></dxi-html-editor-item> <dxi-html-editor-item name="separator"></dxi-html-editor-item> <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="strike"></dxi-html-editor-item> <dxi-html-editor-item name="underline"></dxi-html-editor-item> <dxi-html-editor-item name="separator"></dxi-html-editor-item> <dxi-html-editor-item name="alignLeft"></dxi-html-editor-item> <dxi-html-editor-item name="alignCenter"></dxi-html-editor-item> <dxi-html-editor-item name="alignRight"></dxi-html-editor-item> <dxi-html-editor-item name="alignJustify"></dxi-html-editor-item> <dxi-html-editor-item name="separator"></dxi-html-editor-item> <dxi-html-editor-item widget="dxButton" [options]="toolbarButtonOptions" ></dxi-html-editor-item> </dxo-html-editor-toolbar> </dx-html-editor> <dx-popup [showTitle]="true" title="Markup" [(visible)]="popupVisible" [showCloseButton]="true" > <div>{{ editorValue }}</div> </dx-popup>
import { bootstrapApplication } from '@angular/platform-browser'; import { ChangeDetectorRef, Component, enableProdMode, provideZoneChangeDetection, } from '@angular/core'; import { DxHtmlEditorModule, DxPopupModule } from 'devextreme-angular'; import { DxButtonTypes } from 'devextreme-angular/ui/button'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], providers: [Service], imports: [ DxHtmlEditorModule, DxPopupModule, ], }) export class AppComponent { editorValue: string; popupVisible: boolean; toolbarButtonOptions: DxButtonTypes.Properties = { text: 'Show markup', stylingMode: 'text', onClick: () => { this.popupVisible = true; this.changeDetectorRef.detectChanges(); }, }; constructor(service: Service, private changeDetectorRef: ChangeDetectorRef) { this.editorValue = service.getMarkup(); } } bootstrapApplication(AppComponent, { providers: [ provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }), ], });
::ng-deep .dx-htmleditor-content img { vertical-align: middle; padding-right: 10px; }
import { Injectable } from '@angular/core'; const markup = ` <h2> <img src="../../../../images/widgets/HtmlEditor.svg" alt="HtmlEditor"> Formatted Text Editor (HTML Editor) </h2> <br> <p>DevExtreme JavaScript HTML Editor is a client-side WYSIWYG text editor that allows its users to format textual and visual content and store it as HTML.</p> <p>Supported features:</p> <ul> <li>Inline formats: <ul> <li><strong>Bold</strong>, <em>italic</em>, <s>strikethrough</s> text formatting</li> <li>Font, size, color changes (HTML only)</li> </ul> </li> <li>Block formats: <ul> <li>Headers</li> <li>Text alignment</li> <li>Lists (ordered and unordered)</li> <li>Code blocks</li> <li>Quotes</li> </ul> </li> <li>Custom formats</li> <li>Mail-merge placeholders (for example, %username%)</li> <li>Adaptive toolbar for working images, links, and color formats</li> <li>Image upload: drag-and-drop images onto the form, select files from the file system, or specify a URL.</li> <li>Copy-paste rich content (unsupported formats are removed)</li> <li>Tables support</li> </ul> `; @Injectable() export class Service { getMarkup(): string { return markup; } }
<!DOCTYPE html> <html lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> <script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script> <script src="./bundle.js" type="module"></script> </body> </html>