live-codes/livecodes

Monaco editor CSS nesting support

Closed this issue · 9 comments

Currently, the monaco editor shows errors when using CSS nested selectors.

CleanShot-Obsidian-View Transitions test + vtremove prototype - Playground - Obsidian v1 5 8-2024-02-23-13 13 25

Is it possible to update the engine to remove these errors? Are there any SDK config options that might solve this issue?

After a brief search, this may be related to my request.

microsoft/monaco-editor#4071

Thank you!

Thank you for raising that up and for the helpful link.

I will watch that issue in Monaco editor till supported and update it.

May be a temporary solution is loading CSS in Monaco editor as SCSS (which is a superset of CSS). Of course, the SCSS compiler will not be used in that case.
What do you think?

Your temp solution works great. Thank you for the tip!

@gapmiss

I have implemented this workaround. (use SCSS language in Monaco instead of CSS, till official support lands)

Please try it on this preview URL and let me know if you have any comments:
https://48652ce8.livecodes.pages.dev/

image

Thank you for reporting this issue.

@hatemhosny

Yes, this works great. Thank you

I was also hoping it would solve similar issues with CSS @layer. However, even with your SCSS workaround, it still show errors. Not sure if they are similar, but am happy to have the nesting workaround.

https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

CleanShot-Safari-LiveCodes-2024-02-26-07 23 40

@hatemhosny

Yes, this works great. Thank you

I was also hoping it would solve similar issues with CSS @layer. However, even with your SCSS workaround, it still show errors. Not sure if they are similar, but am happy to have the nesting workaround.

https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

CleanShot-Safari-LiveCodes-2024-02-26-07 23 40

@gapmiss
we need to wait for monaco to support that
the css nesting workaround has been merged and should be available in next release
meanwhile, you may test it on https://next.livecodes.io/
thank you for reporting

@hatemhosny FYI… I've noticed since this workaround, that CSS code comments (+/) are being rendered as // instead of /* */

@hatemhosny FYI… I've noticed since this workaround, that CSS code comments (+/) are being rendered as // instead of /* */

@gapmiss
I see. Let's revert this workaround and wait till new CSS features are officially supported in Monaco.
Thanks again.

@hatemhosny agree, best choice at the moment ... thank you

hi @gapmiss

CSS nesting & @layer are now supported on Monaco editor

image

demo:
https://livecodes.io/?x=id/hjqjv3avhkh

image

demo: https://livecodes.io/?x=id/35w66b2vbdk

Thank you :)