How to separate toolbar from rich text editor

How I can separate toolbar from rte?

I need this case





14 Replies

IM Ivan Malakhov September 2, 2021 01:55 PM UTC

I saw examples on AngularJS but cannot transfer them onto Blazor



GK Gunasekar Kuppusamy Syncfusion Team September 2, 2021 02:04 PM UTC

Hi Ivan, 
 
Greetings from Syncfusion support, 
 
We have validated your reported query. Yes, you can create the toolbar items in the separate place by hiding the default toolbar rendered and use the ExecuteCommand to perform the actions in Rich Text Editor. We have configured the following in the sample. 
 
  • Two Rich Text Editor with a common toolbar for performing actions.
  • A check box to choose which editor the toolbar options are to be affected. (If enabled, first editor has the instance and the selected toolbar properties will be applied. if disabled, second editor has the instance)
  • Configured some of the Rich Text Editor tools. Can refer the below documentation for the list of ExecuteCommands.
Sample: https://www.syncfusion.com/downloads/support/forum/168531/ze/Blazor_App189913213
 

Output Image:

Can you please check the above sample and let us know if it meets your requirements? 
 
Regards, 
Gunasekar



IM Ivan Malakhov September 2, 2021 03:46 PM UTC

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 },

// ...

};



IM Ivan Malakhov September 2, 2021 04:02 PM UTC

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.



GK Gunasekar Kuppusamy Syncfusion Team September 3, 2021 01:32 PM UTC

Hi Ivan,

Greetings from Syncfusion support.

We have validated your queries.

Query 1: Can I use list items with SfToolbar? I saw it with RichTextEditorToolbarSettings and list items, it was very easy.

SfToolbar is a separate component, and we should use the ToolbarItem tag to render the toolbar items. But we can render the ToolbarItem in the loop.

Refer the below documentation code for render the ToolbarItem with the loop.


Query 2: 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.

We could not use the RichTextEditorToolbarSettings for your requirement. But we can update the toolbar items based on the text selection or focus.

We have created a sample for your reference. In this sample, we have configured the following things.
  • Initially rendered the RichTextEditor's with toolbar and hidden the toolbar by using "height: 0px" style.
  • Configured UpdatedToolbarStatus event in the RichTextEditor, it triggers for every time focusing the text.
  • In UpdatedToolbarStatus  event, we have highlighted the toolbar items based on the text applied format.
Code Snippets:
@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;
    }
}


Please check the solution, and let us know if you have any concerns.

Regards,
Gunasekar


IM Ivan Malakhov September 4, 2021 08:07 AM UTC


How I can use this elements for toolbar



IS Indrajith Srinivasan Syncfusion Team September 6, 2021 12:26 PM UTC

Hi Ivan, 
 
Good day to you, 
 
We are currently checking, the possibilities of this implementation using the separate toolbar for the FontName, FontSize, FontColor and Formats. We will update you with further details, in two business days by (08/09/2021). 
 
Regards, 
Indrajith 



IM Ivan Malakhov replied to Indrajith Srinivasan September 9, 2021 06:50 AM UTC

How I can do it?



VJ Vinitha Jeyakumar Syncfusion Team September 10, 2021 06:20 AM UTC

Hi Ivan, 
 
 
Sorry for the inconvenience caused, 
 
 
Still we are validating the reported query due to its complexity. We will update you the further details on or before 14th September. 
 
Regards, 
Vinitha. 



GK Gunasekar Kuppusamy Syncfusion Team September 14, 2021 05:02 PM UTC

Hi Ivan,

Thanks for the patience.

We have further validated your reported query and we have prepared a sample for your reported requirement. In this sample we have done the following things
  • Rendered the Dropdown Button Components for FontSize, FontName and Formats and rendered ColorPicker Componenet for FontColor inside the ToolbarItem template.
  • Bound ItemSelected and ValueChange events for DropDown Buttons and ColorPicker component.
  • Using that event, we have called ExecuteCommandAsync public method with its corresponding value and command name.
  • Finally, we have updated the toolbar elements status based the performed action and focusing text state.
Samplehttps://www.syncfusion.com/downloads/support/forum/168531/ze/SEPERA~3252789122

Please check the sample and let us know if you have any concerns,

Regards,
Gunasekar



JL jose luis barajas July 14, 2022 12:07 AM UTC

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>



VJ Vinitha Jeyakumar Syncfusion Team July 14, 2022 01:46 PM UTC

Currently, we are validating your reported query. we will update you the further details on or before 18th July 2022.



VJ Vinitha Jeyakumar Syncfusion Team July 25, 2022 04:58 AM UTC

Hi Jose,


We have considered the reported issue "Undo and Redo is not working with Custom Toolbar options in RTE" as a bug from our end and the fix for the issue will be included with our upcoming Vol 2 2022 SP1 release which is expected to be rolled out on 8th August 2022.

Now you can track the status of the reported issue through the below feedback,

Regards,
Vinitha





VJ Vinitha Jeyakumar Syncfusion Team August 1, 2022 11:02 AM UTC

Hi Jose,


On further analyzing the reported issue, we found that this use case can be resolved by setting the third argument for the ExecuteCommandAsync public method to enable the undo-redo,

 

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);
           
        }



Regards,
Vinitha

Loader.
Up arrow icon