@witty-works/editor 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@ One self-contained script: no framework, no stylesheet to include. As a script t
10
10
 
11
11
  ```html
12
12
  <div id="editor"></div>
13
- <script src="https://cdn.jsdelivr.net/npm/@witty-works/editor@2.6.0/dist/witty-editor.js"></script>
13
+ <script src="https://cdn.jsdelivr.net/npm/@witty-works/editor@2.6.1/dist/witty-editor.js"></script>
14
14
  <script>
15
15
  const editor = WittyEditor.mount(document.getElementById('editor'), {
16
16
  endpoint: 'https://your-nlp-api.example/',
@@ -49,7 +49,7 @@ For the script tag in a TypeScript project, the same types describe the global:
49
49
 
50
50
  | Option | Default | |
51
51
  |---|---|---|
52
- | `endpoint` | page origin | NLP API base URL, with trailing slash |
52
+ | `endpoint` | page origin | NLP API base URL; a relative one resolves against the page, and a missing trailing slash is added. Anything but an `http(s)` URL throws a `TypeError` |
53
53
  | `apiKey` | none | Sent as `x-key`; prefer `setApiKey` |
54
54
  | `lang` | `'auto'` | Text language: `auto`, `en`, `de`, `fr` or a variant such as `de-CH` |
55
55
  | `config` | none | Check config (gender formats, disabled categories, …); only fields you set are sent |
@@ -69,13 +69,13 @@ For the script tag in a TypeScript project, the same types describe the global:
69
69
  It returns a handle:
70
70
 
71
71
  - `setApiKey(key)`: replace the API key and check again.
72
- - `setConfig(config)`: replace the whole check config (no merging) and check again; `{}` sends none.
72
+ - `setConfig(config)`: replace the whole check config (no merging) and check again; `{}` sends none. The same config again changes nothing, so a host can pass its config on every render. The editor keeps a copy: changing the object afterwards has no effect.
73
73
  - `updateSettings(settings)`: change settings from the host, e.g. its own form, as the settings panel does (the panel follows). The fields given replace the current ones and the rest stay: `updateSettings({llmAlternatives: true})`, `updateSettings({orthography: false})`. `config`, when given, is replaced whole, as with `setConfig`; to change one field of it, start from `getSettings().config`. Calls `onSettingsChange` once if anything changed, and nothing happens if nothing did. A changed `config` checks the text again; popovers opened afterwards follow `llmAlternatives`, an open one keeps what it shows. A value of the wrong type (`llmAlternatives: 'false'`, a `config` that is not an object) throws a `TypeError` and changes nothing. Unlike `setConfig`, which is for the host's own changes, this reports to `onSettingsChange`, so a host that stores the settings there sees changes from its form and from the panel alike.
74
74
  - `getSettings()`: the current settings, `{config, llmAlternatives, orthography}`, as a copy; the same object `onSettingsChange` receives.
75
75
  - `getText()`: the document as plain text.
76
- - `switchGenderFormat(target)`: rewrite the text into a German or French gender format, as the menu does (see below); `target` is a `german_gender_ending` or `french_gender_separator` value. Resolves with `{outcome, target, count, limitReached}`; `outcome` is `switched`, `nothing`, `fromInklusivum` (nothing switched, and the text was in the Inklusivum, which the API cannot convert out of yet), `disabled` (the account keeps these alerts off), `forced` (the account forces another format, given as `applied`; nothing is changed), `unsupported` (the API cannot switch to this target yet) or `unavailable` (not a gender format).
76
+ - `switchGenderFormat(target)`: rewrite the text into a German or French gender format, as the menu does (see below); `target` is a `german_gender_ending` or `french_gender_separator` value. Resolves with `{outcome, target, count, limitReached}`; `outcome` is `switched`, `nothing`, `fromInklusivum` (nothing switched, and the text was in the Inklusivum, which the API cannot convert out of yet), `disabled` (the account keeps these alerts off), `forced` (the account forces another format, given as `applied`; nothing is changed), `unsupported` (the API cannot switch to this target yet) or `unavailable` (not a gender format). Rejects if the switch's check fails (e.g. a refused key or a timeout; the previous settings are restored and nothing is rewritten) or the editor is destroyed meanwhile (an error named `EditorDestroyedError`).
77
77
  - `editor`: the underlying [TipTap](https://tiptap.dev) editor.
78
- - `destroy()`: remove the editor and everything it added to the page.
78
+ - `destroy()`: remove the editor and everything it added to the page. A switch still running rejects.
79
79
 
80
80
  ## Status and errors
81
81
 
@@ -87,7 +87,7 @@ It returns a handle:
87
87
  | `{state: 'unauthorized'}` | The API refused the key (401) or the token behind it (403) | Cleared |
88
88
  | `{state: 'outdated', message}` | The API no longer supports this editor version (400); `message` is the API's explanation. The page needs to load a newer version | Cleared |
89
89
  | `{state: 'unsupportedLanguage'}` | The API could not tell the text's language (422) | Cleared |
90
- | `{state: 'error', message}` | Anything else, e.g. the API is unreachable or answered 5xx | Kept until the next check |
90
+ | `{state: 'error', message}` | Anything else, e.g. the API is unreachable, answered 5xx, or gave no answer within 30 seconds | Kept until the next check |
91
91
 
92
92
  The W icon and the live region say the same to the user. Checks send `client: "witty-editor:<version>"`, so the API can require a minimum version for the editor separately from the browser extension (`web-ext`).
93
93