Code editing option in RIchtexteditor

Hi Team,

I have been using the RichTextEditor for my CMS application where I need to mention some code as well but whenever I paste code into the richtexteditor and select insert code option the format of the code gets distorted as shown in the below screenshot.

Screenshot from 2023-11-25 19-33-55.png


Please let me know the solution to beautify the code view in the rich text editor.

Also, when I paste code from VSCode it takes the format of VSCode but when I select the Insert Code option the format gets distorted as well in the RTE.

Although the former content looks good in the HTML label but the later looks bad as well in the HTML label as well as shown in the below screenshot.

Screenshot from 2023-11-25 19-41-38.png

Kindly let me know the solution of the above.


1 Reply

GD Gokulraj Devarajan Syncfusion Team November 28, 2023 02:53 AM UTC

We have validated your query. The reason for the odd styles in the latter content is that the styles are not cleaned before pasting. However, in the former case, only plain text is pasted. We suggest you inject the paste cleanup module and choose to keep or paste as plain text. In the sample below, we have configured it to use the prompt option. Please find the output screenshots below for your reference.

Sample:

https://stackblitz.com/edit/angular-7aqdhw?file=src%2Fapp.component.html

https://ej2.syncfusion.com/angular/documentation/rich-text-editor/paste-cleanup

Plain text:


Keep Format:






Loader.
Up arrow icon