cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Enable prettier formatter in monaco

Open jjspace opened this issue 9 months ago • 4 comments

Description

  • Add prettier to Sandcastle to format code in monaco
    • This aligns with the rest of Cesium's code so gallery examples should format the same as the source
  • Update monaco default settings
    • I did a pass on all the editor options and toggled a handful to increase the user experience.
    • I really struggled not to turn on all the extra stuff that fits my personal preference :sweat_smile:

Issue number and link

Part of #12566

Testing plan

  • Write any code in Sandcastle
  • Click Format and make sure it works for JS and HTML with no errors
  • Make sure the formatted code matches what you'd expect from prettier

Author checklist

  • [ ] I have submitted a Contributor License Agreement
  • [ ] I have added my name to CONTRIBUTORS.md
  • [ ] I have updated CHANGES.md with a short summary of my change
  • [ ] I have added or updated unit tests to ensure consistent code coverage
  • [ ] I have updated the inline documentation, and included code examples where relevant
  • [ ] I have performed a self-review of my code

jjspace avatar May 29 '25 15:05 jjspace

Thank you for the pull request, @jjspace!

:white_check_mark: We can confirm we have a CLA on file for you.

github-actions[bot] avatar May 29 '25 15:05 github-actions[bot]

I really struggled not to turn on all the extra stuff that fits my personal preference 😅

We all have editor preferences, and some user expressed interest in disabling as much as possible. How tricky would it be to add a settings menu to turn features on and off?

ggetz avatar Jun 13 '25 17:06 ggetz

@ggetz functionally it shouldn't be that hard. However it would probably be a lot of effort to pick and choose which of the 150+ options we want to expose and allow changing

I would rather we stick mostly to defaults with the few opinionated changes I've already made. Monaco shouldn't really get in the way of people just "typing in code".

If we get feedback that it's too much after trying it we can potentially add a single toggle for a "plain text" mode that turns off nearly everything.

jjspace avatar Jun 13 '25 18:06 jjspace

However it would probably be a lot of effort to pick and choose which of the 150+ options and allow changing...If we get feedback that it's too much after trying it we can potentially add a single toggle for a "plain text" mode that turns off nearly everything.

Yes, I agree that approach it with that kind of fine-toothed comb would be a loosing battle.

At the very least, we are already allowing user to toggle dark and light modes, so I don't think it would hurt to have a settings area for that plus maybe one or two "controversial" options. From there, we could make small changes based on user feedback, right?

ggetz avatar Jun 13 '25 19:06 ggetz

@jjspace Code is all looking good. Could you please

  1. merge in the feature branch, and
  2. address or document https://github.com/CesiumGS/cesium/pull/12640#issuecomment-2971395229 in https://github.com/CesiumGS/cesium/issues/12566

? This should then be good to merge.

ggetz avatar Jun 27 '25 19:06 ggetz

Thanks @ggetz this should be good to go now. Slightly annoying merge but it looks cleaned up now. I'll add a todo to track user settings including the editor settings

jjspace avatar Jun 27 '25 22:06 jjspace

Awesome, thanks @jjspace!

ggetz avatar Jun 30 '25 15:06 ggetz