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

Code editor additional languages #2684

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

Conversation

zamoore
Copy link
Contributor

@zamoore zamoore commented Feb 4, 2025

πŸ“Œ Summary

If merged, this PR adds syntax highlighting support for JavaScript and Rego to the hds-code-editor modifier.

πŸ› οΈ Detailed description

  • Implements custom Rego StreamParser
  • Uses official JS parser for javascript

πŸ“Έ Screenshots

πŸ”— External links

Jira tickets:
HDS-4452
HDS-4469


πŸ‘€ Component checklist

πŸ’¬ Please consider using conventional comments when reviewing this PR.

@hashibot-hds hashibot-hds added packages/components docs-website Content updates to the documentation website showcase labels Feb 4, 2025
Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
hds-showcase βœ… Ready (Inspect) Visit Preview Feb 4, 2025 6:31pm
hds-website βœ… Ready (Inspect) Visit Preview Feb 4, 2025 6:31pm

Copy link
Contributor

@shleewhite shleewhite left a comment

Choose a reason for hiding this comment

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

Tested it out and looked good to me, just a couple small nits.

Ruby = 'ruby',
Shell = 'shell',
Go = 'go',
Hcl = 'hcl',
Javascript = 'javascript',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: should it be JavaScript?

"@hashicorp/design-system-components": minor
---

hds-code-editor: Add language syntax highlighting suport for JavaScript and Rego
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: should we include that theres a new dep @codemirror/lang-javascript?

Copy link
Contributor

@dchyun dchyun left a comment

Choose a reason for hiding this comment

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

Looks great! Just a couple small comments

console.log(message);
}

sayMessage();
}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] This is causing a trailing bracket in the showcase example.
Screenshot 2025-02-07 at 10 17 45β€―AM

"@hashicorp/design-system-components": minor
---

hds-code-editor: Add language syntax highlighting suport for JavaScript and Rego
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
hds-code-editor: Add language syntax highlighting suport for JavaScript and Rego
`hds-code-editor` modifier - Add language syntax highlighting suport for JavaScript and Rego
`CodeEditor` - Add language syntax highlighting suport for JavaScript and Rego

[nit] Need to tweak format slightly, and add in a line for the CodeEditor so the parser generate a version history for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There aren't any direct changes to the code editor component, just the modifier. Do you think we still need to tag the component with changes?

Copy link
Member

Choose a reason for hiding this comment

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

There aren't any direct changes to the code editor component, just the modifier. Do you think we still need to tag the component with changes?

While your take is accurate, all instances using the modifier (in our case the CodeEditor component) are benefitting from this new feature, so surfacing it at the component level makes sense to me. While we offer both a component and a modifier, the latter is more of an escape hatch for bespoke implementations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense - Thanks for your clarification.

@hashicorp hashicorp deleted a comment from Bosaba667 Feb 7, 2025
@hashicorp hashicorp deleted a comment from Bosaba667 Feb 7, 2025
@majedelass
Copy link
Contributor

Design will have to add these to the CodeEditor ~ will open up a branch for this in Figma.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-website Content updates to the documentation website packages/components showcase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants