Class RichTextEditorIFrameSettings
A class used for configuring the IFrame rendering properties in the SfRichTextEditor. This ensures that the editor's content is comfortably isolated within an iframe.
Inheritance
Inherited Members
Namespace: Syncfusion.Blazor.RichTextEditor
Assembly: Syncfusion.Blazor.dll
Syntax
public class RichTextEditorIFrameSettings : SfOwningComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Constructors
RichTextEditorIFrameSettings()
Declaration
public RichTextEditorIFrameSettings()
Properties
Attributes
Gets or sets a collection of additional attributes to be added in the iframe element for customization.
Declaration
[Parameter]
public Dictionary<string, object>? Attributes { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, object> | A Dictionary<TKey, TValue> containing key-value pairs for iframe attributes. |
Examples
In the below code example, enable the iframe spellcheck and autocorrect attributes.
@using Syncfusion.Blazor.RichTextEditor;
<SfRichTextEditor>
<RichTextEditorIFrameSettings Enable="true" Attributes="IframeAttributes"/>
</SfRichTextEditor>
@code {
private Dictionary<string, object> IframeAttributes = new Dictionary<string, object>() {
{"spellcheck", "true" },
{"autocorrect", "on"}
}
}
Enable
Gets or sets a value indicating whether the editor content will be rendered in an iframe and isolated from the rest of the page.
Declaration
[Parameter]
public bool Enable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
MetaTags
Gets or sets a list of meta tags to be inserted into the iframe's head. This allows customization of the meta tags to mitigate XSS attacks.
Declaration
[Parameter]
public List<MetaTag>? MetaTags { get; set; }
Property Value
| Type | Description |
|---|---|
| List<MetaTag> | A list of MetaTag objects representing the meta tags to be added. The default is an empty list. |
Remarks
These meta tags will be dynamically inserted when the iframe editor loads, allowing for enhanced security and metadata management.
Examples
This example demonstrates how to add meta tags to the Rich Text Editor's iframe.
@using Syncfusion.Blazor.RichTextEditor;
<SfRichTextEditor>
<RichTextEditorIFrameSettings Enable="true" MetaTags="@metaTags" />
</SfRichTextEditor>
@code {
private List<MetaTag> metaTags = new List<MetaTag>()
{
new MetaTag { Name = "description", Content = "This is a description" },
new MetaTag { Name = "keywords", Content = "HTML, CSS, JavaScript" },
new MetaTag { Charset = "UTF-8" },
new MetaTag { HttpEquiv = "Content-Security-Policy", Content = "default-src 'self'" }
};
}
Resources
Gets or sets the resources for injecting the styles and scripts into the iframe element.
Declaration
[Parameter]
public ResourcesModel? Resources { get; set; }
Property Value
| Type | Description |
|---|---|
| ResourcesModel | The ResourcesModel which includes styles and scripts to be added in the iframe. |
Examples
In the following code example, the external style and script files are added in the iframe body element.
@using Syncfusion.Blazor.RichTextEditor;
<SfRichTextEditor>
<RichTextEditorIFrameSettings Enable="true" Resources="NewResources" />
</SfRichTextEditor>
@code {
private ResourcesModel NewResources { get; set; } = new ResourcesModel()
{
Styles = new string[] { "/styles.css" },
Scripts = new string[] { "/script.js" }
};
}
Sandbox
Gets or sets the sandbox values for the Rich Text Editor's iframe. Controls the restrictions applied to the content embedded in the iframe.
Declaration
[Parameter]
public string[]? Sandbox { get; set; }
Property Value
| Type | Description |
|---|---|
| string[] | A string array that configures the sandbox values for the iframe. The default is a string array containing "allow-same-origin". |
Remarks
The Sandbox property configures security restrictions for the iframe content. Setting an empty array applies all restrictions except "allow-same-origin" by default.
Examples
This example demonstrates how to configure the Sandbox for the Rich Text Editor's iframe:
@using Syncfusion.Blazor.RichTextEditor;
<SfRichTextEditor>
<RichTextEditorIFrameSettings Enable="true" Sandbox="@sandbox" />
</SfRichTextEditor>
@code {
private string[] sandbox = new string[] { "allow-scripts", "allow-same-origin" };
}
Methods
Dispose(bool)
Dispose unmanaged resources in the Syncfusion Blazor component.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | Boolean value to dispose the object. |
Overrides
OnInitializedAsync()
Method invoked when the component is ready to start.
Declaration
protected override Task OnInitializedAsync()
Returns
| Type | Description |
|---|---|
| Task | A System.Threading.Tasks.Task representing any asynchronous operation. |
Overrides
OnParametersSetAsync()
Method invoked when the component has received parameters from its parent.
Declaration
protected override Task OnParametersSetAsync()
Returns
| Type | Description |
|---|---|
| Task | A System.Threading.Tasks.Task representing any asynchronous operation. |