Skip to content

Commit 5538d18

Browse files
committed
added docs and changeset
1 parent bc9b9f5 commit 5538d18

File tree

5 files changed

+82
-5
lines changed

5 files changed

+82
-5
lines changed

.changeset/smooth-bobcats-hang.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hashicorp/design-system-components": minor
3+
---
4+
5+
hds-code-editor: Add language syntax highlighting suport for JavaScript and Rego

showcase/app/controllers/components/code-editor.js

+27
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ sed do eiusmod tempor incididunt
1212
ut labore et dolore magna aliqua`;
1313

1414
languages = [
15+
{
16+
value: 'rego',
17+
label: 'Rego',
18+
code: `package example.test
19+
import data.users
20+
default allow = false
21+
# single-line comment
22+
allow with data.something as foo {
23+
some i in input.paths
24+
not forbidden
25+
time.now() >= /* inline block comment */ 1672531200
26+
}
27+
deny { base64.decode(input.encoded) == "decoded" }
28+
`,
29+
},
1530
{
1631
value: 'ruby',
1732
label: 'Ruby',
@@ -58,6 +73,18 @@ func main() {
5873
code: `variable "region" {
5974
type = string
6075
default = "us-west-1"
76+
}`,
77+
},
78+
{
79+
value: 'javascript',
80+
label: 'JavaScript',
81+
code: `const message = 'Hello, world!';
82+
83+
function sayMessage() {
84+
console.log(message);
85+
}
86+
87+
sayMessage();
6188
}`,
6289
},
6390
{

website/docs/components/code-editor/partials/code/component-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This component uses [CodeMirror 6](https://codemirror.net/) under the hood.
2929
<C.Property @name="isStandalone" @type="boolean" @default="true">
3030
Applies rounded borders to the component. When used within another component or when the context requires it, you can turn it off.
3131
</C.Property>
32-
<C.Property @name="language" @type="string" @values={{array "go" "hcl" "json" "ruby" "sentinel" "shell" "sql" "yaml"}}>
32+
<C.Property @name="language" @type="string" @values={{array "go" "hcl" "javascript" "json" "rego" "ruby" "sentinel" "shell" "sql" "yaml"}}>
3333
The coding language to use for syntax highlighting. If you need additional languages <LinkTo class="doc-link-generic" @route="show" @model="about/support">contact the Design Systems Team</LinkTo>.
3434
</C.Property>
3535
<C.Property @name="value" @type="string">

website/docs/components/code-editor/partials/code/how-to-use.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The default `@tag` is `"h2"`, however, the correct value is dependent on the ind
5959

6060
### Language
6161

62-
The `language` argument sets the syntax highlighting used. We support the following languages: `ruby`, `sentinel`, `shell`, `go`, `hcl`, `json`, `sql`, and `yaml`. If you need additional languages, <LinkTo class="doc-link-generic" @route="show" @model="about/support">contact the Design Systems Team</LinkTo>.
62+
The `language` argument sets the syntax highlighting used. We support the following languages: `rego`, `ruby`, `sentinel`, `shell`, `go`, `hcl`, `javascript`, `json`, `sql`, and `yaml`. If you need additional languages, <LinkTo class="doc-link-generic" @route="show" @model="about/support">contact the Design Systems Team</LinkTo>.
6363

6464
```handlebars
6565
<Hds::CodeEditor

yarn.lock

+48-3
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,21 @@ __metadata:
21242124
languageName: node
21252125
linkType: hard
21262126

2127+
"@codemirror/lang-javascript@npm:^6.2.2":
2128+
version: 6.2.2
2129+
resolution: "@codemirror/lang-javascript@npm:6.2.2"
2130+
dependencies:
2131+
"@codemirror/autocomplete": "npm:^6.0.0"
2132+
"@codemirror/language": "npm:^6.6.0"
2133+
"@codemirror/lint": "npm:^6.0.0"
2134+
"@codemirror/state": "npm:^6.0.0"
2135+
"@codemirror/view": "npm:^6.17.0"
2136+
"@lezer/common": "npm:^1.0.0"
2137+
"@lezer/javascript": "npm:^1.0.0"
2138+
checksum: 10/eac2e57a7a595cf0c93afd4bb42034902230c73e5525554ba925bad12aa544ca58014c017466288a2b34f1684d6efa5537507ed8b57e276d02665c2821c7a9d6
2139+
languageName: node
2140+
linkType: hard
2141+
21272142
"@codemirror/lang-json@npm:^6.0.1":
21282143
version: 6.0.1
21292144
resolution: "@codemirror/lang-json@npm:6.0.1"
@@ -2186,6 +2201,17 @@ __metadata:
21862201
languageName: node
21872202
linkType: hard
21882203

