Member-only story
How to Add Rich Text Editor to an Angular App with Localization
Adding a rich text editor to your Angular app is easy since there are libraries to do so already. It supports lots of features like changing fonts, adding or removing underline, adding lists, bolding text, changing default fonts, add pictures, adding placeholders, etc. Almost anything you can think of can be added to an editor. CKEditor is the rich text editor with the most comprehensive options available.
To use CKEditor in our Angular app, we use an Angular version of the editor available at https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/angular.html, available as a Node package. This allows us to bind our input content to our model without writing code to do that ourselves.
We install the package by running:
npm i ng2-ckeditor
Then we include the following in the imports
array of your module:
import { CKEditorModule } from 'ng2-ckeditor';
import { FormsModule } from '@angular/forms';
@NgModule({
// ...
imports: [CKEditorModule, FormsModule],
// ...
})
export class AppModule {}
In index.html
, we add:
<script src="https://cdn.ckeditor.com/4.5.11/full-all/ckeditor.js"></script>
This includes all the plugins for CKEditor.
Then we add the following to our component, we add:
import { Component } from '@angular/core';
@Component({…