Custom Code Folding

Does any one have examples of how to set up custom cold folding? The problem I am trying to solve involves formatting a JSON output. I want it so that on display it will default to only folding properties that have a . in their name. I feel like this is something that can be easily implemented I’m just not exactly sure where to look in the docs.

I’m also currently using the uiwjs React CodeMirror component which supports v6.

Do you mean that only some objects can be folded, or to fold all such objects on load (or on a command)?

What I had in mind was having only some objects folded on the initial load. Like the HTML example in this demo where the head and the div was folded initially: CodeMirror: Code Folding Demo

The user should still be able to fold/open whatever they want.

The general approach for that would be to iterate the parse tree scanning for nodes you want to fold (might have to read from the document to figure out property names), collect a bunch of fold effects, and dispatch those.

1 Like

Great, thanks. I’ll look into this.