A rich text HTML editor component with WYSIWYG editing, formatting toolbar, image upload, and custom tool support. RadzenHtmlEditor provides a full-featured editor for creating and editing formatted content with a Microsoft Word-like interface. Allows users to create rich formatted content without knowing HTML. Features WYSIWYG (what-you-see-is-what-you-get) visual editing interface, formatting tools (bold, italic, underline, font selection, colors, alignment, lists, links, images), built-in image upload with configurable upload URL, custom toolbar buttons via RadzenHtmlEditorCustomTool, toggle between visual editing and HTML source code view, paste filtering to remove unwanted HTML when pasting from other sources, and programmatic execution of formatting commands via ExecuteCommandAsync(). The Value property contains HTML markup. Use UploadUrl to configure where images are uploaded. Add custom tools for domain-specific functionality like inserting templates or special content.
FormComponent<string>.GetValue
FormComponent<string>.OnContextMenu
FormComponent<string>.GetClassList
FormComponent<string>.TabIndex
FormComponent<string>.Placeholder
FormComponent<string>.Disabled
FormComponent<string>.EditContext
FormComponent<string>.ValueChanged
FormComponent<string>.HasValue
FormComponent<string>.FieldIdentifier
FormComponent<string>.ValueExpression
FormComponent<string>.FormFieldContext
FormComponent<string>.CurrentPlaceholder
RadzenComponent.RaiseContextMenu
RadzenComponent.RaiseMouseEnter
RadzenComponent.AddContextMenu
RadzenComponent.RaiseMouseLeave
RadzenComponent.OnBecameInvisible
RadzenComponent.DefaultCulture
RadzenComponent.IsJSRuntimeAvailable
ComponentBase.OnInitializedAsync
ComponentBase.OnParametersSet
ComponentBase.OnParametersSetAsync
ComponentBase.StateHasChanged
ComponentBase.ShouldRender
ComponentBase.OnAfterRender
ComponentBase.InvokeAsync
ComponentBase.DispatchExceptionAsync
ComponentBase.RendererInfo
ComponentBase.Assets
ComponentBase.AssignedRenderMode
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
public class RadzenHtmlEditor : FormComponent<string>, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormComponentBasic HTML editor:
<RadzenHtmlEditor @bind-Value=@htmlContent Style="height: 400px;" />
@code {
string htmlContent = "<p>Enter content here...</p>";
}
Editor with image upload:
<RadzenHtmlEditor @bind-Value=@content UploadUrl="api/upload/image" UploadHeaders=@uploadHeaders>
<RadzenHtmlEditorBold />
<RadzenHtmlEditorItalic />
<RadzenHtmlEditorUnderline />
<RadzenHtmlEditorSeparator />
<RadzenHtmlEditorImage />
</RadzenHtmlEditor>
Editor with custom tool:
<RadzenHtmlEditor @bind-Value=@html Execute=@OnExecute>
<RadzenHtmlEditorCustomTool CommandName="InsertDate" Icon="calendar_today" Title="Insert Current Date" />
</RadzenHtmlEditor>
@code {
async Task OnExecute(HtmlEditorExecuteEventArgs args)
{
if (args.CommandName == "InsertDate")
{
await args.Editor.ExecuteCommandAsync(HtmlEditorCommands.InsertHtml, DateTime.Today.ToLongDateString());
}
}
}A rich text HTML editor component with WYSIWYG editing, formatting toolbar, image upload, and custom tool support. RadzenHtmlEditor provides a full-featured editor for creating and editing formatted content with a Microsoft Word-like interface. Allows users to create rich formatted content without knowing HTML. Features WYSIWYG (what-you-see-is-what-you-get) visual editing interface, formatting tools (bold, italic, underline, font selection, colors, alignment, lists, links, images), built-in image upload with configurable upload URL, custom toolbar buttons via RadzenHtmlEditorCustomTool, toggle between visual editing and HTML source code view, paste filtering to remove unwanted HTML when pasting from other sources, and programmatic execution of formatting commands via ExecuteCommandAsync(). The Value property contains HTML markup. Use UploadUrl to configure where images are uploaded. Add custom tools for domain-specific functionality like inserting templates or special content.
public RadzenHtmlEditor()Gets or sets the child content.
public RenderFragment ChildContent { get; set; }
| Type | Description |
|---|---|
| RenderFragment | Gets or sets the child content. |
A callback that will be invoked when the user executes a command of the editor (e.g. by clicking one of the tools).
public EventCallback<HtmlEditorExecuteEventArgs> Execute { get; set; }
| Type | Description |
|---|---|
| EventCallback<HtmlEditorExecuteEventArgs> | A callback that will be invoked when the user executes a command of the editor (e.g. by clicking one of the tools). |
<RadzenHtmlEditor Execute=@OnExecute>
<RadzenHtmlEditorCustomTool CommandName="InsertToday" Icon="today" Title="Insert today" />
</RadzenHtmlEditor>
@code {
string html = "@lt;strong>Hello</strong> world!";
async Task OnExecute(HtmlEditorExecuteEventArgs args)
{
if (args.CommandName == "InsertToday")
{
await args.Editor.ExecuteCommandAsync(HtmlEditorCommands.InsertHtml, DateTime.Today.ToLongDateString());
}
}Gets or sets a value indicating whether the source editor should update the value on every keystroke. When true, typing in the HTML source textarea invokes change immediately instead of on blur. Set to false by default.
public bool Immediate { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets a value indicating whether the source editor should update the value on every keystroke. When true, typing in the HTML source textarea invokes change immediately instead of on blur. Set to false by default. |
Gets or sets the input.
public EventCallback<string> Input { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Gets or sets the input. |
Gets or sets the editor mode determining whether users see the visual editor or HTML source code. Design mode shows WYSIWYG editing, Source mode shows raw HTML for advanced users.
public HtmlEditorMode Mode { get; set; }
| Type | Description |
|---|---|
| HtmlEditorMode | Gets or sets the editor mode determining whether users see the visual editor or HTML source code. Design mode shows WYSIWYG editing, Source mode shows raw HTML for advanced users. |
A callback that will be invoked when the user pastes content in the editor. Commonly used to filter unwanted HTML.
public EventCallback<HtmlEditorPasteEventArgs> Paste { get; set; }
| Type | Description |
|---|---|
| EventCallback<HtmlEditorPasteEventArgs> | A callback that will be invoked when the user pastes content in the editor. Commonly used to filter unwanted HTML. |
<RadzenHtmlEditor @bind-Value=@html Paste=@OnPaste />
@code {
string html = "@lt;strong>Hello</strong> world!";
void OnPaste(HtmlEditorPasteEventArgs args)
{
// Set args.Html to filter unwanted tags.
args.Html = args.Html.Replace("<br>", "");
}Gets or sets whether to display the formatting toolbar above the editor. When false, hides the toolbar but editing is still possible. Useful for read-only or simplified views.
public bool ShowToolbar { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether to display the formatting toolbar above the editor. When false, hides the toolbar but editing is still possible. Useful for read-only or simplified views. |
Represents the current state of the toolbar commands and other functionalities within the RadzenHtmlEditor component. Updated dynamically based on user actions or programmatically invoked commands.
public RadzenHtmlEditorCommandState State { get; set; }
| Type | Description |
|---|---|
| RadzenHtmlEditorCommandState | Represents the current state of the toolbar commands and other functionalities within the RadzenHtmlEditor component. Updated dynamically based on user actions or programmatically invoked commands. |
Gets or sets the callback which when a file is uploaded.
public EventCallback<UploadCompleteEventArgs> UploadComplete { get; set; }
| Type | Description |
|---|---|
| EventCallback<UploadCompleteEventArgs> | Gets or sets the callback which when a file is uploaded. |
A callback that will be invoked when there is an error during upload.
public EventCallback<UploadErrorEventArgs> UploadError { get; set; }
| Type | Description |
|---|---|
| EventCallback<UploadErrorEventArgs> | A callback that will be invoked when there is an error during upload. |
Specifies custom headers that will be submit during uploads.
public IDictionary<string, string> UploadHeaders { get; set; }
| Type | Description |
|---|---|
| IDictionary<string, string> | Specifies custom headers that will be submit during uploads. |
Specifies the URL to which RadzenHtmlEditor will submit files.
public string UploadUrl { get; set; }
| Type | Description |
|---|---|
| string | Specifies the URL to which RadzenHtmlEditor will submit files. |
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
| Type | Name | Description |
|---|---|---|
| Rendering.RenderTreeBuilder | __builder |
Executes the requested command with the provided value. Check HtmlEditorCommands for the list of supported commands.
public Task ExecuteCommandAsync(string name, string value)
| Type | Name | Description |
|---|---|---|
| string | name | The name. |
| string | value | The value. |
| Type | Description |
|---|---|
| Task |
Executes the action associated with the specified shortcut. Used internally by RadzenHtmlEditor.
public Task ExecuteShortcutAsync(string shortcut)
| Type | Name | Description |
|---|---|---|
| string | shortcut |
| Type | Description |
|---|---|
| Task |
Focuses the editor.
public override ValueTask FocusAsync()
| Type | Description |
|---|---|
| ValueTask |
protected override string GetComponentCssClass()
| Type | Description |
|---|---|
| string |
Invoked by interop during uploads. Provides the custom headers.
public IDictionary<string, string> GetHeaders()
| Type | Description |
|---|---|
| IDictionary<string, string> |
Returns the current mode of the editor.
public HtmlEditorMode GetMode()
| Type | Description |
|---|---|
| HtmlEditorMode |
Retrieves the specified attributes of a selection within the content editable area.
public ValueTask<T> GetSelectionAttributes(string selector, String[] attributes)
| Type | Name | Description |
|---|---|---|
| string | selector | The CSS selector used to target the element. |
| String[] | attributes | An array of attribute names to retrieve. |
| Type | Description |
|---|---|
| ValueTask<T> | A task that represents the asynchronous operation, returning the attributes as an object of type T. |
protected override Task OnAfterRenderAsync(bool firstRender)
| Type | Name | Description |
|---|---|---|
| bool | firstRender |
| Type | Description |
|---|---|
| Task |
Invoked via interop when the value of RadzenHtmlEditor changes.
public void OnChange(string html)
| Type | Name | Description |
|---|---|---|
| string | html | The HTML. |
Called on upload error.
public Task OnError(string error)
| Type | Name | Description |
|---|---|---|
| string | error | The error. |
| Type | Description |
|---|---|
| Task |
Invoked via interop when the user pastes content in RadzenHtmlEditor. Invokes Paste.
public Task<string> OnPaste(string html)
| Type | Name | Description |
|---|---|---|
| string | html | The HTML. |
| Type | Description |
|---|---|
| Task<string> |
Invoked by interop when the RadzenHtmlEditor selection changes.
public Task OnSelectionChange()
| Type | Description |
|---|---|
| Task |
Invoked by interop when the upload is complete.
public Task OnUploadComplete(string response)
| Type | Name | Description |
|---|---|---|
| string | response |
| Type | Description |
|---|---|
| Task |
Registers a shortcut for the specified action.
public void RegisterShortcut(string key, Func<Task> action)
| Type | Name | Description |
|---|---|---|
| string | key | The shortcut. Can be combination of keys such as CTRL+B. |
| Func<Task> | action | The action to execute. |
Restores the last saved selection.
public Task RestoreSelectionAsync()
| Type | Description |
|---|---|
| Task |
Saves the current selection. RadzenHtmlEditor will lose its selection when it loses focus. Use this method to persist the current selection.
public Task SaveSelectionAsync()
| Type | Description |
|---|---|
| Task |
public override Task SetParametersAsync(ParameterView parameters)
| Type | Name | Description |
|---|---|---|
| ParameterView | parameters |
| Type | Description |
|---|---|
| Task |
Unregisters the specified shortcut.
public void UnregisterShortcut(string key)
| Type | Name | Description |
|---|---|---|
| string | key |