Contents
- Configuring Clear Format
- Using Clear Format
- See Also
Having trouble getting help?
Contact Support
Contact Support
Remove Formatting in the Angular Rich Text Editor Component
24 Jan 20254 minutes to read
The Angular Rich Text Editor component offers a powerful Clear Format
feature to remove any applied formatting from selected text.
This feature is particularly useful when you need to:
- Remove multiple styles at once
- Quickly standardize text formatting
- Prepare text for new styling
Configuring Clear Format
To enable the Clear Format feature in your Rich Text Editor, you need to add it to the toolbar items. Follow these steps:
- Open your component file where you’ve implemented the Rich Text Editor.
- Locate the
toolbarSettings
property in your Rich Text Editor configuration. - Add
'ClearFormat'
to theitems
array withintoolbarSettings
.
Here’s an example of how to configure the Clear Format feature:
@Component({
selector: 'app-root',
template: `<ejs-richtexteditor [toolbarSettings]='tools'></ejs-richtexteditor>`
})
export class AppComponent {
public tools: object = {
items:
[
'Bold', 'Italic', 'Underline', '|', 'Formats', 'Alignments', 'OrderedList', 'UnorderedList', '|', 'CreateLink', 'Image', '|', 'SourceCode', 'ClearFormat',
'|', 'Undo', 'Redo'
]
};
}
Using Clear Format
Once configured, you can use the Clear Format feature as follows:
- Select the text with formatting you want to remove.
- Click the
Clear Format
button in the toolbar. - The selected text will revert to its original, unformatted state.
Using Clear Format
makes it easy to undo styling changes and keep your text looking consistent. Examples and code snippets below show how to use ‘Clear Format’ effectively in the Rich Text Editor.
import { Component } from '@angular/core';
import { RichTextEditorModule, ToolbarSettingsModel, ToolbarService, HtmlEditorService, QuickToolbarService, LinkService, ImageService, TableService, PasteCleanupService } from '@syncfusion/ej2-angular-richtexteditor';
@Component({
imports: [RichTextEditorModule],
standalone: true,
selector: 'app-root',
template: `<ejs-richtexteditor id='editor' [toolbarSettings]='tools' [value]='value'>
</ejs-richtexteditor>`,
providers: [ToolbarService, HtmlEditorService, QuickToolbarService, LinkService, ImageService, TableService, PasteCleanupService]
})
export class AppComponent {
public value: string = "<p>The Rich Text Editor component is WYSIWYG (\"what you see is what you get\") editor that provides the best user experience to create and update the content. Users can format their content using standard toolbar commands.</p><p><b>Key features:</b></p><ul><li><p>Provides <IFRAME> and <DIV> modes</p></li><li><p>Capable of handling markdown editing.</p></li><li><p>Contains a modular library to load the necessary functionality on demand.</p></li><li><p>Provides a fully customizable toolbar.</p></li><li><p>Provides HTML view to edit the source directly for developers.</p></li><li><p>Supports third-party library integration.</p></li><li><p>Allows preview of modified content before saving it.</p></li><li><p>Handles images, hyperlinks, video, hyperlinks, uploads, etc.</p></li><li><p>Contains undo/redo manager.</p></li><li><p>Creates bulleted and numbered lists.</p></li></ul>";
public tools: ToolbarSettingsModel = {
items: ['Bold', 'Italic', 'Underline', 'StrikeThrough', 'SuperScript', 'SubScript', '|',
'FontName', 'FontSize', 'FontColor', 'BackgroundColor', '|',
'LowerCase', 'UpperCase', '|',
'Formats', 'Alignments', 'Blockquote', '|', 'NumberFormatList', 'BulletFormatList', '|',
'Outdent', 'Indent', '|', 'FormatPainter', 'ClearFormat',
'|', 'FullScreen']
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));