Skip to content

feat: Use monaco editor #3076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

feat: Use monaco editor #3076

wants to merge 12 commits into from

Conversation

liuxingbaoyu
Copy link
Member

This was tested manually, so let me see if everything works fine after deployment.

Copy link

netlify bot commented Apr 3, 2025

👷 Deploy request for babel-next pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 2b9ddcc

Copy link

netlify bot commented Apr 3, 2025

Deploy Preview for babel ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2b9ddcc
🔍 Latest deploy log https://app.netlify.com/sites/babel/deploys/67fe120bf5ce4900080b1b30
😎 Deploy Preview https://deploy-preview-3076--babel.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

padding: {
top: 2,
},
theme: "dark-plus",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set the light theme by default? Ideally it should adapt to the user colour scheme preference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since our tabs and options are dark, I prefer to always use a dark theme. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current REPL supports user colour scheme preference. If you prefer dark scheme, the REPL will adapt to the system settings (we should have also migrated the top-right colour scheme switch button to REPL page):

Light mode:
image

Dark mode:
image

The tabs/options are for the contrast with the editor, it does not mean we should use dark unconditionally: Similar to the landing page: the upper part is always dark

Light mode:
image

Dark mode:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L~M2AIG3)XNQKTKZPLH@~HJ
M$W5RQVWPCHEU81LEEPO
To be honest, our current light mode doesn't seem very ideal.
As an example, typescript-eslint is more like full light mode.
Of course I am in favor of introducing a button so that users can quickly switch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am all for changing the setting panel accordingly. But to force users with light mode to use dark mode editor is another thing. The current behaviour is that, if the system is in light mode, the editor will be in light mode as well, so as to the dark mode.

@liuxingbaoyu liuxingbaoyu changed the title feat: Using monaco editor feat: Use monaco editor Apr 4, 2025
@JLHwung
Copy link
Contributor

JLHwung commented Apr 4, 2025

On colour mode switch button: If we merge REPL back to a docusuarus page, the global navbar will be reused and we should automatically get the colour switch button. Of course this can be an idea for a new PR.

@liuxingbaoyu
Copy link
Member Author

Yes I'm trying.
Do you remember why we split the REPL?

@JLHwung
Copy link
Contributor

JLHwung commented Apr 4, 2025

Yes I'm trying. Do you remember why we split the REPL?

It was separated when we are migrating to docusuarus 2 so that we can speed up the migration process: #2622 (comment)

Now that we are using docusaurus v3 and planing a REPL overhaul, maybe we can try to see if we can move it back and unify the navbar. @nicolo-ribaudo WDYT?

@JLHwung
Copy link
Contributor

JLHwung commented Apr 5, 2025

The new build looks much better. Now that the monaco editor will capture the command/ctrl key so cmd/ctrl+K will not work, can we hide the DocSearch-Button-Keys?

image

Comment on lines 81 to 86
model: fastMode
? monaco.editor.createModel(
"",
"javascript",
monaco.Uri.file("output/output.tsx")
)
Copy link
Member Author

@liuxingbaoyu liuxingbaoyu Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a somewhat bad hack.

The syntax highlighter registered by shiki will cause performance degradation, which is obvious when using timeTravel on large files.
And monaco does not support using different syntax highlighters for the same language.
So we set the language of the output code to js, it will use a worse highlight, and notice that it will not warn even if we output ts.

What do you think about using this solution, or not using it (because it is not very slow, just a little slow), or continuing to use codemirror for output code?

repl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants