Html containing new line \n is rendered in SfRichTextEditor


I have an html with several new line characters (\n).

Ideally Html viewer/editor shouldn't render \n since it is not an html tag like <br/>, <div/>

How can I tell SfRichTextEditor not to render \n.

Thanks.

3 Replies 1 reply marked as answer

GR Gayathri Ramalingam Syncfusion Team June 3, 2021 07:29 AM UTC

Hi Gautam, 
 
Thank you for using Syncfusion products. 
 
On analyzing your requirement, we found that you have to remove the ‘\n’ character from input text. Please use the below code example to get this issue resolved.   
string text = "The rich text editor \n component is WYSIWYG editor that provides the best user experience to create and update the content"; 
          
richtexteditor.Text = text.Replace("\n", ""); 
        
 
We have prepared sample based on your requirement and it can be downloaded from below link, 
 
Could you please try the above suggested solution and let us know whether it meets your requirement or not?   
 
With Regards, 
Gayathri R 


Marked as answer

GJ Gautam Jain June 3, 2021 08:11 AM UTC

Thanks Gayathri,

This is what I did already and it seems to be working fine.

However, this is what is expected from an html renderer. Is it? Am I missing something? It seems to be a bug and what you have given a workaround.

Thanks for quick support and wish you the best!


GR Gayathri Ramalingam Syncfusion Team June 4, 2021 09:55 AM UTC

Hi Gautam, 
 
Thank you for your update 
 
On further analyzation, C# consider ‘\n’ as a new line character. Based on that we have implemented the same in our SfRichTextEditor and new line added if the given input string contains ‘\n’. However, you can remove the character as we suggested in previous update. Please use the below code example to get this issue resolved.   
 
string text = "The rich text editor \n component is WYSIWYG editor that provides the best user experience to create and update the content";         
richtexteditor.Text = text.Replace("\n""");         
  
Please let us know if any further assistance required. 
 
With Regards, 
Gayathri R  
 


Loader.
Up arrow icon