react-code-block icon indicating copy to clipboard operation
react-code-block copied to clipboard

Support with Sandpack Editor

Open saurabhdaware opened this issue 2 years ago • 2 comments

Sandpack by CodeSandbox supports passing a custom editor function

Here's example with Monaco Editor - https://sandpack.codesandbox.io/docs/guides/integrate-monaco-editor

I think it should be possible to use this with Sandpack. We might have to export onChange function on CodeBlock component. I'll give it a try if I get some time.

saurabhdaware avatar Nov 06 '23 18:11 saurabhdaware

We can give this a try, but it'll require some way to allow user to edit code within the code block while still preserving syntax highlighting. (I can hear horrifying screams of contenteditable attribute 🙈)

I'm not sure how features like line highlighting / word highlighting will work in a code block like this. Maybe it can allow the initial code set by the author to be highlighted as usual, but when the user edits the code, the highlighting goes away.

blenderskool avatar Nov 06 '23 18:11 blenderskool

but it'll require some way to allow user to edit code within the code block while still preserving syntax highlighting

oh yes tried that. This will be tricky.

Maybe it can allow the initial code set by the author to be highlighted as usual, but when the user edits the code, the highlighting goes away.

Aha this is good idea! Normally I have seen line highlighting work only on static code but in live-editor the line highlighting is disabled.

saurabhdaware avatar Nov 06 '23 19:11 saurabhdaware