I saw examples on AngularJS but cannot transfer them onto Blazor
Can I use list items with SfToolbar? I saw it with RichTextEditorToolbarSettings and list items, it was very easy
private List Tools = new List()
{
new ToolbarItemModel() { Command = ToolbarCommand.Bold },
new ToolbarItemModel() { Command = ToolbarCommand.Italic },
new ToolbarItemModel() { Command = ToolbarCommand.Underline },
// ...
};
I would like to use the RichTextEditorToolbarSettings panel as it takes fewer lines of code and is more informative. Also, when working, text selection is used and this is displayed on the panel itself. For example, if we hover over the bold text, then in the panel it will be displayed that it is selected.
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.RichTextEditor
@using Syncfusion.Blazor.Buttons
<SfToolbar>
<ToolbarEvents Clicked="OnClicked"></ToolbarEvents>
<ToolbarItems>
<ToolbarItem CssClass="@boldCss" PrefixIcon="e-icons e-bold" TooltipText="Bold"></ToolbarItem>
<ToolbarItem CssClass="@italicCss" PrefixIcon="e-icons e-italic" TooltipText="Italic"></ToolbarItem>
<ToolbarItem CssClass="@underlineCss" PrefixIcon="e-icons e-underline" TooltipText="Underline"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyLeft" TooltipText="JustifyLeft"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyRight" TooltipText="JustifyRight"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyFull" TooltipText="JustifyFull"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyCenter" TooltipText="JustifyCenter"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-super-script" TooltipText="Superscript"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-sub-script" TooltipText="Subscript"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-redo" TooltipText="Redo"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-undo" TooltipText="Undo"></ToolbarItem>
</ToolbarItems>
</SfToolbar>
<br />
<SfCheckBox @bind-Checked="@isChecked" TChecked="bool" ValueChange="@OnChange"></SfCheckBox> <br />
<p>Field 1</p>
<SfRichTextEditor @ref="rteInstance1">
<p>
The Rich Text Editor component is a WYSIWYG ("what you see is what you get") editor that provides the best user experience to create and update the content.
Users can format their content using standard toolbar commands.
</p> <RichTextEditorToolbarSettings Enable="true" />
<RichTextEditorEvents UpdatedToolbarStatus="OnUpdate" ></RichTextEditorEvents>
</SfRichTextEditor>
<br />
<p>Field 2</p>
<SfRichTextEditor @ref="rteInstance2">
<p>
The Rich Text Editor component is a WYSIWYG ("what you see is what you get") editor that provides the best user experience to create and update the content.
Users can format their content using standard toolbar commands.
</p>
<RichTextEditorToolbarSettings Enable="true" />
<RichTextEditorEvents UpdatedToolbarStatus="OnUpdate"></RichTextEditorEvents> </SfRichTextEditor>@code {
SfRichTextEditor rteInstance1;
SfRichTextEditor rteInstance2; private string boldCss { get; set; }
private string italicCss { get; set; }
private string underlineCss { get; set; } private bool isChecked = true; private void OnChange(Syncfusion.Blazor.Buttons.ChangeEventArgs<bool> args)
{
boldCss = italicCss = underlineCss = string.Empty;
} private async Task OnClicked(ClickEventArgs args)
{
var currentEditor = isChecked ? rteInstance1 : rteInstance2;
var command = (CommandName)System.Enum.Parse(typeof(CommandName), args.Item.TooltipText);
await currentEditor.ExecuteCommandAsync(command);
boldCss = underlineCss = italicCss = string.Empty;
switch (args.Item.TooltipText)
{ case "Bold":
boldCss = "highlight";
break;
case "Italic":
italicCss = "highlight";
break;
case "Underline":
underlineCss = "highlight";
break;
}
} private void OnUpdate(ToolbarStatusEventArgs args)
{
boldCss = args.Html.Bold ? "highlight" : string.Empty ;
italicCss = args.Html.Italic ? "highlight" : string.Empty;
underlineCss = args.Html.Underline ? "highlight" : string.Empty;
}
} |
How I can use this elements for toolbar
Hi
Need your help
Checking your sample
https://www.syncfusion.com/downloads/support/forum/168531/ze/SEPERA~3252789122
Commands undo and redo not works, also I need to implement all icons using separate toolbar, can you h
<SfToolbar>
<ToolbarEvents Clicked="OnClickedToolbar"></ToolbarEvents>
<ToolbarItems>
<ToolbarItem PrefixIcon="e-icons e-bold" TooltipText="Bold"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-italic" TooltipText="Italic"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-underline" TooltipText="Underline"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-strikethrough" TooltipText="StrikeThrough"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-font-name" TooltipText="FontName"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-font-size" TooltipText="FontSize"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-font-color" TooltipText="FontColor"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-backgroundcolor" TooltipText="BackgroundColor"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-separator" TooltipText="Separator"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-formats" TooltipText="Formats"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-alignments" TooltipText="Alignments"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-lowercase" TooltipText="LowerCase"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-uppercase" TooltipText="UpperCase"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-ordered-list" TooltipText="OrderedList"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-under-list" TooltipText="UnorderedList"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-outdent" TooltipText="Outdent"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-indent" TooltipText="Indent"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-create-link" TooltipText="CreateLink"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-image" TooltipText="InsertImage"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-create-table" TooltipText="CreateTable"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-print" TooltipText="Print"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-source-code" TooltipText="SourceCode"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyLeft" TooltipText="JustifyLeft"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyRight" TooltipText="JustifyRight"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyFull" TooltipText="JustifyFull"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-justifyCenter" TooltipText="JustifyCenter"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-super-script" TooltipText="Superscript"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-sub-script" TooltipText="Subscript"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-redo" TooltipText="Redo"></ToolbarItem>
<ToolbarItem PrefixIcon="e-icons e-undo" TooltipText="Undo"></ToolbarItem>
</ToolbarItems>
</SfToolbar>
Currently, we are validating your reported query. we will update you the further details on or before 18th July 2022.
Code Snippet:
public ExecuteCommandOption undoEnable = new ExecuteCommandOption { Undo = true }; private async Task OnClicked(Syncfusion.Blazor.Navigations.ClickEventArgs args) { currentEditor = isChecked ? rteInstance1 : rteInstance2; await currentEditor.SaveSelectionAsync(); var command = (CommandName)System.Enum.Parse(typeof(CommandName), args.Item.TooltipText); if (command != CommandName.FormatBlock && command != CommandName.FontColor && command != CommandName.FontSize && command != CommandName.FontName && command != CommandName.Undo && command != CommandName.Redo) { await currentEditor.RestoreSelection(); await currentEditor.ExecuteCommandAsync(command, string.Empty, undoEnable); } else if(command == CommandName.Undo || command == CommandName.Redo) { await currentEditor.RestoreSelection(); await currentEditor.ExecuteCommandAsync(command); |