Ordered and Unordered Lists customization

Greetings,

I have noticed that for converting existing text in editor to an ordered or unordered list each item (line) must be in separate paragraph <p> in order to work properly. So if I have various lines separated with <br> this conversion will not work and will treat this as a single <li> item. Is there a setting to alter this behavior?  Or could this be done in someway by code? I would really appreciate your help on that one!


3 Replies 1 reply marked as answer

VJ Vinitha Jeyakumar Syncfusion Team June 4, 2024 10:26 AM UTC

Hi Sotiris,
We have tried to understand your requirement by creating a text content within the RichTextEditor with P tag separated by Br tags like below image,
When we apply numbered or bulleted list to the content, the list works properly and we didn't face any issues as you reported.
If this is not your requirement, please share us with more details along with simple sample or text contents and share a video or image illustration for our better understanding.
Regards,
Vinitha



SO Sotiris June 6, 2024 10:36 AM UTC

Hi!

Thanks for your reply! In general, my problem is to clean the text that comes from copying/pasting from a word document. The case I mentioned in my initial post derives from that.

A paste from a word document (see attached pic) of a bulleted list comes to the editor with the following source code (code view):

<p><span>line 1</span></p><div>line 2</div><div>line 3</div><div>line4</div>


After many trials I have found that the most proper solution is to first paste the text, having set the 

RichTextEditorPasteCleanupSettings.PlainText to "true", and then pressing the "Clear Format" button from the toolbar. 

After doing this, the source code becomes:
<p>line 1</p><p>line 2</p><p>line 3</p><p>line 4</p>

Which then can be formatted properly as a bulleted list. 

The above is just one example of many cases I have seen. Almost in all of them, the most clean and "proper" final source code is generated after pasting (with the 
PlainText option) and then performing a  "Clear Format".

So my question is how can I automate that functionality? Is there a way that after a paste is performed to run the "Clear Format" command without having the user do that? I have seen the "
AfterPasteCleanup" event and I guess that's the one I should use but how to invoke from there the  "Clear Format" command? Or is there a better way to achieve this?


Best 


Attachment: Screenshot_20240606_132142_20ffe4c7.zip



VJ Vinitha Jeyakumar Syncfusion Team June 18, 2024 06:34 AM UTC

Hi Sotiris,

You can use the RemoveFormat executeCommand which remove all formatting styles (such as bold, italic, underline, color, superscript, subscript, and more) from the currently selected text to achieve your requirement within the RichTextEditor. Please refer to the documentation below,


Regards,
Vinitha

Marked as answer
Loader.
Up arrow icon