CM6 - How do I get content between 2 positions?

I am reading the documentation but couldn’t figure this out yet. I suspect I can do this using @codemirror/text but not sure how. Any one have pointers to how to use @codemirror/text OR the original question - how do I get content between 2 positions?

The easiest way is state.sliceDoc, which will automatically use the editor state’s line separator (@codemirror/text is oblivious to line separators).

1 Like

Thank you. That worked. I had figured out using

cm.state.doc.sliceString

but I guess it does not account for line separator.

It looks like for any operation that could span multiple lines, I should avoid using @codemirror/text then.