codesandbox / sandpack

A component toolkit for creating live-running code editing experiences, using the power of CodeSandbox.
https://sandpack.codesandbox.io
Apache License 2.0
4.53k stars 311 forks source link

Feature request: Add code folding support on the code-editor component #392

Closed bentleyvk closed 1 year ago

bentleyvk commented 2 years ago

Tell us how you think we can improve Sandpack

Packages affected

What is this feature?

It would be nice to have code folding as Codemirror already supports that https://github.com/codemirror/fold. Also to control what lines are initially folded.

How would your idea work?

There should be an arrow next to line number that folds the code like this: image

Do you have any examples of how you would like to see us implement it?

https://codemirror.net/demo/folding.html

danilowoz commented 2 years ago

I have added your feature request to our internal backlog which we use to prioritize what to build next. We can't make any promises about the timing, but it's on the list!

If you'd like to work on this feature with us, please create a pull request and we'll help you along the way.

For others landing on this issue, feel free to add more context or simply leave a thumbs up 👍 on this comment if you find this feature useful.

danilowoz commented 1 year ago

Sandpack aims to provide an essential but powerful editing experience. That said, we're not considering adding this feature because it can't be considered critical in most cases when using Sandpack. Plus, this can be manually added using the extension API:

<Sandpack
  options={{
    codeEditor: {
      extensions: [codemirrorExtension()],
    },
  }}
  template="react"
/>

https://sandpack.codesandbox.io/docs/advanced-usage/components#extensions