I cant Insert <button> to HtmlEditor #1122

Open
opened 2026-01-29 17:49:11 +00:00 by claunia · 0 comments
Owner

Originally created by @sysdevcom on GitHub (Feb 8, 2024).

I am trying to create a custom tool to insert buttons. But no buttons are inserted at all.

<RadzenHtmlEditor @bind-Value=@htmlValue style="height: 600px;" UploadUrl="upload/image" Execute=@OnExecute>
    <RadzenHtmlEditorCustomTool CommandName="InsertButton" Icon="add_box" Title="InsertButton" />
</RadzenHtmlEditor>

@code {
    private async Task OnExecute(HtmlEditorExecuteEventArgs args)
    {
        switch (args.CommandName)
        {
            case "......":
            case "InsertButton":
                await args.Editor.SaveSelectionAsync();
                await DialogService.OpenAsync("select file", ... , null);
                await args.Editor.FocusAsync();
                await args.Editor.RestoreSelectionAsync();
                await args.Editor.ExecuteCommandAsync(HtmlEditorCommands.InsertHtml, $"<button>{file}</button>");
                break;
        }
    }
}
Originally created by @sysdevcom on GitHub (Feb 8, 2024). I am trying to create a custom tool to insert buttons. But no buttons are inserted at all. ``` <RadzenHtmlEditor @bind-Value=@htmlValue style="height: 600px;" UploadUrl="upload/image" Execute=@OnExecute> <RadzenHtmlEditorCustomTool CommandName="InsertButton" Icon="add_box" Title="InsertButton" /> </RadzenHtmlEditor> @code { private async Task OnExecute(HtmlEditorExecuteEventArgs args) { switch (args.CommandName) { case "......": case "InsertButton": await args.Editor.SaveSelectionAsync(); await DialogService.OpenAsync("select file", ... , null); await args.Editor.FocusAsync(); await args.Editor.RestoreSelectionAsync(); await args.Editor.ExecuteCommandAsync(HtmlEditorCommands.InsertHtml, $"<button>{file}</button>"); break; } } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1122