I’m working with @codemirror/fold right now and I have not found a good way to request for the currently folded regions.
The use case I’m going after is to persist the fold status by line number in hopes of restoring it in a later writing session. This could be done previously on CM5 with getAllMarks() and querying the (undocumented) __isFold property on a Mark object.
So the question is: would it make sense to add some kind of API to get all currently folded regions, or should I be looking into writing a custom fold plugin?
PS. It might also make sense to add an API for querying whether a single line is folded, which could be useful for, say, implementing a toggleFold command.
Ok, in addition to that, I think it may also make sense to have a way to programmatically fold or unfold regions (such as in the case of “loading” a previously persisted folding state), rather than having to set a selection and call foldCode, before restoring the previous selection.
Thank you. The problem is exactly that the state field is not exported, though marijn may know a better/cleaner way to expose the functionality. It would also require to export foldEffect and unfoldEffect for programmatic access to folding specific ranges.