I had some experience with ProseMirror but I understood it badly. Now I try to understand it better and I’m already getting it (btw TypeScript types help a lot in this). I’d like to try to create own functional around some lists (I tried to see source code of the “prosemirror-schema-list” but I didn’t understand it ).
And this is my case:
My schema has such types:
- The list’s type (“ul” for example)
- The list item (just “li”)
I want to realize method of wrapping the selection to a list type. First of all, I want to understand how to wrap my selected nodes. Right now I don’t think about the behavior when I select already a created list and I don’t think about the “auto joining”. I just want to wrap some text nodes in list.
And I had following thoughts:
- Create “Fragment” and fill it
- Create the instance of list’s type (“ul” for example) and fill it
In both cases I thought about that to get all nodes in the selection by “view.state.doc.nodesBetween” method and check every node, change it and push in my result. After It just replace the selection on my result.
I will be glad if someone pushes me on the right path. I want to know how to think correctly in such cases. @marijn I’ve already taken up a lot of your time but probably this question may only be answered by you. Thanks for ProseMirror!