Code Editor
Formsatlas-code-editorExamples
Large editor
A full-size editor on its own: pick the language, toggle line numbers and wrapping. Tab moves focus out; turn on "Tab indents" and Ctrl+M (Shift+Alt+M on macOS) switches Tab back to focus navigation.
Edit freely; nothing is saved.
9 lines · 199 characters
Read-only and disabled
A read-only editor stays focusable, so the text can be selected and copied; a disabled one takes no focus or input.
API
Generated from the library source, so it always matches the code.
AtlasCodeEditorComponent atlas-code-editor
| Input | Type | Default | Description |
|---|---|---|---|
| value two-way | string | '' | |
| language | AtlasCodeEditorLanguage | 'plain' | 'plain' and 'json' . |
| placeholder | string | '' | ariaLabel . |
| lineNumbers | boolean | true | |
| lineWrapping | boolean | false | |
| indentWithTab | boolean | false | |
| disabled | boolean | false | |
| errors | readonly ValidationError.WithOptionalFieldTree[] | [] | [field] . |
| required | boolean | false | [field] . |
| invalid | boolean | false | [field] . |
| touched | boolean | false | [field] . |
| readonly | boolean | false | [field] . |
| pending | boolean | false | [field] . |
| name | string | '' | [field] . |
| ariaLabel | string | null | null | |
| inputId | string | undefined | undefined | id of the text surface. Inside atlas-form-field the field supplies one. |
| ariaDescribedBy | string | null | null | aria-describedby , merged with the surrounding form field's hint or error. |
| class | string | '' | h-80 ); yours win on conflicts. |
| Output | Payload | Description |
|---|---|---|
| touch | void |
Functions
| Function | Description |
|---|---|
| provideAtlasCodeEditorEngine(engine: AtlasCodeEditorEngine): EnvironmentProviders |
Types
AtlasCodeEditorAttributes
role="textbox" ): id , aria-label , aria-labelledby , aria-describedby , aria-invalid , aria-required , aria-readonly , aria-disabled . Absent keys are removed.
type AtlasCodeEditorAttributes = Readonly<Record<string, string>>AtlasCodeEditorCreateOptions
Extends AtlasCodeEditorSettings
| Property | Type | Description |
|---|---|---|
| value | string | |
| onChange | (value: string): void | setValue ). |
| onBlur | (): void |
AtlasCodeEditorEngine
atlas-code-editor . Atlas ships a CodeMirror 6 engine; provide another one (Monaco, a plain textarea…) with provideAtlasCodeEditorEngine() without touching the components that use the editor.
| Property | Type | Description |
|---|---|---|
| create | (host: HTMLElement, options: AtlasCodeEditorCreateOptions): AtlasCodeEditorInstance | host (an empty element the component owns). Browser only. |
AtlasCodeEditorInstance
| Property | Type | Description |
|---|---|---|
| setValue | (value: string): void | onChange . A no-op when the text is unchanged. |
| update | (settings: Partial<AtlasCodeEditorSettings>): void | |
| focus | (): void | |
| destroy | (): void |
AtlasCodeEditorLanguage
'plain' and 'json' ; an engine treats a name it does not know as plain text.
type AtlasCodeEditorLanguage = 'plain' | 'json' | (string & {})AtlasCodeEditorSettings
| Property | Type | Description |
|---|---|---|
| language | AtlasCodeEditorLanguage | |
| readonly | boolean | |
| disabled | boolean | |
| lineNumbers | boolean | |
| lineWrapping | boolean | |
| indentWithTab | boolean | |
| placeholder | string | |
| attributes | AtlasCodeEditorAttributes |