Rich Text Editor is not updating the bound variable

I'm binding a string variable, NoteBody, to the editor as such:

            <SfRichTextEditor @ref="RTFeditor" @bind-Value=NoteBody EnableXhtml=true>

                <RichTextEditorToolbarSettings Items="@Tools">

                    <RichTextEditorCustomToolbarItems>

                        <RichTextEditorCustomToolbarItem Name="Save">

                            <Template>

                                <button class="e-btn e-tbar-btn" @onclick="onSaveClick">

                                    <div class="e-tbar-btn-text" style="font-weight: 500;">💾</div>

                                </button>

                            </Template>

                        </RichTextEditorCustomToolbarItem>

                    </RichTextEditorCustomToolbarItems>

                </RichTextEditorToolbarSettings>

            </SfRichTextEditor>

- On a newly loaded page, NoteBody contains the typed editor text on save (via the onSaveClick handler)

- On a page where NoteBody has been assigned from a previously saved note, it displays in the editor but additional changes are *not* updating NoteBody on save 

- When NoteBody is assigned from a previously saved note and then Ctrl-A is used to select all text, then Delete key pressed to delete it, newly entered text DOES update NoteBody on save.


Help?


5 Replies

VJ Vinitha Jeyakumar Syncfusion Team January 26, 2022 10:49 AM UTC

Hi Philip,


On validating your reported query, we suspect that your requirement is to save the previously added text value to the Rich Text Editor's text content. To achieve your requirement, you can use our EnablePersistance property which persists the value of Rich Text Editor.

please check the code below,

Code snippet:
<SfRichTextEditor EnablePersistence="true" >
        
 </SfRichTextEditor>


If still issue persists at your end, please get back to us with the runnable issue reproducing sample.

Regards,
Vinitha




PH Philip January 26, 2022 08:13 PM UTC

That doesn't fix the issue. The problem is that the RTF control shows what I set in the NoteBody variable, it shows additional typed text after that, but when processing the save, the newly typed text isn't part of what's set in NoteBody. It's clearly a bug that the control itself shows all of the text, old+newly added/edited text, but doesn't set what it shows into the bound variable.



BS Buvana Sathasivam Syncfusion Team January 27, 2022 02:16 PM UTC

Hi Philip, 

We have checked your reported query. You can achieve your requirement using the SaveInterval property set as 1. By default, the Rich Text Editor's value changes when the focus is off of the SfRichTichEditor component. If you wish to get the typed text or modified text when you click the button, you can set the SaveInterval property as 1
  
@using Syncfusion.Blazor.Buttons 
@using Syncfusion.Blazor.RichTextEditor 
 
<SfRichTextEditor @ref="RTFeditor" @bind-Value="@NoteBody" EnableXhtml=true SaveInterval=1> 
    <RichTextEditorToolbarSettings Items="@Tools"> 
        <RichTextEditorCustomToolbarItems> 
            <RichTextEditorCustomToolbarItem Name="Symbol"> 
                <Template> 
                     <button class="e-btn e-tbar-btn" @onclick="onSaveClick"> 
 
                                    <div class="e-tbar-btn-text" style="font-weight: 500;">💾</div> 
 
                                </button> 
                </Template> 
            </RichTextEditorCustomToolbarItem> 
        </RichTextEditorCustomToolbarItems> 
    </RichTextEditorToolbarSettings> 
</SfRichTextEditor> 
 
@code { 
    SfRichTextEditor RTFeditor; 
    public string NoteBody = "Rich Text Editor"; 
 
    private void onSaveClick() 
    { 
        Console.WriteLine(RTFeditor.Value); 
        Console.WriteLine(NoteBody); 
    } 
} 


Please let us know if you have any further assistance. 

Regards, 
Buvana S 



PH Philip January 27, 2022 11:25 PM UTC

Thanks, hopefully that works.



BS Buvana Sathasivam Syncfusion Team January 28, 2022 06:42 AM UTC

Hi Philip, 

Thank you for your update. Please get back to us if you need any further assistance. 

Regards, 
Buvana S 


Loader.
Up arrow icon