@pngwasi/config-editor-react 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +689 -2
- package/dist/index.d.ts +162 -0
- package/dist/index.js +45 -0
- package/package.json +50 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Paradoxe Ngwasi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,690 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Config Editor for React
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React component for [`@pngwasi/config-editor`](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor):
|
|
4
|
+
a fast, schema-aware YAML, JSON, TOML, HCL and XML (or your own language) editor running as WebAssembly,
|
|
5
|
+
with completion from a JSON Schema, hover docs, validation, a diff gutter,
|
|
6
|
+
editing one language as another, and eleven themes.
|
|
7
|
+
|
|
8
|
+
<!-- toc -->
|
|
9
|
+
|
|
10
|
+
## Contents
|
|
11
|
+
|
|
12
|
+
- [Install](#install)
|
|
13
|
+
- [Quick start](#quick-start)
|
|
14
|
+
- [`<ConfigEditor>` props](#configeditor-props)
|
|
15
|
+
- [Settings](#settings)
|
|
16
|
+
- [Ref](#ref)
|
|
17
|
+
- [Saving](#saving)
|
|
18
|
+
- [Several documents](#several-documents)
|
|
19
|
+
- [Keyboard and screen readers](#keyboard-and-screen-readers)
|
|
20
|
+
- [Exports](#exports)
|
|
21
|
+
- [License](#license)
|
|
22
|
+
|
|
23
|
+
<!-- /toc -->
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install @pngwasi/config-editor-react @pngwasi/config-editor
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`@pngwasi/config-editor` is a peer dependency. React 18 or 19. Its
|
|
32
|
+
WebAssembly is built with every feature of the Rust crate.
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useState } from "react";
|
|
38
|
+
import { ConfigEditor } from "@pngwasi/config-editor-react";
|
|
39
|
+
|
|
40
|
+
function Settings({ schema }: { schema: string }) {
|
|
41
|
+
const [text, setText] = useState("listen: 7835\n");
|
|
42
|
+
return (
|
|
43
|
+
<ConfigEditor
|
|
44
|
+
language="yaml"
|
|
45
|
+
schema={schema}
|
|
46
|
+
value={text}
|
|
47
|
+
onChange={setText}
|
|
48
|
+
showToolbar
|
|
49
|
+
showFooter
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The component loads the WebAssembly itself on first mount. To start the
|
|
56
|
+
download earlier, or when your bundler does not serve the `.wasm` next to
|
|
57
|
+
the package's JavaScript, call `loadConfigEditor` (from `@pngwasi/config-editor`) first:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { loadConfigEditor } from "@pngwasi/config-editor";
|
|
61
|
+
// Vite
|
|
62
|
+
import wasmUrl from "@pngwasi/config-editor/config_editor_bg.wasm?url";
|
|
63
|
+
|
|
64
|
+
loadConfigEditor({ module_or_path: wasmUrl });
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## `<ConfigEditor>` props
|
|
68
|
+
|
|
69
|
+
The props are the document and its callbacks (below) and every
|
|
70
|
+
[setting](#settings) (`theme`, `showFooter`, `folding`, …): `ConfigEditorProps`
|
|
71
|
+
extends the generated `EditorSettings` type.
|
|
72
|
+
|
|
73
|
+
| Prop | Type | Default | Purpose |
|
|
74
|
+
| -------------------- | ------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
75
|
+
| `value` | `string` | — | The document (controlled). |
|
|
76
|
+
| `defaultValue` | `string` | `""` | The initial document when uncontrolled. |
|
|
77
|
+
| `onChange` | `(value: string) => void` | — | Called with the document after every edit (after each typing pause while editing as another language). |
|
|
78
|
+
| `language` | `string` | `"yaml"` | `"yaml"`, `"json"`, `"toml"`, `"hcl"`, `"xml"`, or a registered one. `value`, `baseline` and `onChange` are always in it. |
|
|
79
|
+
| `editAs` | `string \| null` | — | Show and edit the document in another language; it is saved back in `language`, keeping its comments. |
|
|
80
|
+
| `onEditAsChange` | `(language: string) => void` | — | Called with the language on screen: once on mount, then each time an `editAs` switch completes and when undo or redo steps back across one (a switch is an undo step). A switch waits while the document cannot convert (e.g. a `null` to TOML): until then the host's language stays on screen and reaches `onChange` as it is, with the reason on the value in the way. Label the language shown from this, not from `editAs`. |
|
|
81
|
+
| `onSyncChange` | `(inSync: boolean) => void` | — | Called with whether the text on screen is written back to the document: once on mount, then each time that changes. `false` while an `editAs` edit cannot convert back (`onChange` waits), whatever brought it there (typing, paste, undo, a switch, a reload, a new value). Always `true` in `language`. |
|
|
82
|
+
| `onChangeSummary` | `(summary: ChangeSummary) => void` | — | Called with `{ added, removed, modified, hunks }` against `baseline`, on mount and whenever it changes. |
|
|
83
|
+
| `onProblems` | `(problems: Diagnostic[]) => void` | — | Called with the editor's own problems (syntax, schema, secret placeholders, values Edit-as cannot convert; `origin: "editor"`), never `hostDiagnostics`: once on mount, then each time they change after a pause in typing, not while they stay the same. With `showDiagnostics` off it finds none. To gate a Save button, use what the handle's `save()` returns, not an `error` here: a lone CR in a TOML or HCL text is shown as an `error` and still saves. |
|
|
84
|
+
| `onPathChange` | `(path: EditorPath) => void` | — | Called with the path of what the caret is on (`{ pointer: "/web/listen", segments: ["web", "listen"] }`) each time it changes, for a breadcrumb. The path is computed only while this is set. |
|
|
85
|
+
| `hostDiagnostics` | `HostDiagnostic[]` | — | Problems the host found (its own checks: a service, a build step): `{ path \| range, severity?, message, code?, source?, docsUrl? }`, shown with the editor's own; see the [`@pngwasi/config-editor` README](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#host-diagnostics). Updates live; only the markers change. |
|
|
86
|
+
| `readOnlyPaths` | `FieldPath[]` | — | Fields the user cannot change (each a whole subtree), on top of the schema's `readOnly` ones; they hold with `editAs` too. See the [`@pngwasi/config-editor` README](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#read-only-fields). Updates live. |
|
|
87
|
+
| `readOnlyRanges` | `TextRangeInput[]` | — | Stretches of the document (in `language`) the user cannot change: `{ start, end }` or `{ startLine, startColumn, endLine?, endColumn? }`. Updates live. |
|
|
88
|
+
| `secrets` | `SecretOptions` | defaults | `{ placeholder?, isPlaceholder?, hint?, referencePrefixes? }`: secret placeholders (`«secret 3f2a»`) in `writeOnly` / `x-secret` fields stay atomic and are kept unless replaced, each real only in the field the host gave it in; see the [`@pngwasi/config-editor` README](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#secrets). Changing `placeholder`, `hint` or `referencePrefixes`, or adding or removing `isPlaceholder`, re-mounts; a new `isPlaceholder` function in its place does not. |
|
|
89
|
+
| `schema` | `string` | — | JSON Schema as JSON or YAML text: completion, hover docs and validation. |
|
|
90
|
+
| `onSchemaWarning` | `(message: string) => void` | console warning | Called once per thing in `schema` the editor cannot use, such as a `patternProperties` regex its engine cannot compile. |
|
|
91
|
+
| `baseline` | `string` | initial value | Text the diff gutter compares against: the version last saved or loaded. A new one under unsaved edits asks the user (Reload / Keep mine). |
|
|
92
|
+
| `onSave` | `(value: string, language: string) => void` | — | Called on `Ctrl+S` / `Cmd+S` (the browser's dialog prevented) and `ref.save()`, with the document in `language`. Nothing saves by itself. Without it, `Ctrl+S` is the browser's. |
|
|
93
|
+
| `onDirtyChange` | `(dirty: boolean) => void` | — | Called with whether the document differs from `baseline`: once on mount, then each time that changes. |
|
|
94
|
+
| `onBaselineConflict` | `(event: BaselineConflict) => void` | — | Called when a new `baseline` arrives under unsaved edits (`"opened"`) and when that is settled (`"reloaded"`, `"kept-mine"`, `"settled"`). |
|
|
95
|
+
| `readOnly` | `boolean` | `false` | View mode. |
|
|
96
|
+
| `readOnlyReason` | `string` | — | Why the editor is read-only, while `readOnly` is on: the "Cannot edit in a read-only editor" notice says it, and so does the text area's accessible description. Updates live. |
|
|
97
|
+
| `fileName` | `string` | `untitled.<ext>` | Shown in the toolbar. |
|
|
98
|
+
| `editorClassName` | `string` | — | Class on the editor root. |
|
|
99
|
+
| `className`, `style` | | — | Class and style of the container `<div>`. |
|
|
100
|
+
| `onError` | `(error: unknown) => void` | `console.error` | Errors from loading or from a prop the editor rejects (unknown language, theme or color token, invalid schema). They never unmount your tree. |
|
|
101
|
+
|
|
102
|
+
`value`, `editAs`, `readOnly`, `baseline`, `hostDiagnostics`,
|
|
103
|
+
`readOnlyPaths`, `readOnlyRanges`, every setting, `onPathChange`, `onSave` and
|
|
104
|
+
the other callbacks update the live editor (the caret, undo history and folds
|
|
105
|
+
stay). `language`, `schema`, `fileName`, `editorClassName` and the `secrets`
|
|
106
|
+
patterns re-create it; the document and its diff baseline carry over (and
|
|
107
|
+
the caret, when the editor had focus), undo history starts over. The
|
|
108
|
+
component is a thin wrapper around `EditorBinding` from
|
|
109
|
+
`@pngwasi/config-editor`, shared with the
|
|
110
|
+
[Vue](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor-vue) and
|
|
111
|
+
[Svelte](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor-svelte)
|
|
112
|
+
packages: the three behave the same.
|
|
113
|
+
|
|
114
|
+
### Settings
|
|
115
|
+
|
|
116
|
+
The theme, the colors and every on/off switch, each a prop with a default;
|
|
117
|
+
the type (`EditorSettings`) is generated from the Rust crate's struct.
|
|
118
|
+
Changing one applies live, and one no longer passed returns to its
|
|
119
|
+
default.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
// A plain viewer: no colors, no diff, no suggestions, no popups.
|
|
123
|
+
<ConfigEditor
|
|
124
|
+
value={text}
|
|
125
|
+
readOnly
|
|
126
|
+
highlighting={false}
|
|
127
|
+
showDiff={false}
|
|
128
|
+
completions={false}
|
|
129
|
+
hoverDocs={false}
|
|
130
|
+
showDiagnostics={false}
|
|
131
|
+
/>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Sticky scroll is on by default: while the text scrolls, the lines that open
|
|
135
|
+
the blocks around the top line (parent keys, tables, elements) stay at the
|
|
136
|
+
top, as in VS Code, and a click on one scrolls back to it.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
<ConfigEditor value={text} stickyScrollMaxLines={3} /> // at most three lines
|
|
140
|
+
<ConfigEditor value={text} stickyScroll={false} /> // off
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
<!-- settings:start -->
|
|
144
|
+
|
|
145
|
+
<!-- Generated from crates/config-editor-leptos/src/settings.rs by js/config-editor/tests/settings.rs; do not edit. Regenerate with `UPDATE_GENERATED=1 cargo test -p config-editor-js --test settings`. -->
|
|
146
|
+
|
|
147
|
+
| Setting | Default | |
|
|
148
|
+
| ------------------------ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
149
|
+
| `theme` | `"vscode-dark"` | The bundled color theme. |
|
|
150
|
+
| `colors` | none | Colors overriding the theme's, by token (`bg`, `key`, `string`, `selection`, …), for a custom palette. |
|
|
151
|
+
| `styled` | `true` | Inject the preset stylesheet. Off, serve it as a file (`preset.css` in the crate and the npm package, as a strict Content-Security-Policy needs) or style the `config-editor__*` markup yourself (the preset is `PRESET_CSS`, `presetCss()` in JavaScript). |
|
|
152
|
+
| `showToolbar` | `false` | Show the built-in toolbar: the file name, its language and the schema's state. |
|
|
153
|
+
| `showFooter` | `false` | Show the built-in status footer: the suggestions hint, problem and change counts, and the line count. |
|
|
154
|
+
| `showDiagnostics` | `true` | Show syntax and schema problems inline, in the footer and on hover (`F8` moves between them). |
|
|
155
|
+
| `showDiff` | `true` | Show line changes against the baseline in the gutter (`Alt+F5` / `Alt+F3` move between them). Off, the change summary stays at zero. In Rust, needs the `diff` Cargo feature. |
|
|
156
|
+
| `completions` | `true` | Schema completions (`Ctrl+Space`). |
|
|
157
|
+
| `autoTriggerCompletions` | `true` | Open suggestions while typing and after accepting a key. Off, only `Ctrl+Space` opens them. |
|
|
158
|
+
| `hoverDocs` | `true` | Show the schema's title, description, type, default and examples when hovering a key, at the caret with `Ctrl+K Ctrl+I` (read to screen readers), or on a tap on a touch screen. |
|
|
159
|
+
| `highlighting` | `true` | Syntax colors. |
|
|
160
|
+
| `autoClosing` | `true` | Auto-close quotes and brackets, wrap selections, and delete empty pairs on Backspace. |
|
|
161
|
+
| `search` | `true` | Find and replace (`Ctrl+F`, `Ctrl+H`, `F3`). Off, those keys are left to the browser. In Rust, needs the `search` Cargo feature. |
|
|
162
|
+
| `goToLine` | `true` | Go to line (`Ctrl+G`). Off, the key is left to the browser. In Rust, needs the `search` Cargo feature. |
|
|
163
|
+
| `folding` | `true` | Folding by structure: chevrons in the gutter, `Ctrl+Shift+[` and `Ctrl+Shift+]` at the caret, `Ctrl+K Ctrl+0` and `Ctrl+K Ctrl+J` for everything (`Cmd` on macOS). View only: the text stays whole. Switching it off opens every fold. In Rust, needs the `folding` Cargo feature. |
|
|
164
|
+
| `stickyScroll` | `true` | Sticky scroll, as in VS Code: the lines opening the blocks around the top line stay at the top while the text scrolls; a click goes back to one. Works with `folding` off too. In Rust, needs the `folding` Cargo feature. |
|
|
165
|
+
| `stickyScrollMaxLines` | `5` | The most lines sticky scroll shows, 1 to 20 (others are taken as the nearest), and never more than fit in a quarter of the text area (at least one). |
|
|
166
|
+
| `saveShortcut` | `true` | Whether `Ctrl+S` / `Cmd+S` saves, when a save callback is set. Off, the key is left to the browser and only the handle's `save` saves. |
|
|
167
|
+
| `strings` | English (see below) | Every built-in text (hints, tooltips, notices and their buttons, footer counts, accessible names and announcements), English by default: give only the texts to change. See `EditorStrings`. |
|
|
168
|
+
|
|
169
|
+
<!-- settings:end -->
|
|
170
|
+
|
|
171
|
+
`strings` rewords or translates every built-in text; give only the texts to
|
|
172
|
+
change (the others stay English), and new texts apply live:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
<ConfigEditor
|
|
176
|
+
value={yaml}
|
|
177
|
+
onChange={setYaml}
|
|
178
|
+
editAs="json"
|
|
179
|
+
strings={{ noProblems: "Keine Fehler", editAsDismiss: "Schließen" }}
|
|
180
|
+
/>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Placeholders are written in braces (`{count}`, `{line}`); counts come in
|
|
184
|
+
pairs, `…One` for 1 and `…Other` otherwise. While editing as another language,
|
|
185
|
+
a dismissible notice says the host file's comments are not shown there (saving
|
|
186
|
+
keeps them) and that comments typed there are not saved.
|
|
187
|
+
|
|
188
|
+
<!-- strings:start -->
|
|
189
|
+
|
|
190
|
+
<!-- Generated from crates/config-editor-leptos/src/strings.rs by js/config-editor/tests/settings.rs; do not edit. Regenerate with `UPDATE_GENERATED=1 cargo test -p config-editor-js --test settings`. -->
|
|
191
|
+
|
|
192
|
+
<details>
|
|
193
|
+
<summary>Every text and its default (229 texts)</summary>
|
|
194
|
+
|
|
195
|
+
| Key | Default | |
|
|
196
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
197
|
+
| `suggestionsHint` | `"{key} for suggestions"` | The footer's suggestions hint; `{key}` is where the chord goes. |
|
|
198
|
+
| `suggestionsHintTouch` | `"suggestions appear as you type"` | `suggestionsHint` on a touch screen, which has no `suggestionsKey`; shown only while suggestions open as you type. |
|
|
199
|
+
| `suggestionsKey` | `"Ctrl+Space"` | The chord that opens suggestions, as the footer draws it: keys between `+`. |
|
|
200
|
+
| `noProblems` | `"No errors"` | The footer's problem count when there are none. |
|
|
201
|
+
| `errorsOne` | `"{count} error"` | One error, in the footer's problem count. |
|
|
202
|
+
| `errorsOther` | `"{count} errors"` | Several errors, in the footer's problem count. |
|
|
203
|
+
| `warningsOne` | `"{count} warning"` | One warning, in the footer's problem count. |
|
|
204
|
+
| `warningsOther` | `"{count} warnings"` | Several warnings, in the footer's problem count. |
|
|
205
|
+
| `infosOne` | `"{count} info"` | One info, in the footer's problem count. |
|
|
206
|
+
| `infosOther` | `"{count} info"` | Several infos, in the footer's problem count. |
|
|
207
|
+
| `hintsOne` | `"{count} hint"` | One hint, in the footer's problem count. |
|
|
208
|
+
| `hintsOther` | `"{count} hints"` | Several hints, in the footer's problem count. |
|
|
209
|
+
| `problemsHint` | `"hover or focus underlined text"` | After the problem count when every problem has its place. |
|
|
210
|
+
| `problemsHintTouch` | `"tap underlined text"` | `problemsHint` on a touch screen, which has no hover. |
|
|
211
|
+
| `problemsCut` | `"only the editor's first {count} are shown"` | After the problem count when the editor's own problems were cut; `{count}` is how many of them are shown (the host's are all shown). |
|
|
212
|
+
| `problemsMore` | `"Only the first {count} problems are shown; more follow."` | The problem that says the list was cut, after `{count}` problems. |
|
|
213
|
+
| `problemsIncomplete` | `"The schema check stopped early; more problems may follow."` | The problem that says the schema check stopped early, so more problems may follow than are listed (a schema whose explanation would grow faster than the document). |
|
|
214
|
+
| `underlinesCut` | `"only {count} underlines are drawn, the most serious first"` | After the problem count when the problems have more underlines than are drawn; `{count}` is how many are (the most serious first). |
|
|
215
|
+
| `changesOne` | `"{count} change"` | The footer's change count against the baseline, for one change. |
|
|
216
|
+
| `changesOther` | `"{count} changes"` | The footer's change count, for several changes. |
|
|
217
|
+
| `changeDetailsOne` | `"{lines} line · Alt+F5 for the next"` | The change count's tooltip when one line changed; `{lines}` lists the added, modified and removed counts. |
|
|
218
|
+
| `changeDetailsOther` | `"{lines} lines · Alt+F5 for the next"` | The change count's tooltip when several lines changed. |
|
|
219
|
+
| `changedAdded` | `"{count} added"` | Added lines, in the change count's tooltip. |
|
|
220
|
+
| `changedModified` | `"{count} modified"` | Modified lines, in the change count's tooltip. |
|
|
221
|
+
| `changedRemoved` | `"{count} removed"` | Removed lines, in the change count's tooltip. |
|
|
222
|
+
| `linesOne` | `"{count} line"` | The footer's line count, for one line. |
|
|
223
|
+
| `linesOther` | `"{count} lines"` | The footer's line count, for several lines. |
|
|
224
|
+
| `tabFocus` | `"Tab moves focus"` | The footer's indicator while Tab moves the focus. |
|
|
225
|
+
| `tabFocusTitle` | `"Tab moves focus (Ctrl+M to indent with Tab)"` | Its tooltip; clicking it turns the mode off. |
|
|
226
|
+
| `tabFocusOn` | `"Tab moves focus: Tab and Shift+Tab now leave the editor. Ctrl+M to indent with Tab again."` | Announced when `Ctrl+M` makes Tab move the focus. |
|
|
227
|
+
| `tabFocusOff` | `"Tab indents: Tab and Shift+Tab indent again. Ctrl+M to move focus with Tab."` | Announced when `Ctrl+M` makes Tab indent again. |
|
|
228
|
+
| `schemaConnected` | `"Schema connected"` | The toolbar's schema state. |
|
|
229
|
+
| `editAsHostComments` | `"The {host} file's comments and formatting are not shown while editing as {edit}; saving keeps them."` | The Edit-as notice when the host's file has comments, which the edited language does not show but saving keeps. |
|
|
230
|
+
| `editAsHostInstructions` | `"The {host} file's comments, processing instructions and formatting are not shown while editing as {edit}; saving keeps them."` | The same when the host's file has processing instructions too (XML `<?…?>`), which the edited language does not show either. |
|
|
231
|
+
| `editAsTypedComments` | `"Comments typed in {edit} are not saved: the {host} file keeps only its own comments."` | The Edit-as notice when comments are typed in the edited language, which saving drops, and the host's language has comments. |
|
|
232
|
+
| `editAsTypedCommentsNone` | `"Comments typed in {edit} are not saved: {host} has no comments."` | The same when the host's language has no comments (JSON). |
|
|
233
|
+
| `editAsDismiss` | `"Dismiss"` | The Edit-as notice's close button. |
|
|
234
|
+
| `baselineChanged` | `"This file changed outside the editor."` | The notice shown when the host's baseline changes under unsaved edits. |
|
|
235
|
+
| `baselineChangedDetail` | `"Reload it, losing your changes, or keep your text and compare it with the new version."` | What the notice's choices do, after its message. |
|
|
236
|
+
| `reload` | `"Reload"` | The notice's button that takes the new baseline as the text. |
|
|
237
|
+
| `reloaded` | `"Reloaded"` | Announced after Reload took the changed baseline. |
|
|
238
|
+
| `reloadTitle` | `"Replace your text with the new version ({cmd}+Z brings yours back)"` | Its tooltip. |
|
|
239
|
+
| `keepMine` | `"Keep mine"` | The notice's button that keeps the text against the new baseline. |
|
|
240
|
+
| `keepMineTitle` | `"Keep your text; the changes are now shown against the new version (Escape)"` | Its tooltip. |
|
|
241
|
+
| `baselineChangedKeys` | `"In the editor, F6 moves to the choices and back."` | How to reach the notice's choices from the keyboard, shown on it (and announced with it); not on touch screens. |
|
|
242
|
+
| `findWidget` | `"Find and replace"` | The find widget's accessible name. |
|
|
243
|
+
| `toggleReplace` | `"Toggle replace"` | The button showing the replace row. |
|
|
244
|
+
| `toggleReplaceTitle` | `"Toggle replace ({cmd}+H)"` | Its tooltip. |
|
|
245
|
+
| `find` | `"Find"` | The query field's accessible name and placeholder. |
|
|
246
|
+
| `matchCase` | `"Match case"` | The match-case toggle. |
|
|
247
|
+
| `matchCaseTitle` | `"Match case (Alt+C)"` | Its tooltip. |
|
|
248
|
+
| `wholeWord` | `"Match whole word"` | The whole-word toggle. |
|
|
249
|
+
| `wholeWordTitle` | `"Match whole word (Alt+W)"` | Its tooltip. |
|
|
250
|
+
| `useRegex` | `"Use regular expression"` | The regular-expression toggle. |
|
|
251
|
+
| `useRegexTitle` | `"Use regular expression (Alt+R)"` | Its tooltip. |
|
|
252
|
+
| `previousMatch` | `"Previous match"` | The previous-match button. |
|
|
253
|
+
| `previousMatchTitle` | `"Previous match (Shift+Enter)"` | Its tooltip. |
|
|
254
|
+
| `nextMatch` | `"Next match"` | The next-match button. |
|
|
255
|
+
| `nextMatchTitle` | `"Next match (Enter)"` | Its tooltip. |
|
|
256
|
+
| `close` | `"Close"` | The find widget's close button. |
|
|
257
|
+
| `closeTitle` | `"Close (Escape)"` | Its tooltip. |
|
|
258
|
+
| `replace` | `"Replace"` | The replacement field's accessible name and placeholder, and the button replacing the current match. |
|
|
259
|
+
| `replaceTitle` | `"Replace (Enter)"` | The replace button's tooltip. |
|
|
260
|
+
| `replaceAll` | `"All"` | The replace-all button. |
|
|
261
|
+
| `replaceAllLabel` | `"Replace all"` | Its accessible name. |
|
|
262
|
+
| `replaceAllTitle` | `"Replace all ({cmd}+Alt+Enter)"` | Its tooltip. |
|
|
263
|
+
| `matchPosition` | `"{current} of {total}"` | The match count: match `{current}` of `{total}`. |
|
|
264
|
+
| `noResults` | `"No results"` | The match count when nothing matches. |
|
|
265
|
+
| `invalidPattern` | `"Invalid pattern"` | The match count when the regular expression is invalid. |
|
|
266
|
+
| `replacedOne` | `"Replaced {count} occurrence"` | After Replace All, for one match. |
|
|
267
|
+
| `replacedOther` | `"Replaced {count} occurrences"` | After Replace All, for several. |
|
|
268
|
+
| `replaceSkipped` | `"; skipped {count} in read-only text or secret placeholders"` | Added when Replace All left matches in protected text alone. |
|
|
269
|
+
| `nothingReplaced` | `"Every match is in read-only text or secret placeholders; nothing was replaced"` | After Replace All when every match is in read-only text or a secret placeholder. |
|
|
270
|
+
| `goToLine` | `"Go to line"` | The go-to-line field's accessible name. |
|
|
271
|
+
| `goToLinePlaceholder` | `"line or line:column"` | Its placeholder. |
|
|
272
|
+
| `goToLineHint` | `"Line 1–{lines}, or line:column"` | Its hint: the range of lines. |
|
|
273
|
+
| `goToLineInvalid` | `"Type a line number between 1 and {lines}"` | Its hint when the text is no position. |
|
|
274
|
+
| `addedLine` | `"Added line"` | The change preview's title for an added line. |
|
|
275
|
+
| `modifiedLine` | `"Modified line"` | For a modified line. |
|
|
276
|
+
| `removedLine` | `"Removed line"` | For one removed line. |
|
|
277
|
+
| `removedLines` | `"Removed lines"` | For several removed lines. |
|
|
278
|
+
| `removedLineAtEnd` | `"Removed line at end of document"` | For one line removed after the last one. |
|
|
279
|
+
| `removedLinesAtEnd` | `"Removed lines at end of document"` | For several lines removed after the last one. |
|
|
280
|
+
| `showAdded` | `"Show added line {line}"` | The gutter marker of an added line. |
|
|
281
|
+
| `showAddedTitle` | `"Show added line"` | Its tooltip. |
|
|
282
|
+
| `showModified` | `"Show before and after for modified line {line}"` | The gutter marker of a modified line. |
|
|
283
|
+
| `showModifiedTitle` | `"Show before and after"` | Its tooltip. |
|
|
284
|
+
| `showRemoved` | `"Show removed lines before line {line}"` | The gutter marker of removed lines. |
|
|
285
|
+
| `showRemovedTitle` | `"Show removed lines"` | Its tooltip, and that of lines removed at the end. |
|
|
286
|
+
| `showRemovedAtEnd` | `"Show removed lines at end of document"` | The gutter marker of lines removed after the last one. |
|
|
287
|
+
| `previewHeading` | `"{title} · line {line}"` | The change preview's heading: its `{title}` and `{line}`. |
|
|
288
|
+
| `previewLabel` | `"{title}, line {line}"` | The change preview's accessible name. |
|
|
289
|
+
| `changePosition` | `"{title}, line {line}: change {position} of {total}"` | Announced on `Alt+F5` / `Shift+Alt+F5`: the change's `{title}` (as the preview's), its `{line}`, and its `{position}` of `{total}`. |
|
|
290
|
+
| `noChanges` | `"No changes"` | Announced on `Alt+F5` / `Alt+F3` when nothing differs from the baseline. |
|
|
291
|
+
| `reverted` | `"Reverted"` | Announced when a change is reverted. |
|
|
292
|
+
| `revert` | `"Revert"` | The preview's revert button. |
|
|
293
|
+
| `revertTitle` | `"Revert this change (R)"` | Its tooltip, for a one-line change. |
|
|
294
|
+
| `revertLinesTitle` | `"Revert this change (lines {first}–{last}) (R)"` | Its tooltip, for a change over lines `{first}` to `{last}`. |
|
|
295
|
+
| `revertLineAndRemovedTitle` | `"Revert this change (line {line} and the removed lines) (R)"` | Its tooltip, for a changed line with removed lines. |
|
|
296
|
+
| `closePreview` | `"Close change preview"` | The preview's close button. |
|
|
297
|
+
| `before` | `"Before"` | The preview's column of the baseline's lines. |
|
|
298
|
+
| `current` | `"Current"` | The preview's column of the current lines. |
|
|
299
|
+
| `fold` | `"Fold line {line}"` | The chevron of an open range. |
|
|
300
|
+
| `unfold` | `"Unfold lines {first}–{last}"` | The chevron or chip of a closed fold. |
|
|
301
|
+
| `foldedChanges` | `"Folded lines have changes"` | A closed fold's line number when it hides changes or problems. |
|
|
302
|
+
| `foldedProblemOne` | `"hides a problem: {severity}"` | After a closed fold's chip label when it hides one problem; `{severity}` names it. |
|
|
303
|
+
| `foldedProblemOther` | `"hides {count} problems, the most serious: {severity}"` | After a closed fold's chip label when it hides `{count}` problems; `{severity}` names the most serious of them. |
|
|
304
|
+
| `foldedLines` | `"Folded lines {first}–{last}"` | Announced when the range of lines `{first}` to `{last}` folds. |
|
|
305
|
+
| `unfoldedLines` | `"Unfolded lines {first}–{last}"` | Announced when the fold of lines `{first}` to `{last}` opens. |
|
|
306
|
+
| `foldedRanges` | `"Folded {count} ranges"` | Announced when `{count}` ranges (two or more) fold at once. |
|
|
307
|
+
| `unfoldedRanges` | `"Unfolded {count} ranges"` | Announced when `{count}` folds (two or more) open at once. |
|
|
308
|
+
| `nothingToFold` | `"Nothing to fold"` | Announced when a fold key (`Ctrl+Shift+[`, `Ctrl+K Ctrl+0`) finds nothing to fold. |
|
|
309
|
+
| `nothingToUnfold` | `"Nothing to unfold"` | Announced when an unfold key (`Ctrl+Shift+]`, `Ctrl+K Ctrl+J`) finds nothing to open. |
|
|
310
|
+
| `required` | `"required"` | The hover card's mark of a required key. |
|
|
311
|
+
| `deprecated` | `"deprecated"` | The hover card's mark of a deprecated key. |
|
|
312
|
+
| `defaultValue` | `"Default"` | The hover card's default row. |
|
|
313
|
+
| `examples` | `"Examples"` | The hover card's examples row. |
|
|
314
|
+
| `oneOf` | `"One of"` | The hover card's row listing the titles of the options (`oneOf`, `anyOf`) a field's object may take, while none matches it yet. |
|
|
315
|
+
| `documentation` | `"Documentation"` | The hover card's link to the schema's documentation. |
|
|
316
|
+
| `hoverFocused` | `"In the docs: arrows, Page Up, Page Down, Home and End scroll them. Escape returns to the text."` | Announced when a second `Ctrl+K Ctrl+I` moves the focus into the hover card, to scroll it. |
|
|
317
|
+
| `hoverLabel` | `"About {key}"` | The focused hover card's accessible name: the `{key}` it documents. |
|
|
318
|
+
| `problemTipLabel` | `"Problems here"` | The problem tip's accessible name while it has the focus (a second `Ctrl+K Ctrl+I`). |
|
|
319
|
+
| `openDocs` | `"Open docs ↗ (Alt+Enter)"` | The link under a host problem's message. |
|
|
320
|
+
| `openDocsTouch` | `"Open docs ↗"` | `openDocs` on a touch screen, which has no keys to name. |
|
|
321
|
+
| `openDocsLabel` | `"{link}: {message}"` | A problem's docs link as a screen reader names it, told apart from the others in a tip: its `{link}` text (`openDocs`) and its problem's `{message}`. |
|
|
322
|
+
| `error` | `"Error"` | An error, as a screen reader hears it. |
|
|
323
|
+
| `warning` | `"Warning"` | A warning, as a screen reader hears it. |
|
|
324
|
+
| `info` | `"Info"` | An info, as a screen reader hears it. |
|
|
325
|
+
| `hint` | `"Hint"` | A hint, as a screen reader hears it. |
|
|
326
|
+
| `problemSource` | `" from {source}"` | Who reported a host problem: the `{source}` of the problem texts below (empty for the editor's own problems). |
|
|
327
|
+
| `problem` | `"{severity}{source}: {message}"` | A problem at the caret, for screen readers. |
|
|
328
|
+
| `problemPosition` | `"{severity} {position} of {total}{source}: {message}"` | Announced on `F8`: problem `{position}` of `{total}`. |
|
|
329
|
+
| `walkNoProblems` | `"No problems"` | Announced on `F8` when there are no problems. |
|
|
330
|
+
| `problemCode` | `" Code {code}."` | After a problem's text for screen readers: its `{code}` (from the host). |
|
|
331
|
+
| `problemDocs` | `" Documentation: {url} (Alt+Enter opens it)."` | After a problem's text (or the hover card's docs) for screen readers: its documentation's `{url}`, and the key that opens it. |
|
|
332
|
+
| `problemMarker` | `"{language} {severity}{source} on line {line}: {message}"` | An underlined problem's accessible name. |
|
|
333
|
+
| `protectedNote` | `"{label}: {message}"` | What protected text at the caret is, for screen readers: its `{label}` and `{message}`. |
|
|
334
|
+
| `sourceLabel` | `"{language} source"` | The text area. |
|
|
335
|
+
| `suggestionsLabel` | `"{language} suggestions"` | The suggestions list. |
|
|
336
|
+
| `problemsLabel` | `"Inline {language} diagnostics"` | The layer of underlined problems. |
|
|
337
|
+
| `editorLabel` | `"{language} editor"` | The editor's frame. |
|
|
338
|
+
| `readOnlyEditor` | `"Cannot edit in a read-only editor"` | Said, and shown at the caret, when typing in a read-only editor. |
|
|
339
|
+
| `readOnlyEditorReason` | `"Cannot edit in a read-only editor: {reason}"` | The same, for an editor the host said why it is read-only (`readOnlyReason`): `{reason}`. |
|
|
340
|
+
| `readOnlyField` | `"This field is read-only"` | Why a field is read-only when neither the schema nor the host says. |
|
|
341
|
+
| `readOnlyText` | `"This text is read-only"` | Why text in a read-only range the host gave cannot change. |
|
|
342
|
+
| `holdsReadOnly` | `"Holds a read-only field"` | Why renaming or moving the key above a read-only field is refused, when nothing says why the field is read-only. |
|
|
343
|
+
| `holdsReadOnlyReason` | `"Holds a read-only field: {reason}"` | The same, for a field the schema says why is read-only (`x-readonly-reason`): `{reason}`. |
|
|
344
|
+
| `saveRefused` | `"{pointer} is read-only and this change would alter it"` | A save refused because it would change a read-only value. |
|
|
345
|
+
| `saveWaits` | `"Not saved: {pointer} is read-only, and it can be checked only once the text is valid"` | A save waiting for the text to be valid: the language cannot say where the read-only field at `{pointer}` is written, so its value is checked only in a text that parses. |
|
|
346
|
+
| `saveHeld` | `"Not saved: the read-only field {pointer} no longer reads as the host gave it{reason}; put it back as it was to save"` | A save waiting because the read-only field at `{pointer}` no longer reads as the host gave it, held where the editor cannot tell why; `{reason}` is the `saveHeldReason` text when the schema says why the field is read-only (`x-readonly-reason`), else empty. The texts after it name each cause a hold records, with the same placeholders. |
|
|
347
|
+
| `saveHeldDuplicate` | `"Not saved: the read-only field {pointer} is written twice, and the other copy is read in its place{reason}; remove the copy to save"` | The same, because its key or a block holding it is written twice, and the other copy is read in its place. |
|
|
348
|
+
| `saveHeldRenamed` | `"Not saved: a key holding the read-only field {pointer} was renamed{reason}; give the key its old name back to save"` | The same, because a key on its path was renamed (by an edit or an undo). |
|
|
349
|
+
| `saveHeldMoved` | `"Not saved: the read-only field {pointer} moved under another parent{reason}; move it back to save"` | The same, because its text now sits under another parent. |
|
|
350
|
+
| `saveHeldListItem` | `"Not saved: the read-only field {pointer} is now another item of its list, because items were added, removed or moved before it{reason}; put the items back in order to save"` | The same, for a list item whose place in its list now holds another item (items were added, removed or moved before it). |
|
|
351
|
+
| `saveHeldCommented` | `"Not saved: the read-only field {pointer} is commented out{reason}; remove the comment mark to save"` | The same, because its line is commented out. |
|
|
352
|
+
| `saveHeldRemoved` | `"Not saved: the read-only field {pointer} is no longer in the text{reason}; write it back as the host gave it to save"` | The same, because the text no longer has it. |
|
|
353
|
+
| `saveHeldAdded` | `"Not saved: the read-only field {pointer} now reads text that was added into it or beside it{reason}; remove that text to save"` | The same, because text was added into it or beside it (a key in its block, a line taken into its value). |
|
|
354
|
+
| `saveHeldSpanless` | `"Not saved: the read-only field {pointer} now reads another value than the host gave{reason}; put its value back as it was to save"` | The same, in a language that cannot say where the field is written: its value reads otherwise. |
|
|
355
|
+
| `saveHeldRange` | `"Not saved: the read-only text the host gave no longer reads as {pointer}{reason}; put that text back where it was to save"` | The same, for a field in a read-only range the host gave: the range's text no longer reads as that field. |
|
|
356
|
+
| `saveHeldBeforeLock` | `"Not saved: {pointer} was changed before the host made it read-only{reason}; put it back as the host gave it to save"` | The same, for a field the host made read-only after it was changed: the text reads it otherwise than the host's text does. |
|
|
357
|
+
| `saveHeldReason` | `" ({reason})"` | What a `save_held…` text says of why the field is read-only, when the schema says (`x-readonly-reason`): its `{reason}`. |
|
|
358
|
+
| `saveHeldPlaceholder` | `"Not saved: {pointer} now reads other text beside its secret placeholder; remove that text so the placeholder stands alone to save"` | A save waiting because the secret field at `{pointer}` now reads text beside a placeholder the host gave as its whole value (an edit beside it, or an undo, made the parse read them together). |
|
|
359
|
+
| `readOnlyLabel` | `"Read-only"` | The gutter lock's label, before the reason. |
|
|
360
|
+
| `secretLabel` | `"Secret placeholder"` | The gutter key's label, before the hint. |
|
|
361
|
+
| `secretHint` | `"Keeps the current secret unless you replace it"` | The hover text of a secret placeholder, unless the host gives one. |
|
|
362
|
+
| `secretValue` | `"the secret value"` | What a schema problem says instead of a secret field's value. |
|
|
363
|
+
| `secretInside` | `"…"` | What a schema problem writes in place of each secret inside a value it quotes (a list or map holding one). |
|
|
364
|
+
| `unknownPlaceholder` | `"{pointer}: unknown secret placeholder; it stands for no current secret, so write the new value instead"` | A placeholder the host did not give, in a secret field. |
|
|
365
|
+
| `movedPlaceholder` | `"{pointer}: this placeholder stands for the secret of {owner}, not this field's; here it is plain text"` | One of the host's placeholders outside the field it stands in. |
|
|
366
|
+
| `foreignPlaceholder` | `"This placeholder stands for a secret of {source}, not of this document; here it is plain text"` | One of another document's placeholders (in a documents view), `{source}` its file name. |
|
|
367
|
+
| `extraPlaceholder` | `"{pointer}: this placeholder is in this field already; another copy of it is plain text"` | One of the host's placeholders written in its own field more often than the host gave it there: a copy of it. |
|
|
368
|
+
| `placeholderInComment` | `"This placeholder stands for the secret of {owner}; in a comment it is plain text"` | One of the host's field placeholders written in a comment. |
|
|
369
|
+
| `commentPlaceholder` | `"{pointer}: this placeholder stands for a secret in a comment, not this field's; here it is plain text"` | A placeholder the host wrote in a comment, in a field. |
|
|
370
|
+
| `gluedPlaceholder` | `"{pointer}: a secret placeholder stands for the whole secret, so nothing can be written beside it: replace it whole to write a new value"` | Text written beside a placeholder the host gave as a field's whole value: the edit refused, the field flagged, a save waiting. |
|
|
371
|
+
| `envReference` | `"Read the secret from an environment variable"` | The detail of the `${…}` reference suggestion. |
|
|
372
|
+
| `fileReference` | `"Read the secret from a file"` | The detail of the `file:` reference suggestion. |
|
|
373
|
+
| `otherReference` | `"A reference starting with {prefix}"` | The detail of another reference suggestion. |
|
|
374
|
+
| `referenceType` | `"reference"` | The type column of a reference suggestion. |
|
|
375
|
+
| `closesTag` | `"Closes <{name}>"` | The detail of the end tag XML suggests. |
|
|
376
|
+
| `endTag` | `"end tag"` | Its type column. |
|
|
377
|
+
| `noSuggestions` | `"No suggestions"` | Said when Ctrl+Space finds nothing to offer, and when typing empties a list opened with Ctrl+Space or moved in; a list that opened by itself closes silently. |
|
|
378
|
+
| `keyNotAllowed` | `"\"{key}\" is not allowed here"` | A key the schema does not allow (`{key}`); its object's pointer goes before it (`/web: `), as before every schema problem but at the root. |
|
|
379
|
+
| `textNotAllowed` | `"text is not allowed here, only elements"` | Text in an element the schema wants elements in (XML); the element's pointer goes before it. |
|
|
380
|
+
| `keyDeprecated` | `"{pointer}: \"{key}\" is deprecated"` | A deprecated key. |
|
|
381
|
+
| `keyDeprecatedInstead` | `"{pointer}: \"{key}\" is deprecated. {message}"` | A deprecated key whose schema says what to use instead. |
|
|
382
|
+
| `notOneOf` | `"{value} is not one of {allowed}"` | A value not among the allowed ones. |
|
|
383
|
+
| `wrongType` | `"{value} is not of type {types}"` | A value of none of the accepted types. |
|
|
384
|
+
| `notFormat` | `"{value} is not a valid {format}"` | A value out of its `format` (checked up to draft-07): `{format}` is its name, quoted. |
|
|
385
|
+
| `noItemContained` | `"no item of the list matches its \"contains\" schema"` | A list with no item its `contains` schema allows. |
|
|
386
|
+
| `tooFewContained` | `"fewer than {limit} items of the list match its \"contains\" schema"` | A list with fewer items its `contains` schema allows than its `minContains` (`{limit}`). |
|
|
387
|
+
| `tooManyContained` | `"more than {limit} items of the list match its \"contains\" schema"` | A list with more items its `contains` schema allows than its `maxContains` (`{limit}`). |
|
|
388
|
+
| `tooFewItems` | `"the number of items must be at least {limit}, and is {count}"` | A list with fewer items (`{count}`) than its `minItems` (`{limit}`). |
|
|
389
|
+
| `tooManyItems` | `"the number of items must be at most {limit}, and is {count}"` | A list with more items (`{count}`) than its `maxItems` (`{limit}`). |
|
|
390
|
+
| `tooFewKeys` | `"the number of keys must be at least {limit}, and is {count}"` | An object with fewer keys (`{count}`) than its `minProperties` (`{limit}`). |
|
|
391
|
+
| `tooManyKeys` | `"the number of keys must be at most {limit}, and is {count}"` | An object with more keys (`{count}`) than its `maxProperties` (`{limit}`). |
|
|
392
|
+
| `repeatedItem` | `"the list holds {item} more than once: each item must differ"` | A list holding an item (`{item}`, as JSON) more than once where its `uniqueItems` wants each item different. |
|
|
393
|
+
| `mustNotMatch` | `"{value} is not allowed here"` | A value its `not` schema (`{schema}`, as JSON) matches, where no plainer words below say why. |
|
|
394
|
+
| `mustNotMatchPattern` | `"{value} must not match the pattern {pattern}"` | A text matching the pattern its `not` schema refuses (`not: {pattern: …}`): the pattern (`{pattern}`), quoted as JSON. |
|
|
395
|
+
| `mustNotBeType` | `"{value} must not be of type {types}"` | A value of a type its `not` schema refuses (`not: {type: …}`): the types (`{types}`), each quoted, joined by `, `. |
|
|
396
|
+
| `mustNotBe` | `"{value} is one of the values not allowed here: {values}"` | A value its `not` schema refuses among others by name (`not: {enum: […]}` of two or more values): the refused values (`{values}`), as JSON, joined by `, `. One refused value (`not: {const: …}`) is told by `mustNotMatch`. |
|
|
397
|
+
| `mustNotHave` | `"{keys} must not be set here"` | An object holding keys its `not` schema refuses one by one (`not: {anyOf: [{required: [a]}, {required: [b]}]}`): the ones it holds (`{keys}`), each quoted, joined by `, `; the object is `{value}`. |
|
|
398
|
+
| `keysUsedTogether` | `"{key} can't be used together with {other}"` | An object holding both keys its `not` schema keeps apart (`not: {required: [a, b]}`, or a key's dependent schema's `not`): the first (`{key}`) and the other (`{other}`), each quoted. |
|
|
399
|
+
| `keysAllUsedTogether` | `"{keys} can't all be used together"` | An object holding all of three or more keys its `not` schema keeps apart (`not: {required: [a, b, c]}`): the keys (`{keys}`), each quoted, joined by `, `. |
|
|
400
|
+
| `noOptionMatches` | `"matches none of the {keyword} options: {reasons}"` | A value that matches none of a schema's options (`{keyword}`: `oneOf` or `anyOf`), with why each fails (`{reasons}`, each worded by `optionNeeds`, `optionRefuses` or `optionProblem`, joined by `; `). |
|
|
401
|
+
| `severalOptionsMatch` | `"matches more than one of the oneOf options ({options}); only one may match"` | A value that matches more than one of a `oneOf`'s options (`{options}`, their names joined by `, `). |
|
|
402
|
+
| `optionNeeds` | `"{option} needs \"{key}\""` | An option (`{option}`) that needs a key the value does not have. |
|
|
403
|
+
| `optionRefuses` | `"{option} does not allow \"{key}\""` | An option (`{option}`) that does not allow a key the value has. |
|
|
404
|
+
| `optionProblem` | `"{option}: {problem}"` | An option (`{option}`) and another problem it has with the value. |
|
|
405
|
+
| `optionNumber` | `"option {number}"` | The name of an option with no title or description (`{number}`, from 1). |
|
|
406
|
+
| `invalidSchema` | `"Invalid JSON Schema: {error}"` | A schema that does not compile. |
|
|
407
|
+
| `emptySchema` | `"Invalid JSON Schema: the schema text is empty"` | A schema whose text is empty, or only spaces and line breaks. |
|
|
408
|
+
| `invalidPlaceholder` | `"secrets.placeholder: {error}"` | A secret placeholder pattern the editor cannot use (it does not compile, or matches empty text): no token is taken for a placeholder. |
|
|
409
|
+
| `problemAtPath` | `"{path}: {message}"` | A host's problem with a field the editor cannot find in the text, listed with the field's path. |
|
|
410
|
+
| `hostCannotKeep` | `"{pointer}: {host} cannot keep this value exactly, as it reads back differently: change it, or edit it as {host}, to save"` | A value the host's language reads back differently (Edit-as). |
|
|
411
|
+
| `editCannotShow` | `"{pointer}: {edit} cannot show this value exactly; editing it here may change it"` | A value the edited language cannot show exactly (Edit-as). |
|
|
412
|
+
| `notSaved` | `"Not saved as {host}: {error}"` | An edit the host's language cannot save (Edit-as). |
|
|
413
|
+
| `noNull` | `"{host} has no null value: give it a value or remove it to save (at {pointer})"` | A null the host's language cannot write (Edit-as). |
|
|
414
|
+
| `noNonFinite` | `"{host} has no infinity or NaN: write a finite number or remove it to save (at {pointer})"` | An infinity or NaN the host's language has no number for (Edit-as). |
|
|
415
|
+
| `cannotSwitch` | `"Cannot switch to {edit} yet: {error}"` | An Edit-as switch waiting until the document converts. |
|
|
416
|
+
| `switchRefused` | `"Cannot edit as {edit}: {error}"` | An Edit-as switch refused: the host's language or the other one cannot write documents. |
|
|
417
|
+
| `mixedContent` | `"{pointer}: text beside child elements cannot be shown in another language"` | XML text beside child elements, which no other language can show (Edit-as). |
|
|
418
|
+
| `tabList` | `"Open files"` | The tab list's accessible name, unless the host gives one. |
|
|
419
|
+
| `noDocuments` | `"No open files"` | Shown in place of an editor while no document is open. |
|
|
420
|
+
| `closeTab` | `"Close {name}"` | A tab's close button. |
|
|
421
|
+
| `closeTabTitle` | `"Close (Delete)"` | Its tooltip. |
|
|
422
|
+
| `addDocument` | `"New file"` | The "+" button after the tabs (with `onAdd`): its accessible name and tooltip. |
|
|
423
|
+
| `unsaved` | `"unsaved changes"` | The dirty dot's tooltip, and what a tab's accessible name adds for it. |
|
|
424
|
+
| `readOnlyTab` | `"read-only"` | What a read-only document's tab adds to its accessible name. |
|
|
425
|
+
| `readOnlyTabTitle` | `"{name}\nRead-only: {reason}"` | The tooltip of a read-only document's tab with a reason (`readOnlyReason`): its file `{name}` and the `{reason}`. |
|
|
426
|
+
|
|
427
|
+
</details>
|
|
428
|
+
|
|
429
|
+
<!-- strings:end -->
|
|
430
|
+
|
|
431
|
+
<details>
|
|
432
|
+
<summary>Parents that apply onChange late: echoes and resetting with setValue</summary>
|
|
433
|
+
|
|
434
|
+
A parent that applies `onChange` values late, even in another order (a
|
|
435
|
+
store, a fetch per edit), cannot roll the document back: a `value` the
|
|
436
|
+
editor sent that has not come back yet is taken as its echo, in any order and however
|
|
437
|
+
late, also across a re-mount (a new `language` or `fileName`): the new
|
|
438
|
+
editor takes over the echoes still on their way. Any other `value` (a revert, a reset, a loaded file) is
|
|
439
|
+
applied. The values the editor sent before such a value belong to the text it replaced: switching back to a file applies its text (a parent still applying every late value after one of its own resets with `setValue`, below). `readOnlyRanges` and `hostDiagnostics` passed with an echo are in the echoed text: they are moved to the document. If an echo leaves the parent's state on an older text, with nothing
|
|
440
|
+
still on its way to bring it back, `onChange` reports the document again so
|
|
441
|
+
both end on it. React applies several values in one render, so the echo that
|
|
442
|
+
would bring it back may never be seen: if the state is still on an older
|
|
443
|
+
text 250 ms after such an echo, `onChange` reports the document again then. A parent that applies only some values (a debounce keeping
|
|
444
|
+
the latest) leaves the others counted as echoes: to reset to a text the
|
|
445
|
+
user may have passed through, call `ref.current.setValue(text)`, which
|
|
446
|
+
always applies (also before the editor has mounted, from an effect: it is
|
|
447
|
+
applied when the editor mounts) and is reported through `onChange` so the
|
|
448
|
+
parent's state follows. Reset one way, not both at once: with `setValue`, or by setting your state.
|
|
449
|
+
With both and no `valueRevision`, your state lists the text twice (your own
|
|
450
|
+
set, then the late echo of the report), and that late echo can undo what is
|
|
451
|
+
typed next. With `valueRevision` the editor tells them apart exactly.
|
|
452
|
+
|
|
453
|
+
With revisions there is no pause: `onChange(text, revision)` gives each text a revision. Store it beside the text and pass it back as the `valueRevision` prop (keep only the newest revision you were given, never go back to an older one; leave it out for a text of your own). The echo is then matched exactly, and the editor never sends a text again by itself: a parent that loses one (a save that failed) passes the newest text `onChange` gave again, with its revision. See [Hosts that echo](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#hosts-that-echo).
|
|
454
|
+
|
|
455
|
+
```tsx
|
|
456
|
+
import { useState } from "react";
|
|
457
|
+
import { ConfigEditor } from "@pngwasi/config-editor-react";
|
|
458
|
+
|
|
459
|
+
const [stored, setStored] = useState({
|
|
460
|
+
text: initial,
|
|
461
|
+
revision: undefined as number | undefined,
|
|
462
|
+
});
|
|
463
|
+
<ConfigEditor
|
|
464
|
+
value={stored.text}
|
|
465
|
+
valueRevision={stored.revision}
|
|
466
|
+
onChange={(text, revision) => setStored({ text, revision })}
|
|
467
|
+
/>;
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
`readOnlyRanges` name places in the text they come with: a new list goes to the editor with the `value` you render it with. When you render a new text of your own with the same ranges, the editor keeps the locks where the edits moved them and carries them into the new text; where it cannot tell where a lock went, it locks the whole changed lines around it until you render new ranges. So work the ranges out again for each new text, or use `readOnlyPaths`, which do not depend on places in the text. Hiding and showing the editor (an unmount) starts a new editor: it keeps the locks only through the ranges you render for your current text.
|
|
471
|
+
|
|
472
|
+
</details>
|
|
473
|
+
|
|
474
|
+
## Ref
|
|
475
|
+
|
|
476
|
+
```tsx
|
|
477
|
+
import { useRef } from "react";
|
|
478
|
+
import {
|
|
479
|
+
ConfigEditor,
|
|
480
|
+
type ConfigEditorHandle,
|
|
481
|
+
} from "@pngwasi/config-editor-react";
|
|
482
|
+
|
|
483
|
+
const ref = useRef<ConfigEditorHandle>(null);
|
|
484
|
+
<ConfigEditor ref={ref} defaultValue={initial} />;
|
|
485
|
+
<ConfigEditor
|
|
486
|
+
value={text}
|
|
487
|
+
onChange={setText}
|
|
488
|
+
hostDiagnostics={[
|
|
489
|
+
{ path: "/web/listen", message: "port 80 is taken", source: "validator" },
|
|
490
|
+
]}
|
|
491
|
+
/>;
|
|
492
|
+
<ConfigEditor
|
|
493
|
+
value={text}
|
|
494
|
+
onChange={setText}
|
|
495
|
+
schema={schema}
|
|
496
|
+
readOnlyPaths={["/limits"]}
|
|
497
|
+
/>; // plus the schema's `readOnly` fields
|
|
498
|
+
<ConfigEditor
|
|
499
|
+
value={text}
|
|
500
|
+
onChange={setText}
|
|
501
|
+
schema={schema}
|
|
502
|
+
secrets={{ hint: "Keeps the stored secret" }}
|
|
503
|
+
/>; // `«secret 3f2a»` stays atomic
|
|
504
|
+
|
|
505
|
+
ref.current?.value; // the current document
|
|
506
|
+
ref.current?.editor; // the underlying @pngwasi/config-editor instance, once mounted
|
|
507
|
+
ref.current?.setValue(saved); // replace the document, always; onChange reports it
|
|
508
|
+
ref.current?.unifiedDiff(); // the `diff -u` of the baseline against the document
|
|
509
|
+
|
|
510
|
+
// Paths: a JSON pointer or keys and indices, the same in every language.
|
|
511
|
+
ref.current?.reveal("/web/listen"); // scroll to it, select it, focus; false if absent
|
|
512
|
+
ref.current?.revealRange({ start: 0, end: 12 }); // any stretch of the text on screen, a comment included
|
|
513
|
+
ref.current?.rangeOf(["web", "listen"]); // { start, end, startLine, startColumn, endLine, endColumn } | null
|
|
514
|
+
ref.current?.pathAt(42); // { pointer, segments } | null, at a string index
|
|
515
|
+
ref.current?.currentPath; // the caret's path
|
|
516
|
+
ref.current?.text; // the text on screen (the editAs language while editing as another)
|
|
517
|
+
ref.current?.focus();
|
|
518
|
+
ref.current?.save(); // as Ctrl+S: calls onSave; false when nothing was sent
|
|
519
|
+
ref.current?.editAs("toml"); // ask again for the editAs prop's language (after an undo across the switch)
|
|
520
|
+
ref.current?.isDirty; // the document differs from baseline
|
|
521
|
+
|
|
522
|
+
// Folding (view only).
|
|
523
|
+
ref.current?.foldAll();
|
|
524
|
+
ref.current?.unfoldAll();
|
|
525
|
+
ref.current?.fold("/clients"); // fold the block its key opens; false if none
|
|
526
|
+
ref.current?.unfold("/web/listen"); // open the folds around a field
|
|
527
|
+
ref.current?.foldedLines; // [{ startLine, endLine }], one-based
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Saving
|
|
531
|
+
|
|
532
|
+
```tsx
|
|
533
|
+
import { useState } from "react";
|
|
534
|
+
|
|
535
|
+
const [saved, setSaved] = useState(loaded);
|
|
536
|
+
const [text, setText] = useState(loaded);
|
|
537
|
+
const [dirty, setDirty] = useState(false);
|
|
538
|
+
<ConfigEditor
|
|
539
|
+
value={text}
|
|
540
|
+
onChange={setText}
|
|
541
|
+
baseline={saved}
|
|
542
|
+
onSave={async (next) => {
|
|
543
|
+
await putConfig(next);
|
|
544
|
+
setSaved(next); // nothing unsaved any more
|
|
545
|
+
}}
|
|
546
|
+
onDirtyChange={setDirty}
|
|
547
|
+
/>;
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
When `baseline` changes while the user has unsaved edits (another client
|
|
551
|
+
saved), the editor shows "This file changed outside the editor." (announced; the
|
|
552
|
+
focus stays in the text, `F6` moves it to the notice and back) with **Reload**
|
|
553
|
+
(the document becomes the new baseline, reported through `onChange`) and
|
|
554
|
+
**Keep mine** (or `Escape` with the focus in the notice: the document stays, diffed against the new
|
|
555
|
+
baseline). A baseline equal to the document, or to a text the editor sent
|
|
556
|
+
(a save coming back while the user typed on, or a late parent), never asks.
|
|
557
|
+
A new `value` from the parent keeps the caret and the scroll position.
|
|
558
|
+
|
|
559
|
+
Ranges and indices refer to the text on screen (the `editAs` language while
|
|
560
|
+
editing as another one). `reveal` selects the key and its value when they
|
|
561
|
+
share a line, the key alone when the value is a block below it, the value
|
|
562
|
+
alone for a list item, and the dash or header of an item holding a block.
|
|
563
|
+
|
|
564
|
+
### Several documents
|
|
565
|
+
|
|
566
|
+
```tsx
|
|
567
|
+
import { useRef, useState } from "react";
|
|
568
|
+
import {
|
|
569
|
+
ConfigDocuments,
|
|
570
|
+
type ConfigDocumentsHandle,
|
|
571
|
+
type DocumentSpec,
|
|
572
|
+
} from "@pngwasi/config-editor-react";
|
|
573
|
+
|
|
574
|
+
const [files, setFiles] = useState<DocumentSpec[]>([
|
|
575
|
+
{ id: "main", fileName: "config.yaml", value: mainText, schema },
|
|
576
|
+
{
|
|
577
|
+
id: "tls",
|
|
578
|
+
fileName: "conf.d/tls.toml",
|
|
579
|
+
value: tlsText,
|
|
580
|
+
schema,
|
|
581
|
+
readOnly: true,
|
|
582
|
+
},
|
|
583
|
+
]);
|
|
584
|
+
const update = (id: string, change: Partial<DocumentSpec>) =>
|
|
585
|
+
setFiles((list) =>
|
|
586
|
+
list.map((file) => (file.id === id ? { ...file, ...change } : file)),
|
|
587
|
+
);
|
|
588
|
+
const tabs = useRef<ConfigDocumentsHandle>(null);
|
|
589
|
+
<ConfigDocuments
|
|
590
|
+
ref={tabs}
|
|
591
|
+
documents={files}
|
|
592
|
+
onChange={(id, value) => update(id, { value })}
|
|
593
|
+
onSave={async (id, value) => {
|
|
594
|
+
await putFile(id, value);
|
|
595
|
+
update(id, { baseline: value });
|
|
596
|
+
}}
|
|
597
|
+
onClose={({ id, dirty }) => {
|
|
598
|
+
if (dirty && !confirm(`Discard unsaved changes to ${id}?`)) return;
|
|
599
|
+
setFiles((list) => list.filter((file) => file.id !== id));
|
|
600
|
+
}}
|
|
601
|
+
/>;
|
|
602
|
+
tabs.current?.saveAll(); // the dirty documents; returns their ids
|
|
603
|
+
tabs.current?.select("tls");
|
|
604
|
+
tabs.current?.activeId;
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
Tabs over one editor per document, each with its own language, baseline,
|
|
608
|
+
read-only state, schema and, optionally, settings; switching keeps each document's caret, undo
|
|
609
|
+
history, scroll and folds. The parent owns the list (a late parent never
|
|
610
|
+
rolls a document back); nothing closes by itself (`onClose` gets
|
|
611
|
+
`{ id, dirty }`). `Alt+PageDown` / `Alt+PageUp` switch documents; the tab list
|
|
612
|
+
takes arrows, `Home`, `End`, `Enter` and `Delete`. Props: `documents`,
|
|
613
|
+
`activeId`, `onSelect`, `onClose` (a document with `closable: false` has no
|
|
614
|
+
close button), `onAdd` (the "+" after the tabs, shown only with it: add the
|
|
615
|
+
new document, which opens selected), `onChange`, `onSave`, `onDirtyChange`,
|
|
616
|
+
`onEditAsChange`, `onSyncChange`, `onProblems` (a document's id and its
|
|
617
|
+
editor's own problems), every [setting](#settings) (for all the editors and
|
|
618
|
+
the tabs: `colors` takes
|
|
619
|
+
the `tab-*` tokens too; live), `label`, `viewClassName`, `className`,
|
|
620
|
+
`style`, `onError`. A document's own `settings` go over the view's for its
|
|
621
|
+
editor; `hostDiagnostics`, `readOnlyPaths`, `readOnlyRanges` and `secrets`
|
|
622
|
+
work per document as on `<ConfigEditor>`. A new `activeId` shows that
|
|
623
|
+
document, leaving the focus where it is. `ref.current.editor(id)` returns
|
|
624
|
+
that document's editor, an `EditorView` (`null` for an id not listed):
|
|
625
|
+
`value`, `rangeOf`, `reveal`, `fold`, `currentPath`, `unifiedDiff`, …; its
|
|
626
|
+
its paths, folds and `reveal` answer `null` until the document has been shown once (at once with `editAsText`; `value`, `unifiedDiff`, `isDirty` and `save` answer for the document as listed). `ref.current.setValue(id, text)` replaces a document's text, always (a reset to a text the user passed through), and reports it through `onChange`. Per document, `onEditAsChange(id, language)` says the language on screen (once when its editor mounts, then on each change: a switch made, one that waited, undo or redo across a switch) and `onSyncChange(id, inSync)` whether the text on screen is written back to its `value`. A prop that did not change is not sent again, so after an undo stepped back across a switch, `editAs(id, language)` on the ref asks for it again. A document's `editAsText` (with `editAs`) opens its editor with the text the user had on screen (kept from `editor(id).text`), converted back once it is valid; `readOnlyReason` shows why a read-only document is read-only (its tab's tooltip, the notice when the user types, the accessible descriptions). See the [`@pngwasi/config-editor` README](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#several-documents).
|
|
627
|
+
|
|
628
|
+
For example:
|
|
629
|
+
|
|
630
|
+
```tsx
|
|
631
|
+
<ConfigDocuments ref={tabs} documents={files} showFooter theme="nord" />;
|
|
632
|
+
tabs.current?.editor("main")?.reveal("/public_address");
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
See the [`@pngwasi/config-editor` README](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#several-documents).
|
|
636
|
+
To fill a set height (the component's element, styled through its class), give
|
|
637
|
+
the view `height: 100%`
|
|
638
|
+
(`.config-editor-documents { height: 100%; }`): the tab strip keeps its height
|
|
639
|
+
and the shown editor takes the rest; see
|
|
640
|
+
[Size](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#size).
|
|
641
|
+
|
|
642
|
+
## Keyboard and screen readers
|
|
643
|
+
|
|
644
|
+
The keys are those of [`@pngwasi/config-editor`](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#keyboard).
|
|
645
|
+
`Tab` indents while editing; to leave the editor with the keyboard,
|
|
646
|
+
`Ctrl+M` switches `Tab` and `Shift+Tab` to moving the focus (announced, and
|
|
647
|
+
shown in the footer as "Tab moves focus" until `Ctrl+M` again), and right
|
|
648
|
+
after an `Escape` that had nothing to close one `Tab` or `Shift+Tab` leaves.
|
|
649
|
+
The text area's `aria-describedby` holds what is at the caret (each problem's
|
|
650
|
+
message, host ones with their source, a read-only value's reason, a secret
|
|
651
|
+
placeholder's hint), `F8` announces "Error 2 of 5: …", and `Ctrl+K Ctrl+I`
|
|
652
|
+
shows and reads the schema docs of the key at the caret. Nothing to set:
|
|
653
|
+
|
|
654
|
+
```tsx
|
|
655
|
+
<label htmlFor="after">Next field</label>
|
|
656
|
+
<ConfigEditor value={text} onChange={setText} />
|
|
657
|
+
<input id="after" /> {/* Ctrl+M, Tab (or Escape, Tab) lands here */}
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
## Exports
|
|
661
|
+
|
|
662
|
+
This package exports its components (`ConfigEditor`, `ConfigDocuments`),
|
|
663
|
+
their props and handle types (`ConfigEditorProps`, `ConfigEditorHandle`,
|
|
664
|
+
`ConfigDocumentsProps`, `ConfigDocumentsHandle`), and the types of what
|
|
665
|
+
they take and return: `EditorSettings`, `EditorStrings`, `ThemeName`,
|
|
666
|
+
`ThemeColorMap`, `LanguageName`, `DocumentSpec`, `CloseRequest`,
|
|
667
|
+
`ChangeSummary`, `BaselineConflict`, `FieldPath`, `EditorPath`,
|
|
668
|
+
`EditorRange`, `LineRange`, `EditorView` (what `editor(id)` returns),
|
|
669
|
+
`HostDiagnostic`, `Diagnostic` (a problem the editor reports), `Severity`, `SecretOptions`, `TextRangeInput`.
|
|
670
|
+
|
|
671
|
+
The helpers come from `@pngwasi/config-editor`, a peer dependency:
|
|
672
|
+
`loadConfigEditor`, `languages()`, `themes()`, `languageForFile` and
|
|
673
|
+
`registerLanguage` from its main entry, and the tools (`validate`,
|
|
674
|
+
`convert`, `parse`, `serialize`, `unifiedDiff`, `changeSummary`, `rangeOf`, `rangesOf`,
|
|
675
|
+
`pathAt`, `schemaWarnings`, `presetCss`) from
|
|
676
|
+
`@pngwasi/config-editor/tools`, called after `loadConfigEditor()` has
|
|
677
|
+
resolved; see the [`@pngwasi/config-editor` README](https://github.com/paradoxe35/config-editor/tree/main/js/config-editor#pngwasiconfig-editortools).
|
|
678
|
+
|
|
679
|
+
```ts
|
|
680
|
+
import { loadConfigEditor, themes } from "@pngwasi/config-editor";
|
|
681
|
+
import { validate } from "@pngwasi/config-editor/tools";
|
|
682
|
+
|
|
683
|
+
await loadConfigEditor();
|
|
684
|
+
const problems = validate("toml", text, schema);
|
|
685
|
+
const names = themes().map((theme) => theme.label);
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
## License
|
|
689
|
+
|
|
690
|
+
MIT. See [LICENSE](LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { BaselineConflict, ChangeSummary, CloseRequest, Diagnostic, DocumentSpec, EditorPath, EditorSettings, FieldPath, HostDiagnostic, LanguageName, SecretOptions, TextRangeInput } from "@pngwasi/config-editor";
|
|
2
|
+
import { type ConfigDocumentsHandle, type ConfigEditorHandle } from "@pngwasi/config-editor/binding";
|
|
3
|
+
import { type CSSProperties } from "react";
|
|
4
|
+
export type { BaselineConflict, ChangeSummary, CloseRequest, Diagnostic, DocumentSpec, EditorPath, EditorRange, EditorSettings, EditorStrings, EditorView, FieldPath, HostDiagnostic, LanguageName, LineRange, SecretOptions, Severity, TextRangeInput, ThemeColorMap, ThemeName, } from "@pngwasi/config-editor";
|
|
5
|
+
export type { ConfigDocumentsHandle, ConfigEditorHandle } from "@pngwasi/config-editor/binding";
|
|
6
|
+
/**
|
|
7
|
+
* Props of `<ConfigEditor>`: the document and its callbacks, and every
|
|
8
|
+
* setting (`EditorSettings`: `theme`, `showFooter`, `folding`, …), which
|
|
9
|
+
* apply live.
|
|
10
|
+
*/
|
|
11
|
+
export interface ConfigEditorProps extends EditorSettings {
|
|
12
|
+
/** The document, in `language` (controlled). */
|
|
13
|
+
value?: string;
|
|
14
|
+
/** The initial document when uncontrolled. */
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
/** Called with the document, in `language`, after every edit, and its `revision`: store both and pass the revision back as `valueRevision` for an exact echo match. */
|
|
17
|
+
onChange?: (value: string, revision: number) => void;
|
|
18
|
+
/** The `revision` `onChange` gave `value` with (see `onChange`): with it, a late echo is matched exactly, with no pause. Keep the newest revision you were given and never go back to an older one. Leave it out for a value of your own. */
|
|
19
|
+
valueRevision?: number;
|
|
20
|
+
/** Language of the document. Default `"yaml"`. Changing it re-mounts. */
|
|
21
|
+
language?: LanguageName;
|
|
22
|
+
/** Edit in another language; switches live. */
|
|
23
|
+
editAs?: LanguageName | null;
|
|
24
|
+
/** Called with the language on screen: once on mount, then each time an `editAs` switch completes and when undo or redo steps back across one (a switch waits while the document cannot convert, the host's language staying on screen). */
|
|
25
|
+
onEditAsChange?: (language: LanguageName) => void;
|
|
26
|
+
/** Called with whether the text on screen is written back to the document: once on mount, then each time that changes. `false` while an `editAs` edit cannot convert back (`onChange` waits), whatever brought it there (typing, paste, undo, a switch, a reload, a new value); read after each pause in typing. Always `true` while editing in `language`. */
|
|
27
|
+
onSyncChange?: (inSync: boolean) => void;
|
|
28
|
+
/** Called with how the document differs from `baseline`: on mount, then whenever that changes. */
|
|
29
|
+
onChangeSummary?: (summary: ChangeSummary) => void;
|
|
30
|
+
/** Called with the editor's own problems (syntax, schema, secret placeholders, conversion; never `hostDiagnostics`): on mount, then each time they change. */
|
|
31
|
+
onProblems?: (problems: Diagnostic[]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Called with the path of what the caret is on each time it changes (and
|
|
34
|
+
* once on mount), for a breadcrumb. The path is computed only while set.
|
|
35
|
+
*/
|
|
36
|
+
onPathChange?: (path: EditorPath) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Problems the host found (its own checks: a service, a build step), by path
|
|
39
|
+
* or range, shown next to the editor's own and marked as the host's. A new list replaces
|
|
40
|
+
* the previous one; only the markers update.
|
|
41
|
+
*/
|
|
42
|
+
hostDiagnostics?: HostDiagnostic[];
|
|
43
|
+
/**
|
|
44
|
+
* Fields the user cannot change, each with everything inside it, on top of
|
|
45
|
+
* those the schema marks `readOnly`. They hold while editing as another
|
|
46
|
+
* language too. Updates live.
|
|
47
|
+
*/
|
|
48
|
+
readOnlyPaths?: FieldPath[];
|
|
49
|
+
/** Stretches of the document (in `language`) the user cannot change. Updates live. */
|
|
50
|
+
readOnlyRanges?: TextRangeInput[];
|
|
51
|
+
/**
|
|
52
|
+
* How secret placeholders are matched, described and completed. Changing
|
|
53
|
+
* `placeholder`, `hint` or `referencePrefixes`, or adding or removing
|
|
54
|
+
* `isPlaceholder`, re-mounts; a new `isPlaceholder` function in its place
|
|
55
|
+
* does not (the latest one is called).
|
|
56
|
+
*/
|
|
57
|
+
secrets?: SecretOptions;
|
|
58
|
+
/** JSON Schema as JSON or YAML text. Changing it re-mounts. */
|
|
59
|
+
schema?: string;
|
|
60
|
+
/** Called once per thing in `schema` the editor cannot use (an unsupported `patternProperties` regex). Default: a console warning. */
|
|
61
|
+
onSchemaWarning?: (message: string) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Text the diff gutter compares against: the version last saved or loaded.
|
|
64
|
+
* A new one while the user has unsaved edits opens a notice (Reload / Keep
|
|
65
|
+
* mine) instead of mixing them; see `onBaselineConflict`.
|
|
66
|
+
*/
|
|
67
|
+
baseline?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Called when the user presses `Ctrl+S` / `Cmd+S` (the browser's dialog
|
|
70
|
+
* prevented) or you call `ref.save()`, with the document in `language`.
|
|
71
|
+
* Nothing saves by itself. Without it, `Ctrl+S` is the browser's.
|
|
72
|
+
*/
|
|
73
|
+
onSave?: (value: string, language: LanguageName) => void;
|
|
74
|
+
/** Called with whether the document differs from `baseline`: once on mount, then each time that changes. */
|
|
75
|
+
onDirtyChange?: (dirty: boolean) => void;
|
|
76
|
+
/** Called when a new `baseline` arrives under unsaved edits, and when that conflict is settled. */
|
|
77
|
+
onBaselineConflict?: (event: BaselineConflict) => void;
|
|
78
|
+
/** Shown in the toolbar. Changing it re-mounts. */
|
|
79
|
+
fileName?: string;
|
|
80
|
+
/** View mode; switches live. */
|
|
81
|
+
readOnly?: boolean;
|
|
82
|
+
/** Why the editor is read-only, while `readOnly` is on: shown with the "Cannot edit in a read-only editor" notice and in the text area's accessible description. Updates live. */
|
|
83
|
+
readOnlyReason?: string | null;
|
|
84
|
+
/** Class on the editor root (inside the container). Changing it re-mounts. */
|
|
85
|
+
editorClassName?: string;
|
|
86
|
+
/** Class and style of the container element. */
|
|
87
|
+
className?: string;
|
|
88
|
+
style?: CSSProperties;
|
|
89
|
+
/**
|
|
90
|
+
* Called with an error from mounting or from a prop the editor rejects
|
|
91
|
+
* (an unknown language, theme or color token, an invalid schema). Without
|
|
92
|
+
* it errors are logged; they never unmount your React tree.
|
|
93
|
+
*/
|
|
94
|
+
onError?: (error: unknown) => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A schema-aware config editor for YAML, JSON, TOML, HCL and XML.
|
|
98
|
+
*
|
|
99
|
+
* ```tsx
|
|
100
|
+
* <ConfigEditor language="yaml" schema={schema} value={text} onChange={setText} />
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare const ConfigEditor: import("react").ForwardRefExoticComponent<ConfigEditorProps & import("react").RefAttributes<ConfigEditorHandle>>;
|
|
104
|
+
/**
|
|
105
|
+
* Props of `<ConfigDocuments>`: the documents and callbacks, and the settings
|
|
106
|
+
* (`EditorSettings`) of every editor and of the tabs; a document's own
|
|
107
|
+
* `settings` override them. They apply live.
|
|
108
|
+
*/
|
|
109
|
+
export interface ConfigDocumentsProps extends EditorSettings {
|
|
110
|
+
/** The open documents, in tab order (controlled: keep each `value` up to date from `onChange`). */
|
|
111
|
+
documents: DocumentSpec[];
|
|
112
|
+
/** The document shown first (default: the first one); a new id shows that document, leaving the focus where it is. */
|
|
113
|
+
activeId?: string;
|
|
114
|
+
/** Called with a document's id when it becomes the active one. */
|
|
115
|
+
onSelect?: (id: string) => void;
|
|
116
|
+
/**
|
|
117
|
+
* Called when the user asks to close a document (close button, middle
|
|
118
|
+
* click, `Delete` on its tab). Nothing closes by itself: remove it from
|
|
119
|
+
* `documents`, asking first when `request.dirty`. Without it, tabs have no
|
|
120
|
+
* close button. Only `closable` documents ask. Changing whether it is
|
|
121
|
+
* set re-mounts.
|
|
122
|
+
*/
|
|
123
|
+
onClose?: (request: CloseRequest) => void;
|
|
124
|
+
/**
|
|
125
|
+
* Called when the user asks for a new document: the "+" button after the
|
|
126
|
+
* last tab, shown only with it (it stays at the strip's end when the tabs
|
|
127
|
+
* overflow). It only asks: add the new document to `documents`; the next
|
|
128
|
+
* one added is selected and its editor focused. Changing whether it is
|
|
129
|
+
* set re-mounts.
|
|
130
|
+
*/
|
|
131
|
+
onAdd?: () => void;
|
|
132
|
+
/** Called with a document's id and text after every edit. */
|
|
133
|
+
onChange?: (id: string, value: string) => void;
|
|
134
|
+
/** Called when the user saves a document (`Ctrl+S` / `Cmd+S`) or you call `ref.save(id)` / `ref.saveAll()`. */
|
|
135
|
+
onSave?: (id: string, value: string, language: LanguageName) => void;
|
|
136
|
+
/** Called with a document's id and whether it differs from its baseline: when it is added, then each time that changes. */
|
|
137
|
+
onDirtyChange?: (id: string, dirty: boolean) => void;
|
|
138
|
+
/** Called with a document's id and its editor's own problems: once its editor mounts (when first shown, or at once when listed with `editAsText`), then each time they change. */
|
|
139
|
+
onProblems?: (id: string, problems: Diagnostic[]) => void;
|
|
140
|
+
/** Called with a document's id and the language on screen in its editor: once when the editor mounts (the first time the document is shown, or at once when listed with `editAsText`), then each time that changes (a switch made, one that waited until the text converted, undo or redo across a switch). */
|
|
141
|
+
onEditAsChange?: (id: string, language: LanguageName) => void;
|
|
142
|
+
/** Called with a document's id and whether the text on screen is written back to its `value`: once when its editor mounts, then each time that changes. */
|
|
143
|
+
onSyncChange?: (id: string, inSync: boolean) => void;
|
|
144
|
+
/** The tab list's accessible name. Default `"Open files"`. Changing it re-mounts. */
|
|
145
|
+
label?: string;
|
|
146
|
+
/** Class on the view's root (inside the container). Changing it re-mounts. */
|
|
147
|
+
viewClassName?: string;
|
|
148
|
+
/** Class and style of the container element. */
|
|
149
|
+
className?: string;
|
|
150
|
+
style?: CSSProperties;
|
|
151
|
+
/** Called with an error from mounting or from a prop the view rejects. Without it errors are logged. */
|
|
152
|
+
onError?: (error: unknown) => void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Several documents as tabs, one editor per document (each keeps its caret,
|
|
156
|
+
* undo history, scroll and folds across switches).
|
|
157
|
+
*
|
|
158
|
+
* ```tsx
|
|
159
|
+
* <ConfigDocuments documents={files} onChange={(id, value) => update(id, value)} onSave={upload} onClose={close} />
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export declare const ConfigDocuments: import("react").ForwardRefExoticComponent<ConfigDocumentsProps & import("react").RefAttributes<ConfigDocumentsHandle>>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DocumentsBinding, EditorBinding, } from "@pngwasi/config-editor/binding";
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
4
|
+
/**
|
|
5
|
+
* A schema-aware config editor for YAML, JSON, TOML, HCL and XML.
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <ConfigEditor language="yaml" schema={schema} value={text} onChange={setText} />
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export const ConfigEditor = forwardRef(function ConfigEditor(props, ref) {
|
|
12
|
+
const host = useRef(null);
|
|
13
|
+
// Everything an editor needs from a component (live props, re-mounts,
|
|
14
|
+
// the bound value through the editor's `echoes`), shared with the Vue and Svelte
|
|
15
|
+
// packages: `EditorBinding` from `@pngwasi/config-editor/binding`.
|
|
16
|
+
const binding = useRef(null);
|
|
17
|
+
binding.current ?? (binding.current = new EditorBinding("config-editor-react", props));
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
binding.current.attach(host.current, props);
|
|
20
|
+
return () => binding.current.detach();
|
|
21
|
+
}, []);
|
|
22
|
+
useEffect(() => binding.current.update(props));
|
|
23
|
+
useImperativeHandle(ref, () => binding.current.handle, []);
|
|
24
|
+
return _jsx("div", { ref: host, className: props.className, style: props.style });
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Several documents as tabs, one editor per document (each keeps its caret,
|
|
28
|
+
* undo history, scroll and folds across switches).
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <ConfigDocuments documents={files} onChange={(id, value) => update(id, value)} onSave={upload} onClose={close} />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const ConfigDocuments = forwardRef(function ConfigDocuments(props, ref) {
|
|
35
|
+
const host = useRef(null);
|
|
36
|
+
const binding = useRef(null);
|
|
37
|
+
binding.current ?? (binding.current = new DocumentsBinding("config-editor-react", props));
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
binding.current.attach(host.current, props);
|
|
40
|
+
return () => binding.current.detach();
|
|
41
|
+
}, []);
|
|
42
|
+
useEffect(() => binding.current.update(props));
|
|
43
|
+
useImperativeHandle(ref, () => binding.current.handle, []);
|
|
44
|
+
return _jsx("div", { ref: host, className: props.className, style: props.style });
|
|
45
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pngwasi/config-editor-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "React component for config-editor: schema-aware YAML, JSON, TOML, HCL and XML editing",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p ."
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@pngwasi/config-editor": "^0.1.1",
|
|
25
|
+
"react": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"config",
|
|
30
|
+
"editor",
|
|
31
|
+
"react",
|
|
32
|
+
"yaml",
|
|
33
|
+
"json",
|
|
34
|
+
"toml",
|
|
35
|
+
"hcl",
|
|
36
|
+
"xml",
|
|
37
|
+
"json-schema",
|
|
38
|
+
"wasm"
|
|
39
|
+
],
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/paradoxe35/config-editor.git",
|
|
43
|
+
"directory": "js/config-editor-react"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/paradoxe35/config-editor#readme",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/paradoxe35/config-editor/issues"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|