Skip to content

Commit dea879f

Browse files
zamooredchyun
andauthored
Code editor additional languages (#2684)
Co-authored-by: Dylan Hyun <dylan.hyun@hashicorp.com>
1 parent e1156b0 commit dea879f

File tree

10 files changed

+467
-5
lines changed

10 files changed

+467
-5
lines changed

.changeset/smooth-bobcats-hang.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@hashicorp/design-system-components": minor
3+
---
4+
5+
`hds-code-editor` modifier - Add language syntax highlighting suport for JavaScript and Rego
6+
7+
`CodeEditor` - Add language syntax highlighting suport for JavaScript and Rego
8+
9+
Dependencies - added @codemirror/lang-javascript

packages/components/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"dependencies": {
3838
"@codemirror/commands": "^6.8.0",
3939
"@codemirror/lang-go": "^6.0.1",
40+
"@codemirror/lang-javascript": "^6.2.2",
4041
"@codemirror/lang-json": "^6.0.1",
4142
"@codemirror/lang-sql": "^6.8.0",
4243
"@codemirror/lang-yaml": "^6.1.2",

packages/components/src/modifiers/hds-code-editor.ts

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ const LANGUAGES: Record<
5252
HdsCodeEditorLanguages,
5353
{ load: () => Promise<Extension | StreamLanguageType<unknown>> }
5454
> = {
55+
rego: {
56+
load: async () => {
57+
const { rego } = await import('./hds-code-editor/languages/rego.ts');
58+
return defineStreamLanguage(rego);
59+
},
60+
},
5561
ruby: {
5662
load: async () => {
5763
const { ruby } = await import('@codemirror/legacy-modes/mode/ruby');
@@ -78,6 +84,10 @@ const LANGUAGES: Record<
7884
hcl: {
7985
load: async () => (await import('codemirror-lang-hcl')).hcl(),
8086
},
87+
javascript: {
88+
load: async () =>
89+
(await import('@codemirror/lang-javascript')).javascript(),
90+
},
8191
json: {
8292
load: async () => (await import('@codemirror/lang-json')).json(),
8393
},

0 commit comments

Comments
 (0)