How can I help you?
Integrate WProofreader into the Angular Rich Text Editor
11 Feb 20263 minutes to read
WProofreader enables real-time spelling, grammar, and style checks inside the Rich Text Editor editable area. The SDK attaches to the editor content element and provides suggestions without changing the editor workflow.
Prerequisites
Before proceeding, complete the base Rich Text Editor setup described in the Getting Started guide. The guide covers Angular CLI setup, package installation, CSS imports, module injection, and basic editor markup: Getting Started with Angular Rich Text Editor.
Key features
- Real-time spelling and grammar suggestions.
- Multilingual support and custom dictionaries.
- Cloud and on-premise deployment options.
Set up the WProofreader sdk
Install the WProofreader SDK package using the following command:
npm install @webspellchecker/wproofreader-sdk-jsNote: Register for a WProofreader cloud service key and keep the
serviceIdready. For self-hosted deployment, prepare the service endpoint settings.
Configure WProofreader for the Rich Text Editor
After installing the package, you can integrate WProofreader with the Angular Rich Text Editor by following these steps:
- Import the
WProofreadermodule into your Angular component. - Configure the
containerproperty of WProofreader to the editable element of the Rich Text Editor component. - Use the
ViewChilddecorator to access the Angular Rich Text Editor instance. - Set the
langproperty to specify the language of the text to be checked. - Configure the activation key in the
serviceIdproperty.
Example: integrate with Syncfusion Rich Text Editor (app.ts)
import { Component, AfterViewInit, ViewChild } from '@angular/core';
import { RichTextEditorComponent } from '@syncfusion/ej2-angular-richtexteditor';
import WProofreaderSDK from '@webspellchecker/wproofreader-sdk-js';
@Component({
selector: 'app-root',
template: `
<ejs-richtexteditor #spellEditor id="editor" [value]="value"></ejs-richtexteditor>
`
})
export class AppComponent implements AfterViewInit, OnDestroy {
@ViewChild('spellEditor')
public spellEditor!: RichTextEditorComponent;
public value: string = "<p>Enter you\'re text here with real spelling and grammer mistakes to see how WProofreader work. Alot of potential errors will be underlined; hover on the marked wods for instant correction suggesstions.</p>";
ngAfterViewInit(): void {
WProofreader.init({
container: this.spellEditor.inputElement,
lang: 'en_US',
serviceId: 'YOUR_SERVICE_ID',
});
}
ngOnDestroy(): void {
if (this.wpcInstance && typeof this.wpcInstance.destroy === 'function') {
this.wpcInstance.destroy();
return;
}
}
}Additional resources
- GitHub Repository: Angular Rich Text Editor with Web Spell Checker
- WProofreader SDK: https://www.npmjs.com/package/@webspellchecker/wproofreader-sdk-js