Hi,
I am facing an issue while try to "SaveSelection" and "RestoreSelection"
Demo also not saving and restoring cursor location before adding date value.
Here is the edited code below:
<RadzenHtmlEditor @ref="HtmlEditor" style="height: 200px;" Execute=@OnExecute Change=@OnChange>
<RadzenHtmlEditorCustomTool CommandName="InsertToday" Icon="today" Title="Insert today" />
</RadzenHtmlEditor>
@code {
public RadzenHtmlEditor HtmlEditor { get; set; }
async Task OnExecute(HtmlEditorExecuteEventArgs args)
{
await HtmlEditor.RestoreSelectionAsync();
StateHasChanged();
if (args.CommandName == "InsertToday")
{
await InsertDate(args.Editor, DateTime.Now);
}
}
async Task InsertDate(RadzenHtmlEditor editor, DateTime date)
{
await editor.ExecuteCommandAsync(HtmlEditorCommands.InsertHtml, $"<strong>{date.ToLongDateString()}</strong>");
}
async Task OnChange()
{
await HtmlEditor.SaveSelectionAsync();
}
}