- Configuring the Iframe Editor
- Customizing IFrame Attributes
- Integrating External CSS and Scripts
- See also
Contact Support
IFrame Editing Mode in Angular Rich Text Editor Component
24 Jan 20255 minutes to read
The iframe editor in the Rich Text Editor component provides an isolated environment for content editing. It uses an iframe element to create a separate document, ensuring better compatibility and separation from the parent page’s styles and scripts. In this mode, the editor displays only the body tag of the iframe, offering a clean and isolated workspace for content creation.
Configuring the Iframe Editor
To enable the iframe editor, you can use the iframeSettings property. When this option is enabled, the Rich Text Editor creates an iframe element as the content area during initialization.
Here’s an example of how to enable the iframe editor:
import { RichTextEditorAllModule } from '@syncfusion/ej2-angular-richtexteditor'
import { ToolbarService, LinkService, ImageService, HtmlEditorService,IFrameSettingsModel} from '@syncfusion/ej2-angular-richtexteditor';
@Component({
imports: [RichTextEditorAllModule],
standalone: true,
selector: 'app-root',
template: `<ejs-richtexteditor id='iframeRTE' [iframeSettings]='iframe'></ejs-richtexteditor>`,
providers: [ToolbarService, LinkService, ImageService, HtmlEditorService]
})
export class AppComponent {
public iframe: IFrameSettingsModel = { enable: true };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Customizing IFrame Attributes
You can add custom attributes to the body tag of the iframe using the attributes field of the iframeSettings
property. This property accepts name/value pairs in string format, enabling you to override the default appearance of the content area.
import { RichTextEditorAllModule } from '@syncfusion/ej2-angular-richtexteditor'
import { Component } from '@angular/core';
import { ToolbarService, LinkService, ImageService, HtmlEditorService,IFrameSettingsModel } from '@syncfusion/ej2-angular-richtexteditor';
@Component({
imports: [RichTextEditorAllModule],
standalone: true,
selector: 'app-root',
template: `<ejs-richtexteditor id='iframeRTE' [iframeSettings]='iframe'></ejs-richtexteditor>`,
providers: [ToolbarService, LinkService, ImageService, HtmlEditorService]
})
export class AppComponent {
public iframe: IFrameSettingsModel = {
enable: true,
attributes: {readonly: 'readonly'}
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Integrating External CSS and Scripts
The Rich Text Editor allows you to apply an external CSS file to style the iframe element. This can be done using the styles
field in the iframeSettings property. By including an external CSS file, you can easily change the appearance of the editor’s content to meet your specific requirements.
Likewise, add the external script file to the < iframe >
element using the scripts
field of iframeSettings to provide the additional functionalities to the RichTextEditor.
import { RichTextEditorAllModule } from '@syncfusion/ej2-angular-richtexteditor'
import { Component } from '@angular/core';
import { ToolbarService, LinkService, ImageService, HtmlEditorService, IFrameSettingsModel } from '@syncfusion/ej2-angular-richtexteditor';
@Component({
imports: [RichTextEditorAllModule],
standalone: true,
selector: 'app-root',
template: `<ejs-richtexteditor id='iframeRTE' [iframeSettings]='iframe'></ejs-richtexteditor>`,
providers: [ToolbarService, LinkService, ImageService, HtmlEditorService]
})
export class AppComponent {
public iframe: IFrameSettingsModel = {
enable: true,
attributes: {readonly: 'readonly'},
resources: {
scripts: [''], // script.js
styles: [''] // css
}
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
You can also explore our iframe in Angular Rich Text Editor example that shows how to render the iframe in Angular Rich Text Editor.