Hi, I am new to CodeMirror and its “functional” structure is really confusing.
So far I only managed to setup things using examples.
The problem is that I can’t find any examples of code folding for v6.
I want to automatically fold object with key toFold
on top level of JSON object after some event, let’s say after document change event:
{
"toFold": { /* Everything here should be folded */ },
"foo": 5
"bar": {
"baz": true
}
}
So I setup my editor like this:
const editor = new EditorView({
doc: myInitialJsonString,
parent: myElem,
extensions: [
basicSetup,
json(),
EditorView.updateListener.of(e => {
if (!e.docChanged) return;
editor.dispatch({ /* How to fold? */ });
})
]
});
And I am stuck here…
I think I need to somehow get fold range (for example by using regexp) and dispatch fold effect on that range but I have no idea of how this should look in code.