Getting Started with the Kendo UI for Angular Editor

The Editor enables users to create rich textual content through a What-You-See-Is-What-You-Get (WYSIWYG) interface.

It delivers a set of tools for creating, editing, and formatting of text, paragraphs, lists, and other HTML elements.

The Editor is currently in its Beta version. Feel fully encouraged to share your feedback. To check the known issues and file bug reports, use the Kendo UI for Angular issue tracker.

Basic Usage

The following example demonstrates the Editor in action.

@Component({
    selector: 'my-app',
    template: `
        <kendo-editor [value]="value" style="height: 370px;"></kendo-editor>
    `
})
export class AppComponent {
    public value: string = `
        <p>
            The Kendo UI Angular Editor allows your users to edit HTML in a familiar, user-friendly way.<br />
            In this version, the Editor provides the core HTML editing engine which includes basic text formatting, hyperlinks, and lists.
            The widget <strong>outputs identical HTML</strong> across all major browsers, follows
            accessibility standards, and provides API for content manipulation.
        </p>
        <p>Features include:</p>
        <ul>
            <li>Text formatting</li>
            <li>Bulleted and numbered lists</li>
            <li>Hyperlinks</li>
            <li>Cross-browser support</li>
            <li>Identical HTML output across browsers</li>
        </ul>
    `;
}

Installation

Either use the quick setup (Angular CLI v6 or later) or manually add the package (Angular CLI v5 or earlier).

Quick Setup with Angular CLI v6 or Later

Angular CLI v6 supports the addition of packages through the ng add command which executes in one step the set of otherwise individually needed commands.

ng add @progress/kendo-angular-editor

Manual Setup

  1. Download and install the package.

    npm install --save @progress/kendo-angular-editor @progress/kendo-angular-buttons @progress/kendo-angular-common @progress/kendo-angular-dialog @progress/kendo-angular-dropdowns @progress/kendo-angular-inputs @progress/kendo-angular-intl @progress/kendo-angular-l10n @progress/kendo-angular-popup @progress/kendo-angular-toolbar @progress/kendo-drawing
  2. Once installed, import the EditorModule in your application root or feature module.

    import { Component, NgModule } from '@angular/core';
    import { RouterModule } from '@angular/router';
    import { CommonModule } from '@angular/common';
    import { EditorModule } from '@progress/kendo-angular-editor';
    
    @NgModule({
       declarations: [
           AppComponent,
       ],
       imports: [
           RouterModule.forChild(
               [{
                   path: '',
                   component: AppComponent
               }]
           ),
           CommonModule,
           EditorModule
       ]
    })
    export class AppModule {}
  3. You are required to install one of the Kendo UI themes for Angular to style your component. For more information on how to add the styles, refer to the section on styling.

  4. For Angular 9.x and later, install the @angular/localize package:

    1. Run npm install --save @angular/localize.
    2. Add import '@angular/localize/init'; to your src/polyfills.ts file.

Dependencies

The Editor package requires you to install the following peer dependencies in your application:

  • @angular/common
  • @angular/core
  • @angular/forms
  • rxjs
  • @progress/kendo-angular-buttons
  • @progress/kendo-angular-common
  • @progress/kendo-angular-dialog
  • @progress/kendo-angular-dropdowns
  • @progress/kendo-angular-inputs
  • @progress/kendo-angular-intl
  • @progress/kendo-angular-l10n
  • @progress/kendo-angular-popup
  • @progress/kendo-angular-toolbar
  • @progress/kendo-drawing

The following dependencies are automatically installed:

  • prosemirror-commands
  • prosemirror-history
  • prosemirror-inputrules
  • prosemirror-keymap
  • prosemirror-schema-basic
  • prosemirror-schema-list
  • prosemirror-state
  • prosemirror-model
  • prosemirror-view
  • @types/prosemirror-commands
  • @types/prosemirror-history
  • @types/prosemirror-inputrules
  • @types/prosemirror-keymap
  • @types/prosemirror-model
  • @types/prosemirror-schema-basic
  • @types/prosemirror-schema-list
  • @types/prosemirror-state
  • @types/prosemirror-view

Functionality and Features

Events

The following example demonstrates the valueChange event of the Editor.

import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: `
        <kendo-editor [value]="value" (valueChange)="valueChange($event)" style="height: 400px;"></kendo-editor>
        <event-log title="Event log" [events]="events"></event-log>
    `
})
export class AppComponent {
    public events: string[] = [];
    public value = `
        <p>
            The Kendo Angular UI Editor allows your users to edit HTML in a familiar, user-friendly way.<br />
            In this version, the Editor provides the core HTML editing engine, which includes basic text formatting, hyperlinks and lists.
            The widget <strong>outputs identical HTML</strong> across all major browsers, follows
            accessibility standards, and provides API for content manipulation.
        </p>
        <p>Features include:</p>
        <ul>
            <li>Text formatting</li>
            <li>Bulleted and numbered lists</li>
            <li>Hyperlinks</li>
            <li>Cross-browser support</li>
            <li>Identical HTML output across browsers</li>
        </ul>
    `;

    public valueChange(value: any): void {
        this.log('valueChange', value);
    }

    private log(event: string, arg: any): void {
        this.events.push(`${event} ${arg || ''}`);
    }
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { EditorModule } from '@progress/kendo-angular-editor';

import { AppComponent } from './app.component';
import { EventLogComponent } from './event-log.component';

@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    EditorModule
  ],
  declarations: [
    AppComponent,
    EventLogComponent
  ],
  bootstrap: [
    AppComponent
  ]
})
export class AppModule { }
import { Component, Input } from '@angular/core';

@Component({
  selector: 'event-log',
  template: `
    <div class="example-config">
      <h5>{{ title }}</h5>
      <ul class="event-log">
        <li *ngFor="let event of events.reverse()">{{ event }}</li>
      </ul>
    </div>
  `
})
export class EventLogComponent {
  @Input() public title: string;
  @Input() public events: string[];
}
import { AppModule } from './app.module';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);

In this article