How to create and manage nested List with NSTextList, NSAttributedString and UI/NSTextView

I am developing a library for RichTextEditor for SwiftUI, and I am facing issues with implementing NSParagraphStyle related features like nested bullet lists and text alignment. I have searched a lot and personally feel that the documentation is not enough on this topic, so here I want to discuss how we can achieve the nested list with UI/NSTextView and natively available NSTextList in NSParagraphStyle.textLists. The problem is I am not able to understand how I can use this text list and how to manage adding list and removing list with my editor

I have seen code that work adding attributes to each string and then merge them, but I don't want that, I want to add/update/remove attributes from selected text and if text is not selected then want to manage typing attributes to keep applied attributes to current position

To use NSTextList, you create a list style and apply it via a NSMutableParagraphStyle to the text range or typing attributes.

For dynamic updates:

For Selected Text: Modify the NSParagraphStyle of the selected range in the NSTextStorage.

For Typing Attributes: Update the typingAttributes of the NSTextView to ensure new text inherits the styles.

Avoid manual string attribute merging by working with the paragraph style directly.