RTE get value on browser refresh

Hello, 
I would like do get the value of the RTE when the browser refresh button is clicked. So far a solution that works is setting SaveInterval to some value (like 1000) and saving the current value. However, this turns out to be very slow when I start adding pictures as Base64. Is there any nice way to get the current value only when I need it? I am using CircuitHandlerService to attach logic on browser refresh but when I get the Value property of the RTE object it is not the current value but the previously saved one.

6 Replies 1 reply marked as answer

RK Revanth Krishnan Syncfusion Team November 2, 2020 10:14 AM UTC

 Hi Ivan, 
 
 
Greetings from Syncfusion support. 
 
 
We have validated your query “Is there any nice way to get the current value only when I need it? I am using CircuitHandlerService to attach logic on browser refresh but when I get the Value property of the RTE object it is not the current value but the previously saved one”. 
 
The Rich Text Editor value can be get using the `Value` API which is a two-way binding property, but not using the Rich Text Editor’s object. The value should be assigned to a variable and the `@bind` should be used to reflect the Rich Text Editor value in the variable as it is a two-way binding property. We have prepared a sample to get the Rich Text Editor value when ever needed, 
 
Code Snippet: 
<SfRichTextEditor @ref="defaultAPIObj" @bind-Value="@RteValue" /> 
 
 
private string RteValue = @"<p>Rich Text Editor is a WYSIWYG editing control which will reduce the effort for users while trying to express their formatting word content as HTML or Markdown format.</p><p><b>API’s:</b></p><ul><li><p>MaxLength - allows to restrict the maximum length to be entered.</p></li><li><p>ReadOnly - allows to change it as non-editable state.</p></li><li><p>Enabled - enable or disable the RTE component.</p></li><li><p>EnableHtmlEncode - Get the encoded string value through value property and source code panel</p></li><li><p>GetValue - get the value of RTE.</p></li></ul>"; 
 
private async Task GetValueClick() 
{ 
    this.Content = this.RteValue; 
    await this.DialogObj.Show(); 
} 
 
 
 
 
Please check the above code snippet, documentation and the sample and let us know if it satisfy your requirement. 
 
Regards, 
Revanth 



KI Krasimir Ivanov November 2, 2020 10:34 AM UTC

Yes, it normally works. However, in the case where I attach to a CircuitHandlerService it doesn't. My code is the following:

This is for the component: 

 
                   
                   
                   
   

 protected override void OnInitialized()
    {
        base.OnInitialized();

        // Subscribe to the event handler

        // this is to save description on browser refresh or close
        (circuitHandler as CircuitHandlerService).CircuitsChanged += HandleCircuitsChanged;

    }

public async Task SaveEditor()
    {
        await this.SaveAsync();
    }

 public void HandleCircuitsChanged(object sender, EventArgs args)
    {
        this.InvokeAsync(async () => await SaveEditor());
    }

This is for CircuitHandlerService.cs :

 public class CircuitHandlerService : CircuitHandler
    {
        public event EventHandler CircuitsChanged;

        protected virtual void OnCircuitsChanged()
             => CircuitsChanged?.Invoke(this, EventArgs.Empty);

        public CircuitHandlerService()
        {
        }

        public override Task OnCircuitClosedAsync(Circuit circuit,
                  CancellationToken cancellationToken)
        {
            this.OnCircuitsChanged();
            return base.OnCircuitClosedAsync(circuit,
                              cancellationToken);
        }
    }

When I access the Description property in SaveAsync its value is the previous value that was stored in Description.




RK Revanth Krishnan Syncfusion Team November 3, 2020 02:03 PM UTC

Hi Ivan, 
 
Good day to you.   
  
Currently, we are checking with the shared code snippet. We will update you with further details within two business days on or before November 5th 2020.  
  
We appreciate your patience until then.  
     
Regards, 
Revanth 



IS Indrajith Srinivasan Syncfusion Team November 6, 2020 01:02 PM UTC

Hi Ivan, 
 
Good day to you, 
 
By default, Rich Text Editor value will be updated by a minimal timeout(10000). Can you try setting, the SaveInterval property as 1 for the editor to update the value immediately and try using your CircuitHandlerService ? 
 
If you are still facing the reported issue, can you please replicate the reported issue in the already shared sample and revert back to us. So that we can validate and provide solution at earliest. 
 
Regards, 
Indrajith 



KI Krasimir Ivanov November 9, 2020 11:45 PM UTC

If I set SaveInterval to 1 the rte becomes very slow when I upload a couple of base64 files but it works. I wanted to see if there is a faster alternative.


PM Pandiyaraj Muniyandi Syncfusion Team November 10, 2020 11:39 AM UTC

 
Good day to you. 
 
The base64 string image suitable for tiny images, if you’re trying to insert large size base64 string images browser will take some time to process it. So base64 string value update into Rich Text Editor takes some delay. 
 
Note: This is the behaviour of a base64 image in a web browser. 
 
 
If you’re still facing issues with tiny images, kindly share the issue replicate sample to us, which help us to provide the solution at earliest. 
 
Regards, 
Pandiyaraj 


Marked as answer
Loader.
Up arrow icon