Class RichTextEditorCodeBlockSettings
A class used for configuring the code block settings in the SfRichTextEditor. This allows customization of the available languages and default language for the code block feature inside the editor.
Inheritance
Namespace: Syncfusion.Blazor.RichTextEditor
Assembly: Syncfusion.Blazor.dll
Syntax
public class RichTextEditorCodeBlockSettings : OwningComponentBase
Constructors
RichTextEditorCodeBlockSettings()
Declaration
public RichTextEditorCodeBlockSettings()
Properties
DefaultLanguage
Gets or sets the default programming language for new code blocks in the Rich Text Editor.
Declaration
public string DefaultLanguage { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | A System.String specifying the language identifier (e.g., |
Remarks
This property determines which language will be preselected when adding a new code block. The specified default language should match an entry in the Languages list for optimal user experience.
Examples
This example demonstrates how to set the DefaultLanguage property:
<SfRichTextEditor>
<RichTextEditorCodeBlockSettings DefaultLanguage="python" />
</SfRichTextEditor>
Languages
Gets or sets the list of available programming languages for code blocks in the Rich Text Editor.
Declaration
public List<CodeBlockLanguageModel> Languages { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<CodeBlockLanguageModel> | A System.Collections.Generic.List<> representing the available languages displayed in the code block language selection dropdown. |
Remarks
Each CodeBlockLanguageModel should specify the label (display name) and the language identifier (e.g., "C", "HTML", "typescript").
Examples
This example demonstrates how to configure the Languages property:
<SfRichTextEditor>
<RichTextEditorCodeBlockSettings Languages="@customLanguages" />
</SfRichTextEditor>
@code {
private List<CodeBlockLanguageModel> customLanguages = new List<CodeBlockLanguageModel>
{
new CodeBlockLanguageModel { Label = "C#", Language = "csharp" },
new CodeBlockLanguageModel { Label = "JavaScript", Language = "javascript" },
new CodeBlockLanguageModel { Label = "Python", Language = "python" }
};
}
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 initially initialized.
Declaration
protected override Task OnInitializedAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the 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. |