2204+
"@codemirror/lint@npm:^6.0.0":
2205+
version: 6.8.4
2206+
resolution: "@codemirror/lint@npm:6.8.4"
2207+
dependencies:
2208+
"@codemirror/state": "npm:^6.0.0"
2209+
"@codemirror/view": "npm:^6.35.0"
2210+
crelt: "npm:^1.0.5"
2211+
checksum: 10/401ead0591d88d31d1bf6527d4caba26e0deb7b49382dfbb8c712037d858047b0699fa2c15831a07db928194549eea9b942004fee42f334b34ff5973c7dbec58
2212+
languageName: node
2213+
linkType: hard
2214+
21892215
"@codemirror/state@npm:^6.0.0, @codemirror/state@npm:^6.4.0, @codemirror/state@npm:^6.5.0":
21902216
version: 6.5.0
21912217
resolution: "@codemirror/state@npm:6.5.0"
@@ -2195,7 +2221,7 @@ __metadata:
21952221
languageName: node
21962222
linkType: hard
21972223

2198-
"@codemirror/view@npm:^6.17.0, @codemirror/view@npm:^6.23.0, @codemirror/view@npm:^6.27.0, @codemirror/view@npm:^6.36.2":
2224+
"@codemirror/view@npm:^6.17.0, @codemirror/view@npm:^6.23.0, @codemirror/view@npm:^6.27.0, @codemirror/view@npm:^6.35.0, @codemirror/view@npm:^6.36.2":
21992225
version: 6.36.2
22002226
resolution: "@codemirror/view@npm:6.36.2"
22012227
dependencies:
@@ -3924,6 +3950,7 @@ __metadata:
39243950
"@babel/runtime": "npm:^7.26.0"
39253951
"@codemirror/commands": "npm:^6.8.0"
39263952
"@codemirror/lang-go": "npm:^6.0.1"
3953+
"@codemirror/lang-javascript": "npm:^6.2.2"
39273954
"@codemirror/lang-json": "npm:^6.0.1"
39283955
"@codemirror/lang-sql": "npm:^6.8.0"
39293956
"@codemirror/lang-yaml": "npm:^6.1.2"
@@ -4535,7 +4562,7 @@ __metadata:
45354562
languageName: node
45364563
linkType: hard
45374564

4538-
"@lezer/highlight@npm:^1.0.0, @lezer/highlight@npm:^1.2.0":
4565+
"@lezer/highlight@npm:^1.0.0, @lezer/highlight@npm:^1.1.3, @lezer/highlight@npm:^1.2.0":
45394566
version: 1.2.1
45404567
resolution: "@lezer/highlight@npm:1.2.1"
45414568
dependencies:
@@ -4544,6 +4571,17 @@ __metadata:
45444571
languageName: node
45454572
linkType: hard
45464573

4574+
"@lezer/javascript@npm:^1.0.0":
4575+
version: 1.4.21
4576+
resolution: "@lezer/javascript@npm:1.4.21"
4577+
dependencies:
4578+
"@lezer/common": "npm:^1.2.0"
4579+
"@lezer/highlight": "npm:^1.1.3"
4580+
"@lezer/lr": "npm:^1.3.0"
4581+
checksum: 10/7f8b1f469103e74dc2c39e7e75e6cc670e4cf6f48b5317e2a0e267521c9924641e8de41c6e740af8cc919f5c7e03c0a97fc2f261486c96f1625c3e3bbb23b80a
4582+
languageName: node
4583+
linkType: hard
4584+
45474585
"@lezer/json@npm:^1.0.0":
45484586
version: 1.0.3
45494587
resolution: "@lezer/json@npm:1.0.3"
@@ -4555,7 +4593,7 @@ __metadata:
45554593
languageName: node
45564594
linkType: hard
45574595

4558-
"@lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.4.0":
4596+
"@lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.3.0, @lezer/lr@npm:^1.4.0":
45594597
version: 1.4.2
45604598
resolution: "@lezer/lr@npm:1.4.2"
45614599
dependencies:
@@ -11031,6 +11069,13 @@ __metadata:
1103111069
languageName: node
1103211070
linkType: hard
1103311071

11072+
"crelt@npm:^1.0.5":
11073+
version: 1.0.6
11074+
resolution: "crelt@npm:1.0.6"
11075+
checksum: 10/5ed326ca6bd243b1dba6b943f665b21c2c04be03271824bc48f20dba324b0f8233e221f8c67312526d24af2b1243c023dc05a41bd8bd05d1a479fd2c72fb39c3
11076+
languageName: node
11077+
linkType: hard
11078+
1103411079
"cross-spawn@npm:^6.0.0":
1103511080
version: 6.0.6
1103611081
resolution: "cross-spawn@npm:6.0.6"

0 commit comments

Comments
 (0)