Class RadzenHtmlEditor
A component which edits HTML content. Provides built-in upload capabilities.
public class RadzenHtmlEditor : FormComponent<string>, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenFormComponent
- Inheritance
-
RadzenHtmlEditor
- Implements
- Inherited Members
Examples
<RadzenHtmlEditor @bind-Value=@html />
@code {
string html = "@lt;strong>Hello</strong> world!";
}
Constructors
RadzenHtmlEditor()
public RadzenHtmlEditor()
Properties
ChildContent
Gets or sets the child content.
[Parameter]
public RenderFragment ChildContent { get; set; }
Property Value
- RenderFragment
The child content.
Execute
A callback that will be invoked when the user executes a command of the editor (e.g. by clicking one of the tools).
[Parameter]
public EventCallback<HtmlEditorExecuteEventArgs> Execute { get; set; }
Property Value
Examples
<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());
}
}
Input
Gets or sets the input.
[Parameter]
public EventCallback<string> Input { get; set; }
Property Value
- EventCallback<string>
The input.
Mode
Gets or sets the mode of the editor.
[Parameter]
public HtmlEditorMode Mode { get; set; }
Property Value
Paste
A callback that will be invoked when the user pastes content in the editor. Commonly used to filter unwanted HTML.
[Parameter]
public EventCallback<HtmlEditorPasteEventArgs> Paste { get; set; }
Property Value
Examples
<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>", "");
}
ShowToolbar
Specifies whether to show the toolbar. Set it to false to hide the toolbar. Default value is true.
[Parameter]
public bool ShowToolbar { get; set; }
Property Value
UploadError
A callback that will be invoked when there is an error during upload.
[Parameter]
public EventCallback<UploadErrorEventArgs> UploadError { get; set; }
Property Value
UploadHeaders
Specifies custom headers that will be submit during uploads.
[Parameter]
public IDictionary<string, string> UploadHeaders { get; set; }
Property Value
UploadUrl
Specifies the URL to which RadzenHtmlEditor will submit files.
[Parameter]
public string UploadUrl { get; set; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
Dispose()
public override void Dispose()
ExecuteCommandAsync(string, string)
Executes the requested command with the provided value. Check HtmlEditorCommands for the list of supported commands.
public Task ExecuteCommandAsync(string name, string value = null)
Parameters
Returns
ExecuteShortcutAsync(string)
Executes the action associated with the specified shortcut. Used internally by RadzenHtmlEditor.
[JSInvokable("ExecuteShortcutAsync")]
public Task ExecuteShortcutAsync(string shortcut)
Parameters
shortcut
string
Returns
FocusAsync()
Focuses the editor.
public override ValueTask FocusAsync()
Returns
GetComponentCssClass()
protected override string GetComponentCssClass()
Returns
GetHeaders()
Invoked by interop during uploads. Provides the custom headers.
[JSInvokable("GetHeaders")]
public IDictionary<string, string> GetHeaders()
Returns
GetMode()
Returns the current mode of the editor.
public HtmlEditorMode GetMode()
Returns
OnAfterRenderAsync(bool)
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRender
bool
Returns
OnChange(string)
Invoked via interop when the value of RadzenHtmlEditor changes.
[JSInvokable]
public void OnChange(string html)
Parameters
html
stringThe HTML.
OnError(string)
Called on upload error.
[JSInvokable("OnError")]
public Task OnError(string error)
Parameters
error
stringThe error.
Returns
OnInitialized()
protected override void OnInitialized()
OnPaste(string)
Invoked via interop when the user pastes content in RadzenHtmlEditor. Invokes Paste.
[JSInvokable]
public Task<string> OnPaste(string html)
Parameters
html
stringThe HTML.
Returns
OnSelectionChange()
Invoked by interop when the RadzenHtmlEditor selection changes.
[JSInvokable]
public Task OnSelectionChange()
Returns
RegisterShortcut(string, Func<Task>)
Registers a shortcut for the specified action.
public void RegisterShortcut(string key, Func<Task> action)
Parameters
key
stringThe shortcut. Can be combination of keys such as
CTRL+B
.action
Func<Task>The action to execute.
RestoreSelectionAsync()
Restores the last saved selection.
public Task RestoreSelectionAsync()
Returns
SaveSelectionAsync()
Saves the current selection. RadzenHtmlEditor will lose its selection when it loses focus. Use this method to persist the current selection.
public Task SaveSelectionAsync()
Returns
SetParametersAsync(ParameterView)
public override Task SetParametersAsync(ParameterView parameters)
Parameters
parameters
ParameterView
Returns
UnregisterShortcut(string)
Unregisters the specified shortcut.
public void UnregisterShortcut(string key)
Parameters
key
string