open-consul/ui/packages/consul-ui/app/components/code-editor
Ronald 6bcb98ea71
Add UI copyright headers files (#16614)
* Add copyright headers to UI files

* Ensure copywrite file ignores external libs
2023-03-14 09:18:55 -04:00
..
README.mdx ui: Adds partition support to Service and Node Identity templates (#11696) 2021-12-06 10:33:44 +00:00
index.hbs Add UI copyright headers files (#16614) 2023-03-14 09:18:55 -04:00
index.js Add UI copyright headers files (#16614) 2023-03-14 09:18:55 -04:00
index.scss Add UI copyright headers files (#16614) 2023-03-14 09:18:55 -04:00
layout.scss Add UI copyright headers files (#16614) 2023-03-14 09:18:55 -04:00
skin.scss Add UI copyright headers files (#16614) 2023-03-14 09:18:55 -04:00

README.mdx

---
class: ember
state: needs-love
---

# CodeEditor

```hbs preview-template
<CodeEditor
    @readonly={{true}}
    @name={{concat name "[Rules]"}}
    @syntax="hcl"
    @oninput={{noop}}
>
    <:label>
    Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a>
    </:label>
    <:content>
      {"content": "Initial Content"}
    </:content>
</CodeEditor>
```

A code-editor with syntax highlighting supporting multiple languages (JSON, HCL, YAML), validation and simple tools such as "Copy to clipboard"


### Arguments

| Argument | Type | Default | Description |
| --- | --- | --- | --- |
| `readonly` | `Boolean` | false | If true, the content (value) of the CodeEditor cannot be changed by the user |
| `name` | `String` |  | The name attribute of the form element |
| `syntax` | `String` |  | Identifies the language used to validate/syntax highlight the code (possible values: hcl, json, yaml) |
| `oninput` | `Action` | noop | Action/callback that is triggered when the user inputs data |

### Named Blocks

| Name | Description | Behaviour if empty |
| --- | --- | --- |
| `:label` | Used to define the title that's displayed on the left inside the toolbar above the CodeEditor | Nothing is displayed |
| `:tools` | Used to define tools, buttons, widgets that will be displayed on the right inside the toolbar above the CodeEditor | By default it renders a `language selector` dropdown (if `readonly`== false and `syntax` is falsy) and a `CopyButton`
| `:content` | Used to display specific content such as code templates inside the CodeEditor | if the block is defined, @value will be displayed instead |


### See

- [Component Source Code](./index.js)
- [Template Source Code](./index.hbs)

---