@tooark/code 1.6.0 → 1.7.0
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 +9 -9
- package/README.pt-BR.md +9 -9
- package/dist/index.cjs +43 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +43 -6
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
|
|
29
29
|
The `@tooark/code` package provides:
|
|
30
30
|
|
|
31
|
-
- `language` json / javascript / yaml / text, line numbers, folding, search (Ctrl+F), bracket matching, active line, placeholder, `readonly`, `wrap`, `min-height
|
|
31
|
+
- `language` json / javascript / yaml / text, line numbers, folding, search (Ctrl+F), bracket matching, active line, placeholder, `readonly`, `wrap`, `min-height` and `max-height` (internal scrolling above it);
|
|
32
32
|
- 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;
|
|
33
33
|
- completions: the language's own, `variableKeys` after `{{`, `completions` (words in any language) and `completionSource`; `autocomplete="false"` turns them off;
|
|
34
34
|
- 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, `single-line` turns the editor into a one-line field at control height (`size`), Enter emitting `ark-submit`, and `extensions` adds your own CodeMirror extensions after the library's (a grammar it does not ship, a blame gutter, decorations);
|
|
35
35
|
- `format()` and Shift+Alt+F: JSON built in with the configured indentation, other languages through the `formatter` hook (Prettier stays in the app);
|
|
36
|
-
- chrome on the `--ark-color-*` tokens with fallbacks, `theme="auto"` following the page at runtime; `createCodeEditor` engine without the element;
|
|
36
|
+
- chrome on the `--ark-color-*` tokens and syntax on the `--ark-syntax-*` tokens, both with fallbacks, `theme="auto"` following the page at runtime; `createCodeEditor` engine without the element;
|
|
37
37
|
- CodeMirror packages as peer dependencies, so the page keeps one copy of `@codemirror/state`.
|
|
38
38
|
|
|
39
39
|
---
|
|
@@ -50,7 +50,7 @@ The CodeMirror packages are peer dependencies: your page keeps a single copy of
|
|
|
50
50
|
|
|
51
51
|
## ⚙️ Configuration
|
|
52
52
|
|
|
53
|
-
Register the element once; the editor styles itself through CodeMirror themes that read the `--ark-color-*` tokens (with fallbacks, so it works without `@tooark/web-components
|
|
53
|
+
Register the element once; the editor styles itself through CodeMirror themes that read the `--ark-color-*` tokens for the chrome and the `--ark-syntax-*` tokens for the syntax colors (`keyword`, `string`, `number`, `property`, `comment`, `atom`, `punctuation`, `invalid`), with fallbacks, so it works without `@tooark/web-components`; override a `--ark-syntax-*` token on an ancestor to retheme the syntax:
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
56
|
import { registerTooarkCode } from "@tooark/code";
|
|
@@ -66,7 +66,7 @@ In React, Vue or Angular use the tag directly (the framework READMEs show how);
|
|
|
66
66
|
|
|
67
67
|
### `ark-code-editor`
|
|
68
68
|
|
|
69
|
-
- 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`, `aria-label` (names the editable content, CodeMirror's `role="textbox"`), `testid`.
|
|
69
|
+
- Attributes: `language` (`json` | `javascript` | `yaml` | `text`), `readonly`, `placeholder`, `min-height` (default `8rem`), `max-height` (off by default; above it the content scrolls inside the editor with the gutters; `min-height` wins when larger, `single-line` ignores it), `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`, `aria-label` (names the editable content, CodeMirror's `role="textbox"`), `testid`.
|
|
70
70
|
- Properties: `value`, `variableKeys`, `variables`, `completions`, `completionSource`, `formatter`, `extensions`, `canFormat`, `resolvedLineEnding`, `resolvedTheme`, `view` (the `EditorView`), and one per attribute except `aria-label` and `testid`; methods `format()`, `focus()`.
|
|
71
71
|
- Events: `change` (`detail: { value }`, user edits only), `ark-format-error` (`detail: { error }`), `ark-submit` (`detail: { value }`, Enter in `single-line`).
|
|
72
72
|
- 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.
|
|
@@ -131,7 +131,7 @@ const url = document.querySelector("ark-code-editor")!;
|
|
|
131
131
|
url.variables = [
|
|
132
132
|
{ key: "baseUrl", scope: "global", intent: "info", value: "https://api.example.com" },
|
|
133
133
|
{ key: "token", scope: "environment", intent: "success" }, // no value: kept out of the tooltip
|
|
134
|
-
{ key: "userId", scope: "local", intent: "primary", value: "42" }
|
|
134
|
+
{ key: "userId", scope: "local", intent: "primary", value: "42" }
|
|
135
135
|
];
|
|
136
136
|
url.value = "{{baseUrl}}/users/{{userId}}";
|
|
137
137
|
url.addEventListener("ark-submit", (event) => send((event as CustomEvent<{ value: string }>).detail.value));
|
|
@@ -156,7 +156,7 @@ editor.setAttribute("line-ending", "lf");
|
|
|
156
156
|
editor.completions = [
|
|
157
157
|
{ label: "apiVersion", type: "keyword" },
|
|
158
158
|
{ label: "kind", type: "keyword" },
|
|
159
|
-
{ label: "metadata" }
|
|
159
|
+
{ label: "metadata" }
|
|
160
160
|
];
|
|
161
161
|
editor.formatter = (value) => dump(load(value), { indent: editor.indentSize });
|
|
162
162
|
editor.addEventListener("ark-format-error", (event) => toast.error(String((event as CustomEvent).detail.error)));
|
|
@@ -186,7 +186,7 @@ const blame = gutter({
|
|
|
186
186
|
lineMarker: (view, line) => {
|
|
187
187
|
const author = file.blame.get(view.state.doc.lineAt(line.from).number);
|
|
188
188
|
return author ? new Author(author) : null;
|
|
189
|
-
}
|
|
189
|
+
}
|
|
190
190
|
});
|
|
191
191
|
viewer.extensions = [grammar ?? [], Prec.high(blame)]; // Prec.high: left of the line numbers
|
|
192
192
|
viewer.value = file.content;
|
|
@@ -200,8 +200,8 @@ Installed automatically unless marked as peer; peer dependencies are yours to in
|
|
|
200
200
|
|
|
201
201
|
| Package | Version | Description |
|
|
202
202
|
| ------------------------------------------------------------------------------------------ | ------------- | --------------------------------------------------------- |
|
|
203
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.
|
|
204
|
-
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.
|
|
203
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.7.0 | Design tokens (colors, sizes, motion) and primitive types |
|
|
204
|
+
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.9.1 | TypeScript runtime helpers |
|
|
205
205
|
| [`@codemirror/autocomplete`](https://www.npmjs.com/package/@codemirror/autocomplete) | >=6 (peer) | Completions and bracket closing |
|
|
206
206
|
| [`@codemirror/commands`](https://www.npmjs.com/package/@codemirror/commands) | >=6.6 (peer) | Keymaps, history, indentation commands |
|
|
207
207
|
| [`@codemirror/lang-javascript`](https://www.npmjs.com/package/@codemirror/lang-javascript) | >=6 (peer) | JavaScript language and completions |
|
package/README.pt-BR.md
CHANGED
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
|
|
29
29
|
O pacote `@tooark/code` fornece:
|
|
30
30
|
|
|
31
|
-
- `language` json / javascript / yaml / text, numeração, dobra, busca (Ctrl+F), pares de colchetes, linha ativa, placeholder, `readonly`, `wrap`, `min-height
|
|
31
|
+
- `language` json / javascript / yaml / text, numeração, dobra, busca (Ctrl+F), pares de colchetes, linha ativa, placeholder, `readonly`, `wrap`, `min-height` e `max-height` (rolagem interna acima dele);
|
|
32
32
|
- 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;
|
|
33
33
|
- completions: as da linguagem, `variableKeys` depois de `{{`, `completions` (palavras em qualquer linguagem) e `completionSource`; `autocomplete="false"` desliga;
|
|
34
34
|
- 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, `single-line` faz do editor um campo de uma linha na altura dos controles (`size`), com Enter emitindo `ark-submit`, e `extensions` soma extensões do CodeMirror suas depois das da biblioteca (uma gramática que ela não traz, uma calha de blame, decorações);
|
|
35
35
|
- `format()` e Shift+Alt+F: JSON de fábrica com o recuo configurado, outras linguagens pelo gancho `formatter` (o Prettier fica no app);
|
|
36
|
-
- chrome sobre os tokens `--ark-color-*` com fallback, `theme="auto"` seguindo a página em tempo de execução; engine `createCodeEditor` sem o elemento;
|
|
36
|
+
- chrome sobre os tokens `--ark-color-*` e sintaxe sobre os tokens `--ark-syntax-*`, ambos com fallback, `theme="auto"` seguindo a página em tempo de execução; engine `createCodeEditor` sem o elemento;
|
|
37
37
|
- pacotes do CodeMirror como peer dependencies, para a página ter uma cópia de `@codemirror/state`.
|
|
38
38
|
|
|
39
39
|
---
|
|
@@ -50,7 +50,7 @@ Os pacotes do CodeMirror são peer dependencies: a página fica com uma única c
|
|
|
50
50
|
|
|
51
51
|
## ⚙️ Configuração
|
|
52
52
|
|
|
53
|
-
Registre o elemento uma vez; o editor se estiliza por temas do CodeMirror que leem os tokens `--ark-color-*` (com fallback, então funciona sem o `@tooark/web-components
|
|
53
|
+
Registre o elemento uma vez; o editor se estiliza por temas do CodeMirror que leem os tokens `--ark-color-*` no chrome e os tokens `--ark-syntax-*` nas cores de sintaxe (`keyword`, `string`, `number`, `property`, `comment`, `atom`, `punctuation`, `invalid`), com fallback, então funciona sem o `@tooark/web-components`; sobrescreva um token `--ark-syntax-*` num ancestral para tematizar a sintaxe:
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
56
|
import { registerTooarkCode } from "@tooark/code";
|
|
@@ -66,7 +66,7 @@ Em React, Vue ou Angular use a tag diretamente (os READMEs dos wrappers mostram
|
|
|
66
66
|
|
|
67
67
|
### `ark-code-editor`
|
|
68
68
|
|
|
69
|
-
- 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`, `aria-label` (nomeia o conteúdo editável, o `role="textbox"` do CodeMirror), `testid`.
|
|
69
|
+
- Atributos: `language` (`json` | `javascript` | `yaml` | `text`), `readonly`, `placeholder`, `min-height` (padrão `8rem`), `max-height` (desligado por padrão; acima dele o conteúdo rola dentro do editor com as calhas; o `min-height` vence quando maior, `single-line` o ignora), `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`, `aria-label` (nomeia o conteúdo editável, o `role="textbox"` do CodeMirror), `testid`.
|
|
70
70
|
- Propriedades: `value`, `variableKeys`, `variables`, `completions`, `completionSource`, `formatter`, `extensions`, `canFormat`, `resolvedLineEnding`, `resolvedTheme`, `view` (o `EditorView`), e uma por atributo exceto `aria-label` e `testid`; métodos `format()`, `focus()`.
|
|
71
71
|
- Eventos: `change` (`detail: { value }`, só edições do usuário), `ark-format-error` (`detail: { error }`), `ark-submit` (`detail: { value }`, Enter em `single-line`).
|
|
72
72
|
- 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.
|
|
@@ -131,7 +131,7 @@ const url = document.querySelector("ark-code-editor")!;
|
|
|
131
131
|
url.variables = [
|
|
132
132
|
{ key: "baseUrl", scope: "global", intent: "info", value: "https://api.exemplo.com" },
|
|
133
133
|
{ key: "token", scope: "environment", intent: "success" }, // sem value: fica fora do tooltip
|
|
134
|
-
{ key: "userId", scope: "local", intent: "primary", value: "42" }
|
|
134
|
+
{ key: "userId", scope: "local", intent: "primary", value: "42" }
|
|
135
135
|
];
|
|
136
136
|
url.value = "{{baseUrl}}/users/{{userId}}";
|
|
137
137
|
url.addEventListener("ark-submit", (event) => enviar((event as CustomEvent<{ value: string }>).detail.value));
|
|
@@ -156,7 +156,7 @@ editor.setAttribute("line-ending", "lf");
|
|
|
156
156
|
editor.completions = [
|
|
157
157
|
{ label: "apiVersion", type: "keyword" },
|
|
158
158
|
{ label: "kind", type: "keyword" },
|
|
159
|
-
{ label: "metadata" }
|
|
159
|
+
{ label: "metadata" }
|
|
160
160
|
];
|
|
161
161
|
editor.formatter = (value) => dump(load(value), { indent: editor.indentSize });
|
|
162
162
|
editor.addEventListener("ark-format-error", (event) => toast.error(String((event as CustomEvent).detail.error)));
|
|
@@ -186,7 +186,7 @@ const blame = gutter({
|
|
|
186
186
|
lineMarker: (view, line) => {
|
|
187
187
|
const autor = arquivo.blame.get(view.state.doc.lineAt(line.from).number);
|
|
188
188
|
return autor ? new Autor(autor) : null;
|
|
189
|
-
}
|
|
189
|
+
}
|
|
190
190
|
});
|
|
191
191
|
viewer.extensions = [gramatica ?? [], Prec.high(blame)]; // Prec.high: à esquerda da numeração
|
|
192
192
|
viewer.value = arquivo.conteudo;
|
|
@@ -200,8 +200,8 @@ Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta
|
|
|
200
200
|
|
|
201
201
|
| Pacote | Versão | Descrição |
|
|
202
202
|
| ------------------------------------------------------------------------------------------ | ------------- | ---------------------------------------------------------- |
|
|
203
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.
|
|
204
|
-
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.
|
|
203
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.7.0 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
|
|
204
|
+
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.9.1 | Helpers de runtime do TypeScript |
|
|
205
205
|
| [`@codemirror/autocomplete`](https://www.npmjs.com/package/@codemirror/autocomplete) | >=6 (peer) | Completions e fechamento de pares |
|
|
206
206
|
| [`@codemirror/commands`](https://www.npmjs.com/package/@codemirror/commands) | >=6.6 (peer) | Atalhos, histórico, comandos de recuo |
|
|
207
207
|
| [`@codemirror/lang-javascript`](https://www.npmjs.com/package/@codemirror/lang-javascript) | >=6 (peer) | Linguagem JavaScript e completions |
|
package/dist/index.cjs
CHANGED
|
@@ -21,8 +21,9 @@ function resolveCodeTheme(theme, element) {
|
|
|
21
21
|
return tokens.resolveColorScheme(element);
|
|
22
22
|
}
|
|
23
23
|
// --- Tema ---
|
|
24
|
-
// Cores de sintaxe por lado
|
|
25
|
-
//
|
|
24
|
+
// Cores de sintaxe por lado, fallback dos tokens --ark-syntax-* (os mesmos valores, em light-dark() no tokens.css); o
|
|
25
|
+
// chrome (fundo, texto, bordas, seleção) vem dos tokens --ark-color-* com fallback, para o editor seguir o tema do app
|
|
26
|
+
// mesmo sem o CSS do @tooark/web-components na página.
|
|
26
27
|
const SYNTAX = {
|
|
27
28
|
light: {
|
|
28
29
|
keyword: "#6d28d9",
|
|
@@ -104,12 +105,16 @@ function chromeTheme(side) {
|
|
|
104
105
|
border: `1px solid ${v("border", f.border)}`,
|
|
105
106
|
borderRadius: "0.5rem",
|
|
106
107
|
fontSize: "var(--ark-code-font-size, 0.875rem)",
|
|
107
|
-
minHeight: "var(--ark-code-min-height, 8rem)"
|
|
108
|
+
minHeight: "var(--ark-code-min-height, 8rem)",
|
|
109
|
+
// Sem `max-height` a variável não existe e o editor cresce com o conteúdo; com ela o scroller do CodeMirror
|
|
110
|
+
// (overflow-x auto, logo também y) rola por dentro.
|
|
111
|
+
maxHeight: "var(--ark-code-max-height, none)"
|
|
108
112
|
},
|
|
109
113
|
// Uma linha na altura do controle: a borda (2px) e a linha (1.5em) saem da altura, o resto vira respiro
|
|
110
114
|
// vertical do conteúdo, que ocupa a caixa toda (o clique em qualquer ponto posiciona o cursor).
|
|
111
115
|
"&.cm-ark-single-line": {
|
|
112
|
-
minHeight: "var(--ark-code-control-height, 2.25rem)"
|
|
116
|
+
minHeight: "var(--ark-code-control-height, 2.25rem)",
|
|
117
|
+
maxHeight: "none"
|
|
113
118
|
},
|
|
114
119
|
"&.cm-ark-single-line .cm-scroller": {
|
|
115
120
|
minHeight: "0",
|
|
@@ -258,7 +263,9 @@ function chromeTheme(side) {
|
|
|
258
263
|
}, { dark: side === "dark" });
|
|
259
264
|
}
|
|
260
265
|
function syntaxTheme(side) {
|
|
261
|
-
|
|
266
|
+
// Cada papel lê o token do app; sem ele, a cor embutida do lado. O light-dark() do token resolve pelo color-scheme
|
|
267
|
+
// que o editor declara, então um tema fixo (`theme="dark"` numa página clara) pega o lado certo.
|
|
268
|
+
const c = Object.fromEntries(Object.entries(SYNTAX[side]).map(([role, color]) => [role, `var(--ark-syntax-${role}, ${color})`]));
|
|
262
269
|
return language.syntaxHighlighting(language.HighlightStyle.define([
|
|
263
270
|
{ tag: [highlight.tags.keyword, highlight.tags.modifier, highlight.tags.operatorKeyword, highlight.tags.controlKeyword], color: c.keyword },
|
|
264
271
|
{ tag: [highlight.tags.string, highlight.tags.special(highlight.tags.string)], color: c.string },
|
|
@@ -656,6 +663,15 @@ function createCodeEditor(parent, options = {}) {
|
|
|
656
663
|
});
|
|
657
664
|
const view$1 = new view.EditorView({ state: state$1, parent });
|
|
658
665
|
view$1.dom.style.setProperty("--ark-code-min-height", options.minHeight ?? "8rem");
|
|
666
|
+
const applyMaxHeight = (value) => {
|
|
667
|
+
if (value?.trim()) {
|
|
668
|
+
view$1.dom.style.setProperty("--ark-code-max-height", value.trim());
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
view$1.dom.style.removeProperty("--ark-code-max-height");
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
applyMaxHeight(options.maxHeight);
|
|
659
675
|
applySize(normalizeSize(options.size));
|
|
660
676
|
return {
|
|
661
677
|
view: view$1,
|
|
@@ -700,6 +716,7 @@ function createCodeEditor(parent, options = {}) {
|
|
|
700
716
|
},
|
|
701
717
|
setWrap: (on) => view$1.dispatch({ effects: wrapping.reconfigure(on ? view.EditorView.lineWrapping : []) }),
|
|
702
718
|
setMinHeight: (value) => view$1.dom.style.setProperty("--ark-code-min-height", value),
|
|
719
|
+
setMaxHeight: applyMaxHeight,
|
|
703
720
|
setIndent: (style, size) => {
|
|
704
721
|
indentStyle = style;
|
|
705
722
|
indentSize = size;
|
|
@@ -832,7 +849,8 @@ const NO_EXTENSIONS = [];
|
|
|
832
849
|
* O texto vai pela propriedade `value` (ou pelo atributo `value` como valor
|
|
833
850
|
* inicial) e volta em `change` com `detail: { value }` a cada edição do
|
|
834
851
|
* usuário. Atributos: `language` (json | javascript | yaml | text),
|
|
835
|
-
* `readonly`, `placeholder`, `min-height` (
|
|
852
|
+
* `readonly`, `placeholder`, `min-height` e `max-height` (comprimentos CSS;
|
|
853
|
+
* acima da máxima o conteúdo rola por dentro), `line-numbers`,
|
|
836
854
|
* `fold`, `tab-indent` e `autocomplete` (ligados por padrão; "false"
|
|
837
855
|
* desliga), `wrap`, `indent-style` (space | tab), `indent-size`,
|
|
838
856
|
* `line-ending` (lf | crlf | auto), `theme` (auto | light | dark),
|
|
@@ -874,6 +892,7 @@ class ArkCodeEditor extends HTMLElementBase {
|
|
|
874
892
|
"readonly",
|
|
875
893
|
"placeholder",
|
|
876
894
|
"min-height",
|
|
895
|
+
"max-height",
|
|
877
896
|
"line-numbers",
|
|
878
897
|
"fold",
|
|
879
898
|
"wrap",
|
|
@@ -1076,6 +1095,21 @@ class ArkCodeEditor extends HTMLElementBase {
|
|
|
1076
1095
|
this.removeAttribute("min-height");
|
|
1077
1096
|
}
|
|
1078
1097
|
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Altura máxima do editor (atributo `max-height`, comprimento CSS): acima dela o conteúdo rola dentro do editor.
|
|
1100
|
+
* Ignorada em `single-line`. Padrão: "" (sem limite, cresce com o conteúdo).
|
|
1101
|
+
*/
|
|
1102
|
+
get maxHeight() {
|
|
1103
|
+
return this.getAttribute("max-height")?.trim() || "";
|
|
1104
|
+
}
|
|
1105
|
+
set maxHeight(value) {
|
|
1106
|
+
if (value) {
|
|
1107
|
+
this.setAttribute("max-height", value);
|
|
1108
|
+
}
|
|
1109
|
+
else {
|
|
1110
|
+
this.removeAttribute("max-height");
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1079
1113
|
get theme() {
|
|
1080
1114
|
const value = (this.getAttribute("theme") || "auto").toLowerCase();
|
|
1081
1115
|
return value === "light" || value === "dark" ? value : "auto";
|
|
@@ -1115,6 +1149,8 @@ class ArkCodeEditor extends HTMLElementBase {
|
|
|
1115
1149
|
this.instance.setLabel(newValue || undefined);
|
|
1116
1150
|
if (name === "min-height")
|
|
1117
1151
|
this.instance.setMinHeight(this.minHeight);
|
|
1152
|
+
if (name === "max-height")
|
|
1153
|
+
this.instance.setMaxHeight(this.maxHeight);
|
|
1118
1154
|
if (name === "line-numbers")
|
|
1119
1155
|
this.instance.setLineNumbers(this.lineNumbers);
|
|
1120
1156
|
if (name === "fold")
|
|
@@ -1168,6 +1204,7 @@ class ArkCodeEditor extends HTMLElementBase {
|
|
|
1168
1204
|
fold: this.fold,
|
|
1169
1205
|
wrap: this.wrap,
|
|
1170
1206
|
minHeight: this.minHeight,
|
|
1207
|
+
maxHeight: this.maxHeight || undefined,
|
|
1171
1208
|
indentStyle: this.indentStyle,
|
|
1172
1209
|
indentSize: this.indentSize,
|
|
1173
1210
|
lineEnding: this.lineEnding,
|