Class RichTextEditorIFrameSettings
A class used for configuring the IFrame rendring properties in the SfRichTextEditor.
Inheritance
Namespace: Syncfusion.Blazor.RichTextEditor
Assembly: Syncfusion.Blazor.dll
Syntax
public class RichTextEditorIFrameSettings : OwningComponentBase
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
public Dictionary<string, object> Attributes { get; set; }
Property Value
Type |
---|
System.Collections.Generic.Dictionary<System.String, System.Object> |
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 the editor content will be render in an iframe and isolated from the rest of the page.
Declaration
public bool Enable { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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
public List<MetaTag> MetaTags { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.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 into the head of the iframe when the iframe editor loads. This can be used to insert various metadata for the iframe content, including Content Security Policy. Each list item creates a meta tag with the defined property values.
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
public ResourcesModel Resources { get; set; }
Property Value
Type | Description |
---|---|
ResourcesModel |
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. Use a string array (e.g., ["allow-scripts", "allow-forms"]) to configure. When specified as an empty array, it applies all restrictions to the iframe except "allow-same-origin". By default, "allow-same-origin" is included in the Rich Text Editor's iframe.
Declaration
public string[] Sandbox { get; set; }
Property Value
Type | Description |
---|---|
System.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 allows you to configure security restrictions for the iframe content. When the Sandbox property is set to an empty array, it applies all restrictions to the iframe except "allow-same-origin". The default value includes "allow-same-origin" for the sandbox property.
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(Boolean)
Dispose unmanaged resources in the Syncfusion Blazor component.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Boolean value to dispose the object. |
OnInitializedAsync()
Method invoked when the component is ready to start.
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing any asynchronous operation. |
OnParametersSetAsync()
Method invoked when the component has received parameters from its parent.
Declaration
protected override Task OnParametersSetAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing any asynchronous operation. |