Skip to content
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

Doesn't work in JSONC file types #2

Closed
blaylockbk opened this issue Aug 12, 2021 · 4 comments
Closed

Doesn't work in JSONC file types #2

blaylockbk opened this issue Aug 12, 2021 · 4 comments
Assignees
Labels
done Work has been done for this issue. enhancement New feature or request

Comments

@blaylockbk
Copy link

Thanks for making this extension. I use it often.

I found that the extension doesn't work for JSONC (json with comments) file types.

image

image

Probably not the best place to request this, but I would love to see the color picker show in more file types (like TOML).

@YECHUNAN YECHUNAN added the enhancement New feature or request label Aug 12, 2021
@YECHUNAN YECHUNAN self-assigned this Aug 23, 2021
@YECHUNAN
Copy link
Owner

YECHUNAN commented Aug 23, 2021

Thanks for posting the feature request!

I published a new 1.2.0 which adds a setting to allow people declare arbitrary language to apply the color token detection. jsonc is included in the default value. Theoretically it should work for any other language where color tokens are defined to match this regex: /#[0-9a-fA-F]{6}([0-9]{2})?/g. I didn't exclude the detection for colors in the comments. Please let me know if that significantly disrupts your use case.

image

Unfortunately, due to my lack of knowledge, none of the css-json interaction features will work because I don't know which library to use for parsing jsonc documents.

@YECHUNAN YECHUNAN added the done Work has been done for this issue. label Aug 23, 2021
@blaylockbk
Copy link
Author

blaylockbk commented Aug 24, 2021

This is awesome! Thank you so much. I can now use this color picker in more than just JSON, but JSONC, Python, TOML, and any other document type.
image

@LeonardoGentile
Copy link

LeonardoGentile commented Nov 23, 2021

@YECHUNAN Awesome!
I think you should rename this extension because it might be misleading, given that now this extension is capable of bringing up the color picker not only in json but in any language! 👍 🎉

For future readers: to make this work with js and react, add this in settings:

"jsonColorToken.languages": [
    "json",
    "jsonc",
    "javascript",
    "javascriptreact"
  ]

@eunkich
Copy link

eunkich commented Oct 30, 2023

For those of you trying to enable this feature for python, identifier should be "python", not "Python" as in @blaylockbk's example. Reload window after adding the language identifier in settings.

You can look for the language identifier of your interest in the following link.
#10 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Work has been done for this issue. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants