@tooark/code 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -19
- package/README.pt-BR.md +60 -19
- package/dist/index.cjs +379 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -3
- package/dist/index.d.ts +62 -3
- package/dist/index.js +385 -35
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ The `@tooark/code` package provides:
|
|
|
29
29
|
- `language` json / javascript / yaml / text, line numbers, folding, search (Ctrl+F), bracket matching, active line, placeholder, `readonly`, `wrap`, `min-height`;
|
|
30
30
|
- Tab indents (Shift+Tab outdents; Esc then Tab leaves the editor), `indent-style` spaces or tabs, `indent-size`, `line-ending` `auto`/`lf`/`crlf` converted at the value boundary;
|
|
31
31
|
- completions: the language's own, `variableKeys` after `{{`, `completions` (words in any language) and `completionSource`; `autocomplete="false"` turns them off;
|
|
32
|
+
- optional, off until you pass them: `variables` paints each `{{key}}` with its variable's intent (free-form scope, hover tooltip with scope and value), `mark-unknown-variables` flags keys that are not defined, and `single-line` turns the editor into a one-line field at control height (`size`), Enter emitting `ark-submit`;
|
|
32
33
|
- `format()` and Shift+Alt+F: JSON built in with the configured indentation, other languages through the `formatter` hook (Prettier stays in the app);
|
|
33
34
|
- chrome on the `--ark-color-*` tokens with fallbacks, `theme="auto"` following the page at runtime; `createCodeEditor` engine without the element;
|
|
34
35
|
- CodeMirror packages as peer dependencies, so the page keeps one copy of `@codemirror/state`.
|
|
@@ -61,16 +62,30 @@ registerTooarkCode();
|
|
|
61
62
|
|
|
62
63
|
### `ark-code-editor`
|
|
63
64
|
|
|
64
|
-
- Attributes: `language` (`json` | `javascript` | `yaml` | `text`), `readonly`, `placeholder`, `min-height` (default `8rem`), `line-numbers` and `fold` (on; `"false"` turns off), `wrap`, `indent-style` (`space` | `tab`), `indent-size` (default 2), `line-ending` (`auto` | `lf` | `crlf`), `tab-indent` and `autocomplete` (on; `"false"` turns off), `theme`, `testid`.
|
|
65
|
-
- Properties: `value`, `variableKeys`, `completions`, `completionSource`, `formatter`, `canFormat`, `resolvedLineEnding`, `resolvedTheme`, `view` (the `EditorView`), and one per attribute except `testid`; methods `format()`, `focus()`.
|
|
66
|
-
- Events: `change` (`detail: { value }`, user edits only), `ark-format-error` (`detail: { error }`).
|
|
65
|
+
- Attributes: `language` (`json` | `javascript` | `yaml` | `text`), `readonly`, `placeholder`, `min-height` (default `8rem`), `line-numbers` and `fold` (on; `"false"` turns off), `wrap`, `indent-style` (`space` | `tab`), `indent-size` (default 2), `line-ending` (`auto` | `lf` | `crlf`), `tab-indent` and `autocomplete` (on; `"false"` turns off), `mark-unknown-variables`, `single-line`, `size` (`xs` … `xl`, default `md`: font and side padding, plus the height in `single-line`), `theme`, `testid`.
|
|
66
|
+
- Properties: `value`, `variableKeys`, `variables`, `completions`, `completionSource`, `formatter`, `canFormat`, `resolvedLineEnding`, `resolvedTheme`, `view` (the `EditorView`), and one per attribute except `testid`; methods `format()`, `focus()`.
|
|
67
|
+
- Events: `change` (`detail: { value }`, user edits only), `ark-format-error` (`detail: { error }`), `ark-submit` (`detail: { value }`, Enter in `single-line`).
|
|
67
68
|
- Keys: Ctrl/Cmd+F search, Ctrl/Cmd+Z undo, Ctrl+Y redo (Cmd+Shift+Z on macOS), Ctrl+Space completions, Shift+Alt+F format, Tab/Shift+Tab indent, Esc+Tab leave, Ctrl+M (Shift+Alt+M on macOS) toggles CodeMirror's tab-focus mode.
|
|
69
|
+
- Hooks: the CodeMirror root carries `data-ark="code-editor"` and the `testid` as `data-testid`; each painted variable `data-ark="code-editor-variable"` with `data-key`; its tooltip `data-ark="code-editor-variable-tooltip"`.
|
|
70
|
+
|
|
71
|
+
### Scoped variables
|
|
72
|
+
|
|
73
|
+
Nothing changes until the app passes `variables` or sets `mark-unknown-variables`; `variableKeys` alone still only completes.
|
|
74
|
+
|
|
75
|
+
- `variables`: `ArkCodeVariable[]`, one `{ key, scope?, intent?, value? }` per key. The library knows no scope: `scope` is any name the app uses, and when a key exists in several scopes the app resolves the precedence and sends only the winner (a repeated key keeps its first entry).
|
|
76
|
+
- Each `{{key}}` (inner spaces allowed; keys use letters, digits, `_`, `.`, `-` and `$`) becomes `<span class="cm-ark-variable cm-ark-variable-<intent>" data-key data-scope data-intent>` with the intent's soft background and text (`--ark-color-<intent>-soft`/`-soft-fg`, default `primary`), also inside JSON strings, and each variable stays a single span. The distinct hues are `info`, `success`, `warning`/`primary` and `danger` (which also marks unknown keys); `secondary` and `neutral` read close to the text color. For more scopes, or your own palette, override a scope's colors with CSS, e.g. `ark-code-editor .cm-ark-variable[data-scope="global"] { background: …; color: … }`.
|
|
77
|
+
- A variable with `scope` or `value` shows a hover tooltip with the scope (in its intent) and the value; the completion after `{{` shows the scope as detail and the value as info. All of that text is the app's: leave `value` out for secrets.
|
|
78
|
+
- `mark-unknown-variables`: a `{{key}}` found in neither `variables` nor `variableKeys` gets `cm-ark-variable-unknown` and `data-unknown`, painted `danger` with a wavy underline (not color alone).
|
|
79
|
+
|
|
80
|
+
### Single-line field
|
|
81
|
+
|
|
82
|
+
`single-line` makes a field such as a URL bar: the height of the controls of the same `size` (it lines up with `ark-button` and `ark-input`), no gutters and no active line, Enter emits `ark-submit` instead of breaking the line (when the completion list is open, Enter accepts the completion), pasted line breaks are removed as in an `<input>`, Tab leaves the field and Ctrl/Cmd+F is left to the browser. Turning it on over a multi-line text joins the lines without a `change`. Variables and completions work the same.
|
|
68
83
|
|
|
69
84
|
### Engine
|
|
70
85
|
|
|
71
|
-
- `createCodeEditor(parent, options)` → `{ view, getValue, setValue, setLanguage, setTheme, setReadonly, setPlaceholder, setLineNumbers, setFold, setWrap, setMinHeight, setIndent, setLineEnding, resolvedLineEnding, setTabIndent, setAutocomplete, setVariableKeys, setCompletions, setCompletionSource, setFormatter, format, canFormat, resolvedTheme, focus, destroy }`.
|
|
86
|
+
- `createCodeEditor(parent, options)` → `{ view, getValue, setValue, setLanguage, setTheme, setReadonly, setPlaceholder, setLineNumbers, setFold, setWrap, setMinHeight, setIndent, setLineEnding, resolvedLineEnding, setTabIndent, setAutocomplete, setVariableKeys, setVariables, setMarkUnknownVariables, setSingleLine, setSize, setCompletions, setCompletionSource, setFormatter, format, canFormat, resolvedTheme, focus, destroy }`; the options mirror the attributes and properties, plus `onChange`, `onFormatError` and `onSubmit`.
|
|
72
87
|
- `resolveCodeTheme(theme, element)`.
|
|
73
|
-
- Types: `ArkCodeEditorInstance`, `ArkCodeEditorOptions`, `ArkCodeLanguage`, `ArkCodeTheme`, `ArkCodeIndentStyle`, `ArkCodeLineEnding`, `ArkCodeCompletion`, `ArkCodeCompletionSource`, `ArkCodeFormatter`.
|
|
88
|
+
- Types: `ArkCodeEditorInstance`, `ArkCodeEditorOptions`, `ArkCodeVariable`, `ArkCodeLanguage`, `ArkCodeTheme`, `ArkCodeIndentStyle`, `ArkCodeLineEnding`, `ArkCodeCompletion`, `ArkCodeCompletionSource`, `ArkCodeFormatter`.
|
|
74
89
|
|
|
75
90
|
---
|
|
76
91
|
|
|
@@ -90,6 +105,32 @@ formatButton.hidden = !editor.canFormat;
|
|
|
90
105
|
formatButton.addEventListener("click", () => editor.format()); // also Shift+Alt+F
|
|
91
106
|
```
|
|
92
107
|
|
|
108
|
+
### A URL field with scoped variables
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<ark-code-editor id="url" single-line mark-unknown-variables placeholder="{{baseUrl}}/path"></ark-code-editor>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
const url = document.querySelector("ark-code-editor")!;
|
|
116
|
+
// Precedence between scopes is resolved by the app: one entry per key.
|
|
117
|
+
url.variables = [
|
|
118
|
+
{ key: "baseUrl", scope: "global", intent: "info", value: "https://api.example.com" },
|
|
119
|
+
{ key: "token", scope: "environment", intent: "success" }, // no value: kept out of the tooltip
|
|
120
|
+
{ key: "userId", scope: "local", intent: "primary", value: "42" },
|
|
121
|
+
];
|
|
122
|
+
url.value = "{{baseUrl}}/users/{{userId}}";
|
|
123
|
+
url.addEventListener("ark-submit", (event) => send((event as CustomEvent<{ value: string }>).detail.value));
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```css
|
|
127
|
+
/* your own color for one scope, instead of an intent */
|
|
128
|
+
ark-code-editor .cm-ark-variable[data-scope="environment"] {
|
|
129
|
+
background: #ecfeff;
|
|
130
|
+
color: #0e7490;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
93
134
|
### YAML with schema keys and an app formatter
|
|
94
135
|
|
|
95
136
|
```ts
|
|
@@ -113,20 +154,20 @@ editor.addEventListener("ark-format-error", (event) => toast.error(String((event
|
|
|
113
154
|
|
|
114
155
|
Installed automatically unless marked as peer; peer dependencies are yours to install (the ranges are what the package declares).
|
|
115
156
|
|
|
116
|
-
| Package | Version
|
|
117
|
-
| ------------------------------------------------------------------------------------------ |
|
|
118
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.1
|
|
119
|
-
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1
|
|
120
|
-
| [`@codemirror/autocomplete`](https://www.npmjs.com/package/@codemirror/autocomplete) | >=6 (peer)
|
|
121
|
-
| [`@codemirror/commands`](https://www.npmjs.com/package/@codemirror/commands) | >=6 (peer)
|
|
122
|
-
| [`@codemirror/lang-javascript`](https://www.npmjs.com/package/@codemirror/lang-javascript) | >=6 (peer)
|
|
123
|
-
| [`@codemirror/lang-json`](https://www.npmjs.com/package/@codemirror/lang-json) | >=6 (peer)
|
|
124
|
-
| [`@codemirror/lang-yaml`](https://www.npmjs.com/package/@codemirror/lang-yaml) | >=6 (peer)
|
|
125
|
-
| [`@codemirror/language`](https://www.npmjs.com/package/@codemirror/language) | >=6 (peer)
|
|
126
|
-
| [`@codemirror/search`](https://www.npmjs.com/package/@codemirror/search) | >=6 (peer)
|
|
127
|
-
| [`@codemirror/state`](https://www.npmjs.com/package/@codemirror/state) | >=6 (peer)
|
|
128
|
-
| [`@codemirror/view`](https://www.npmjs.com/package/@codemirror/view) | >=6 (peer) | Editor view and DOM |
|
|
129
|
-
| [`@lezer/highlight`](https://www.npmjs.com/package/@lezer/highlight) | >=1 (peer)
|
|
157
|
+
| Package | Version | Description |
|
|
158
|
+
| ------------------------------------------------------------------------------------------ | ------------- | --------------------------------------------------------- |
|
|
159
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.1 | Design tokens (colors, sizes, motion) and primitive types |
|
|
160
|
+
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | TypeScript runtime helpers |
|
|
161
|
+
| [`@codemirror/autocomplete`](https://www.npmjs.com/package/@codemirror/autocomplete) | >=6 (peer) | Completions and bracket closing |
|
|
162
|
+
| [`@codemirror/commands`](https://www.npmjs.com/package/@codemirror/commands) | >=6.6 (peer) | Keymaps, history, indentation commands |
|
|
163
|
+
| [`@codemirror/lang-javascript`](https://www.npmjs.com/package/@codemirror/lang-javascript) | >=6 (peer) | JavaScript language and completions |
|
|
164
|
+
| [`@codemirror/lang-json`](https://www.npmjs.com/package/@codemirror/lang-json) | >=6 (peer) | JSON language |
|
|
165
|
+
| [`@codemirror/lang-yaml`](https://www.npmjs.com/package/@codemirror/lang-yaml) | >=6 (peer) | YAML language |
|
|
166
|
+
| [`@codemirror/language`](https://www.npmjs.com/package/@codemirror/language) | >=6 (peer) | Language support, folding, indentation |
|
|
167
|
+
| [`@codemirror/search`](https://www.npmjs.com/package/@codemirror/search) | >=6 (peer) | Search panel and selection matches |
|
|
168
|
+
| [`@codemirror/state`](https://www.npmjs.com/package/@codemirror/state) | >=6 (peer) | Editor state (one copy per page) |
|
|
169
|
+
| [`@codemirror/view`](https://www.npmjs.com/package/@codemirror/view) | >=6.27 (peer) | Editor view and DOM |
|
|
170
|
+
| [`@lezer/highlight`](https://www.npmjs.com/package/@lezer/highlight) | >=1 (peer) | Syntax highlight tags |
|
|
130
171
|
|
|
131
172
|
---
|
|
132
173
|
|
package/README.pt-BR.md
CHANGED
|
@@ -29,6 +29,7 @@ O pacote `@tooark/code` fornece:
|
|
|
29
29
|
- `language` json / javascript / yaml / text, numeração, dobra, busca (Ctrl+F), pares de colchetes, linha ativa, placeholder, `readonly`, `wrap`, `min-height`;
|
|
30
30
|
- Tab recua (Shift+Tab desfaz; Esc e depois Tab sai do editor), `indent-style` espaços ou tabulação, `indent-size`, `line-ending` `auto`/`lf`/`crlf` convertido na fronteira do valor;
|
|
31
31
|
- completions: as da linguagem, `variableKeys` depois de `{{`, `completions` (palavras em qualquer linguagem) e `completionSource`; `autocomplete="false"` desliga;
|
|
32
|
+
- opcionais, desligados até você passá-los: `variables` pinta cada `{{chave}}` pelo intent da variável (escopo livre, tooltip com escopo e valor), `mark-unknown-variables` marca as chaves não definidas e `single-line` faz do editor um campo de uma linha na altura dos controles (`size`), com Enter emitindo `ark-submit`;
|
|
32
33
|
- `format()` e Shift+Alt+F: JSON de fábrica com o recuo configurado, outras linguagens pelo gancho `formatter` (o Prettier fica no app);
|
|
33
34
|
- chrome sobre os tokens `--ark-color-*` com fallback, `theme="auto"` seguindo a página em tempo de execução; engine `createCodeEditor` sem o elemento;
|
|
34
35
|
- pacotes do CodeMirror como peer dependencies, para a página ter uma cópia de `@codemirror/state`.
|
|
@@ -61,16 +62,30 @@ registerTooarkCode();
|
|
|
61
62
|
|
|
62
63
|
### `ark-code-editor`
|
|
63
64
|
|
|
64
|
-
- Atributos: `language` (`json` | `javascript` | `yaml` | `text`), `readonly`, `placeholder`, `min-height` (padrão `8rem`), `line-numbers` e `fold` (ligados; `"false"` desliga), `wrap`, `indent-style` (`space` | `tab`), `indent-size` (padrão 2), `line-ending` (`auto` | `lf` | `crlf`), `tab-indent` e `autocomplete` (ligados; `"false"` desliga), `theme`, `testid`.
|
|
65
|
-
- Propriedades: `value`, `variableKeys`, `completions`, `completionSource`, `formatter`, `canFormat`, `resolvedLineEnding`, `resolvedTheme`, `view` (o `EditorView`), e uma por atributo exceto `testid`; métodos `format()`, `focus()`.
|
|
66
|
-
- Eventos: `change` (`detail: { value }`, só edições do usuário), `ark-format-error` (`detail: { error }`).
|
|
65
|
+
- Atributos: `language` (`json` | `javascript` | `yaml` | `text`), `readonly`, `placeholder`, `min-height` (padrão `8rem`), `line-numbers` e `fold` (ligados; `"false"` desliga), `wrap`, `indent-style` (`space` | `tab`), `indent-size` (padrão 2), `line-ending` (`auto` | `lf` | `crlf`), `tab-indent` e `autocomplete` (ligados; `"false"` desliga), `mark-unknown-variables`, `single-line`, `size` (`xs` … `xl`, padrão `md`: fonte e recuo lateral, e a altura em `single-line`), `theme`, `testid`.
|
|
66
|
+
- Propriedades: `value`, `variableKeys`, `variables`, `completions`, `completionSource`, `formatter`, `canFormat`, `resolvedLineEnding`, `resolvedTheme`, `view` (o `EditorView`), e uma por atributo exceto `testid`; métodos `format()`, `focus()`.
|
|
67
|
+
- Eventos: `change` (`detail: { value }`, só edições do usuário), `ark-format-error` (`detail: { error }`), `ark-submit` (`detail: { value }`, Enter em `single-line`).
|
|
67
68
|
- Teclas: Ctrl/Cmd+F busca, Ctrl/Cmd+Z desfazer, Ctrl+Y refazer (Cmd+Shift+Z no macOS), Ctrl+Espaço completions, Shift+Alt+F formatar, Tab/Shift+Tab recuo, Esc+Tab sair, Ctrl+M (Shift+Alt+M no macOS) alterna o modo tab-focus do CodeMirror.
|
|
69
|
+
- Hooks: a raiz do CodeMirror leva `data-ark="code-editor"` e o `testid` como `data-testid`; cada variável pintada, `data-ark="code-editor-variable"` com `data-key`; o tooltip dela, `data-ark="code-editor-variable-tooltip"`.
|
|
70
|
+
|
|
71
|
+
### Variáveis com escopo
|
|
72
|
+
|
|
73
|
+
Nada muda até o app passar `variables` ou ligar `mark-unknown-variables`; `variableKeys` sozinho continua só completando.
|
|
74
|
+
|
|
75
|
+
- `variables`: `ArkCodeVariable[]`, um `{ key, scope?, intent?, value? }` por chave. A biblioteca não conhece escopo nenhum: `scope` é o nome que o app usar, e quando uma chave existe em vários escopos o app resolve a precedência e manda só a vencedora (chave repetida fica com a primeira entrada).
|
|
76
|
+
- Cada `{{chave}}` (espaços internos permitidos; chaves com letras, dígitos, `_`, `.`, `-` e `$`) vira `<span class="cm-ark-variable cm-ark-variable-<intent>" data-key data-scope data-intent>` com o fundo e o texto suaves do intent (`--ark-color-<intent>-soft`/`-soft-fg`, padrão `primary`), inclusive dentro de strings JSON, e cada variável fica num span só. Os matizes distintos são `info`, `success`, `warning`/`primary` e `danger` (que também marca as chaves desconhecidas); `secondary` e `neutral` ficam perto da cor do texto. Para mais escopos, ou uma paleta própria, troque as cores de um escopo por CSS, por exemplo `ark-code-editor .cm-ark-variable[data-scope="global"] { background: …; color: … }`.
|
|
77
|
+
- Variável com `scope` ou `value` mostra um tooltip ao passar o mouse, com o escopo (no intent dela) e o valor; a completion depois de `{{` mostra o escopo como detalhe e o valor como info. Todo esse texto é do app: deixe `value` de fora para segredos.
|
|
78
|
+
- `mark-unknown-variables`: o `{{chave}}` que não está em `variables` nem em `variableKeys` ganha `cm-ark-variable-unknown` e `data-unknown`, pintado em `danger` com sublinhado ondulado (não só pela cor).
|
|
79
|
+
|
|
80
|
+
### Campo de uma linha
|
|
81
|
+
|
|
82
|
+
`single-line` faz um campo como a barra de endereço: a altura dos controles do mesmo `size` (alinha com `ark-button` e `ark-input`), sem calhas nem linha ativa, Enter emite `ark-submit` em vez de quebrar a linha (com a lista de completions aberta, o Enter aceita a completion), quebras coladas são removidas como num `<input>`, Tab sai do campo e Ctrl/Cmd+F fica com o navegador. Ligar sobre um texto de várias linhas junta as linhas sem `change`. Variáveis e completions funcionam igual.
|
|
68
83
|
|
|
69
84
|
### Engine
|
|
70
85
|
|
|
71
|
-
- `createCodeEditor(parent, options)` → `{ view, getValue, setValue, setLanguage, setTheme, setReadonly, setPlaceholder, setLineNumbers, setFold, setWrap, setMinHeight, setIndent, setLineEnding, resolvedLineEnding, setTabIndent, setAutocomplete, setVariableKeys, setCompletions, setCompletionSource, setFormatter, format, canFormat, resolvedTheme, focus, destroy }`.
|
|
86
|
+
- `createCodeEditor(parent, options)` → `{ view, getValue, setValue, setLanguage, setTheme, setReadonly, setPlaceholder, setLineNumbers, setFold, setWrap, setMinHeight, setIndent, setLineEnding, resolvedLineEnding, setTabIndent, setAutocomplete, setVariableKeys, setVariables, setMarkUnknownVariables, setSingleLine, setSize, setCompletions, setCompletionSource, setFormatter, format, canFormat, resolvedTheme, focus, destroy }`; as opções espelham atributos e propriedades, mais `onChange`, `onFormatError` e `onSubmit`.
|
|
72
87
|
- `resolveCodeTheme(theme, element)`.
|
|
73
|
-
- Tipos: `ArkCodeEditorInstance`, `ArkCodeEditorOptions`, `ArkCodeLanguage`, `ArkCodeTheme`, `ArkCodeIndentStyle`, `ArkCodeLineEnding`, `ArkCodeCompletion`, `ArkCodeCompletionSource`, `ArkCodeFormatter`.
|
|
88
|
+
- Tipos: `ArkCodeEditorInstance`, `ArkCodeEditorOptions`, `ArkCodeVariable`, `ArkCodeLanguage`, `ArkCodeTheme`, `ArkCodeIndentStyle`, `ArkCodeLineEnding`, `ArkCodeCompletion`, `ArkCodeCompletionSource`, `ArkCodeFormatter`.
|
|
74
89
|
|
|
75
90
|
---
|
|
76
91
|
|
|
@@ -90,6 +105,32 @@ botaoFormatar.hidden = !editor.canFormat;
|
|
|
90
105
|
botaoFormatar.addEventListener("click", () => editor.format()); // também Shift+Alt+F
|
|
91
106
|
```
|
|
92
107
|
|
|
108
|
+
### Um campo de URL com variáveis por escopo
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<ark-code-editor id="url" single-line mark-unknown-variables placeholder="{{baseUrl}}/caminho"></ark-code-editor>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
const url = document.querySelector("ark-code-editor")!;
|
|
116
|
+
// A precedência entre escopos é resolvida pelo app: uma entrada por chave.
|
|
117
|
+
url.variables = [
|
|
118
|
+
{ key: "baseUrl", scope: "global", intent: "info", value: "https://api.exemplo.com" },
|
|
119
|
+
{ key: "token", scope: "environment", intent: "success" }, // sem value: fica fora do tooltip
|
|
120
|
+
{ key: "userId", scope: "local", intent: "primary", value: "42" },
|
|
121
|
+
];
|
|
122
|
+
url.value = "{{baseUrl}}/users/{{userId}}";
|
|
123
|
+
url.addEventListener("ark-submit", (event) => enviar((event as CustomEvent<{ value: string }>).detail.value));
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```css
|
|
127
|
+
/* cor própria para um escopo, em vez de um intent */
|
|
128
|
+
ark-code-editor .cm-ark-variable[data-scope="environment"] {
|
|
129
|
+
background: #ecfeff;
|
|
130
|
+
color: #0e7490;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
93
134
|
### YAML com chaves do schema e formatador do app
|
|
94
135
|
|
|
95
136
|
```ts
|
|
@@ -113,20 +154,20 @@ editor.addEventListener("ark-format-error", (event) => toast.error(String((event
|
|
|
113
154
|
|
|
114
155
|
Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta (os ranges são os que o pacote declara).
|
|
115
156
|
|
|
116
|
-
| Pacote | Versão
|
|
117
|
-
| ------------------------------------------------------------------------------------------ |
|
|
118
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.1
|
|
119
|
-
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1
|
|
120
|
-
| [`@codemirror/autocomplete`](https://www.npmjs.com/package/@codemirror/autocomplete) | >=6 (peer)
|
|
121
|
-
| [`@codemirror/commands`](https://www.npmjs.com/package/@codemirror/commands) | >=6 (peer)
|
|
122
|
-
| [`@codemirror/lang-javascript`](https://www.npmjs.com/package/@codemirror/lang-javascript) | >=6 (peer)
|
|
123
|
-
| [`@codemirror/lang-json`](https://www.npmjs.com/package/@codemirror/lang-json) | >=6 (peer)
|
|
124
|
-
| [`@codemirror/lang-yaml`](https://www.npmjs.com/package/@codemirror/lang-yaml) | >=6 (peer)
|
|
125
|
-
| [`@codemirror/language`](https://www.npmjs.com/package/@codemirror/language) | >=6 (peer)
|
|
126
|
-
| [`@codemirror/search`](https://www.npmjs.com/package/@codemirror/search) | >=6 (peer)
|
|
127
|
-
| [`@codemirror/state`](https://www.npmjs.com/package/@codemirror/state) | >=6 (peer)
|
|
128
|
-
| [`@codemirror/view`](https://www.npmjs.com/package/@codemirror/view) | >=6 (peer) | View e DOM do editor |
|
|
129
|
-
| [`@lezer/highlight`](https://www.npmjs.com/package/@lezer/highlight) | >=1 (peer)
|
|
157
|
+
| Pacote | Versão | Descrição |
|
|
158
|
+
| ------------------------------------------------------------------------------------------ | ------------- | ---------------------------------------------------------- |
|
|
159
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.1 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
|
|
160
|
+
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | Helpers de runtime do TypeScript |
|
|
161
|
+
| [`@codemirror/autocomplete`](https://www.npmjs.com/package/@codemirror/autocomplete) | >=6 (peer) | Completions e fechamento de pares |
|
|
162
|
+
| [`@codemirror/commands`](https://www.npmjs.com/package/@codemirror/commands) | >=6.6 (peer) | Atalhos, histórico, comandos de recuo |
|
|
163
|
+
| [`@codemirror/lang-javascript`](https://www.npmjs.com/package/@codemirror/lang-javascript) | >=6 (peer) | Linguagem JavaScript e completions |
|
|
164
|
+
| [`@codemirror/lang-json`](https://www.npmjs.com/package/@codemirror/lang-json) | >=6 (peer) | Linguagem JSON |
|
|
165
|
+
| [`@codemirror/lang-yaml`](https://www.npmjs.com/package/@codemirror/lang-yaml) | >=6 (peer) | Linguagem YAML |
|
|
166
|
+
| [`@codemirror/language`](https://www.npmjs.com/package/@codemirror/language) | >=6 (peer) | Suporte a linguagens, dobra, recuo |
|
|
167
|
+
| [`@codemirror/search`](https://www.npmjs.com/package/@codemirror/search) | >=6 (peer) | Painel de busca e ocorrências da seleção |
|
|
168
|
+
| [`@codemirror/state`](https://www.npmjs.com/package/@codemirror/state) | >=6 (peer) | Estado do editor (uma cópia por página) |
|
|
169
|
+
| [`@codemirror/view`](https://www.npmjs.com/package/@codemirror/view) | >=6.27 (peer) | View e DOM do editor |
|
|
170
|
+
| [`@lezer/highlight`](https://www.npmjs.com/package/@lezer/highlight) | >=1 (peer) | Tags de realce de sintaxe |
|
|
130
171
|
|
|
131
172
|
---
|
|
132
173
|
|