Rich Text Editor Custom Control is always "selected"
|
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.RichTextEditor
<SfRichTextEditor>
<RichTextEditorToolbarSettings Items="@Tools">
<RichTextEditorCustomToolbarItems>
<RichTextEditorCustomToolbarItem Name="Symbol">
<Template>
<SfButton @onclick="ClickHandler" CssClass="rte_custom_tool" ></SfButton>
</Template>
</RichTextEditorCustomToolbarItem>
</RichTextEditorCustomToolbarItems>
</RichTextEditorToolbarSettings>
</SfRichTextEditor>
<style>
.rte_custom_tool {
background-color: #f8f9fa;
color: #212529;
border-color: transparent;
}
</style>
@code {
private List<ToolbarItemModel> Tools = new List<ToolbarItemModel>()
{
new ToolbarItemModel() { Command = ToolbarCommand.Bold },
new ToolbarItemModel() { Command = ToolbarCommand.Italic },
new ToolbarItemModel() { Command = ToolbarCommand.Underline },
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
new ToolbarItemModel() { Name = "Symbol", TooltipText = "Insert Symbol" },
new ToolbarItemModel() { Command = ToolbarCommand.SourceCode },
new ToolbarItemModel() { Command = ToolbarCommand.FullScreen }
};
private void ClickHandler()
{
//Perform your action here
}
}
|
Welcome, Please get back to us if you need any further assistance.
Regards,
Indrajith
Any idea why I am getting this error using custome toolbar item?
<RichTextEditorToolbarSettings Items="@Tools" />
<RichTextEditorQuickToolbarSettings Table="@TableToolbar" Image="@ImageToolbar" Link="@LinkToolbar" Audio="AudioToolbar" Video="VideoToolbar" />
<RichTextEditorCustomToolbarItems>
<RichTextEditorCustomToolbarItem Name="RemoveFormatting" >
<Template>
<SfButton @onclick="RemoveFormattingClick"><i class="fa fa-eraser" aria-hidden="true"></i></SfButton>
</Template>
</RichTextEditorCustomToolbarItem>
</RichTextEditorCustomToolbarItems>
new ToolbarItemModel() { Name = "RemoveFormatting", TooltipText = "Remove All HTML code" },System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Blazor.RichTextEditor.RichTextEditorCustomToolbarItems.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
Hi Joseph,
We have analyzed the shared codes, and we could see that you missed adding the closing tag of the RichTextEditorToolbarSettings component, which caused the reported problem. So, we suggest you ensure to add the below highlighted code to overcome the reported problem.
<SfRichTextEditor> <RichTextEditorQuickToolbarSettings Table="@TableQuickToolbarItems" Image="@ImageToolbar" Link="@Link" Audio="AudioQuickToolbarItems" Video="VideoQuickToolbarItems" /> <RichTextEditorToolbarSettings Items="@Tools"> <RichTextEditorCustomToolbarItems> <RichTextEditorCustomToolbarItem Name="RemoveFormatting"> <Template> <SfButton @onclick="RemoveFormattingClick"><i class="fa fa-eraser" aria-hidden="true"></i></SfButton> </Template> </RichTextEditorCustomToolbarItem> </RichTextEditorCustomToolbarItems> </RichTextEditorToolbarSettings> </SfRichTextEditor> |
We have attached a sample for your reference.
Regards,
Vinothkumar
Attachment: BlazorApp1_ae4c4538.zip
- 5 Replies
- 4 Participants
- Marked answer
-
JT Joseph Tan
- Oct 30, 2020 03:29 AM UTC
- Jun 29, 2023 08:52 AM UTC