Quill.js, a modern rich text editor built for the web, has gained significant traction due to its versatility, ease of use, and seamless integration with modern web applications. One of its popular variations, Ngx Quill, brings the power of Quill.js to Angular applications. If you're working with Ngx Quill and looking for examples to enhance your project, you've come to the right place.

In this comprehensive guide, we'll explore two main topics: integration and customization. We'll delve into each topic, providing detailed examples and step-by-step instructions to help you harness the full potential of Ngx Quill in your Angular projects.

Integration
Before diving into customization, let's first ensure Ngx Quill is integrated perfectly into your Angular application.

To start, install Ngx Quill using npm:
```bash npm install --save ngx-quill ```
Basic Integration

After installation, import `QuillModule` in your `app.module.ts` and add it to the `imports` array:
```typescript import { QuillModule } from 'ngx-quill'; @NgModule({ imports: [ QuillModule.forRoot({ modules: { syntax: true, toolbar: [ ['bold', 'italic', 'underline', 'strike'], // styling ['link', 'image'], // basic text formatting ['clean'], // remove formatting ], }, }), // other imports ], // ... }) export class AppModule { } ```
Next, use the `quill` directive in your template:
```html
Integrating with FormsModule

To use Ngx Quill with Angular's `FormsModule`, import `FormsModule` in your `app.module.ts` and update the `QuillModule` configuration:
```typescript import { FormsModule, ReactiveFormsModule } from '@angular/forms'; @NgModule({ imports: [ QuillModule.forRoot({ modules: { ... // previous configuration }, toolbarComponent: CustomToolbarComponent, // optional }), FormsModule, ReactiveFormsModule, // other imports ], // ... }) export class AppModule { } ```
Now, you can use Ngx Quill in your forms:
```html
```Customization

Ngx Quill offers extensive customization options to tailor the rich text editor according to your project's requirements.
Let's explore two sub-topics: customizing toolbar and adding custom modules.









Customizing Toolbar
You can create a custom toolbar component to extend the default toolbar functionality. First, create a new component `custom-toolbar.component.ts`:
```typescript import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-custom-toolbar', templateUrl: './custom-toolbar.component.html', styleUrls: ['./custom-toolbar.component.css'] }) export class CustomToolbarComponent implements OnInit { modules = { syntax: true, toolbar: [ ['bold', 'italic', 'underline', 'strike'], ['link', 'image'], ['clean'], '|', // separator 'my-custom-button', // custom module ], }; constructor() { } ngOnInit(): void { } } ```
In the template, add your custom button:
```html ```
Don't forget to update your `QuillModule` configuration:
```typescript QuillModule.forRoot({ toolbarComponent: CustomToolbarComponent, // other configuration }); ```
Adding Custom Modules
Create a new directive `custom-module.directive.ts` to extend Quill's functionality:
```typescript import { Directive } from '@angular/core'; import { Quill } from 'quill'; @Directive({ selector: '[quill-module]' }) export class CustomModuleDirective { @Input() quillModule: string; constructor(private quill: Quill) { } ngOnInit(): void { if (this.quillModule === 'my-custom-module') { this.quill.register('modules/myCustomModule', () => { return { name: 'myCustomModule', icon: '', key: 'ctrl+ shifts+ m', handleClick: () => { // your custom functionality here }, }; }); } } } ```
Finally, update your `app.module.ts` to include the custom directive:
```typescript import { CustomModuleDirective } from './custom-module.directive'; @NgModule({ declarations: [ CustomModuleDirective, // other declarations ], // ... }) export class AppModule { } ```
Now you're ready to use your custom module in the toolbar:
```html
The world of Ngx Quill is vast and full of possibilities. From basic integration to advanced customization, this guide has provided you with a solid foundation to build upon. Happy coding, and may your rich text editor dreams come true!