Easily track & remove content with decorations

Thanks for the response.

Storing data as a RangeSet makes (theoretical) sense. However, even after spending a week steeped in the CodeMirror 6 docs, I constantly find myself struggling with the practical implementation.

For example: You recommend using RangeSet.

  1. There aren’t any direct examples of RangeSet I can find, so…
  2. I go to the RangeSet Docs
  3. Dig through dozen or more methods to even see the ways to create a RangeSet.
  4. It’s still unclear if I should use new RangeSet(), RangeSet.of(), RangeSet.empty, or if I need to use the completely separate RangeSetBuilder.

After all of that, I still have to figure out:

  1. How to integrate that into StateField
  2. How to properly store data in the RangeSet and StateField
  3. How to loop through the RangeSet to update the position with tr.changes.mapPos
  4. How to get that data back and use it to remove a range of the document.

I’m not complaining about having to learn new concepts, but there are so many disparate concepts/types and so few examples that really showcase how these concepts are supposed to work individually or together.

Some of that will come with time and community, but if there are parts of the documentation or codebase I might be missing that help with understanding how to implement or use them, do let me know.

Noting other discussions for reference:

2 Likes