Page History
(this page was created automatically. In case of formatting issues, please visit the official Wiki Page)
Code Editor
Overview
- The Code Editor Component is a specialized form control for code editing.
- It provides syntax highlighting, language detection, and a modern editor interface.
- It supports code formats like JSON, YAML, plain text, and Nginx configuration.
- It helps users input structured text or code snippets inside forms.
...
- authorizationDisable – Specifies a policy set that determines when the component should be disabled based on user permissions. For example, setting to "readOnlyPolicy" will disable the code editor for users who don’t have edit permissions according to the specified policy.
Links
- Figma: tba
- Live style guide: tba
Guidelines
...
[NO DATA AVAILABLE]
Accessibility
...
Usage
- Set
defaultLanguageto the expected syntax so highlighting is predictable when automatic detection fails (e.g.,json,yaml,nginx,plaintext). - Seed helpful starter content with
defaultValue(e.g., a minimal valid JSON object) to reduce user errors. - Enforce input rules with
validation(userequired,minLength,maxLength, andpatternfor syntax/shape checks).
Sizing & Layout
- Set
heightto a fixed px value for consistent editing space (e.g.,400px) or a percentage for flexible layouts (e.g.,100%within its container). - Choose
theme(DarkorLight) to maintain comfortable contrast in the expected environment; prefer the option that meets contrast needs of surrounding UI.
States & Feedback
- Use
readonlyto present code without allowing edits. - Use
authorizationDisableto disable editing based on policy while keeping the control present. - Toggle
hiddento remove the control from view when not applicable.
Data-Driven / Conditional Behavior
- Constrain content shape with
validation.pattern(regex) and size withminLength/maxLength; require presence withrequired. - Preserve draft stability across sessions with
saveInLocalStorage.
Content & Localization
- Provide clear starter content with
defaultValuethat matchesdefaultLanguage. - Prefer language-neutral examples in
defaultValue, since the component exposes no text translation settings.
Dos & Don’ts
| Do | Don’t | Article setting(s) |
|---|---|---|
Set defaultLanguage to the expected syntax so highlighting is stable. | Rely solely on auto-detection and accept mismatched highlighting. | defaultLanguage |
| Pre-fill a minimal valid template. | Start empty when strict formatting is required. | defaultValue |
| Persist drafts between sessions. | Risk data loss on reloads. | saveInLocalStorage |
| Enforce rules with validation. | Depend on user memory for format rules. | validation.required, validation.minLength, validation.maxLength, validation.pattern |
| Disable edits for review or policy. | Leave the editor editable when changes aren’t allowed. | readonly, authorizationDisable |
| Give users enough vertical space to work. | Force excessive scrolling with a tiny viewport. | height |
| Choose a theme for readable contrast. | Switch themes arbitrarily mid-task. | theme |
Accessibility
- Ensure readable presentation by selecting an appropriate
themeand sufficient edit area withheight. - Prevent non-functional interaction by using
readonlyfor view-only scenarios andauthorizationDisablewhen policy blocks editing. - Reduce error burden with built-in
validationso incorrect content is caught by the control before submission. - Use
defaultValuethat demonstrates valid structure matchingdefaultLanguageto assist comprehension for screen-reader and keyboard users.