@witty-works/editor 2.3.0 → 2.4.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 CHANGED
@@ -8,7 +8,7 @@ One self-contained script: no framework, no stylesheet to include.
8
8
 
9
9
  ```html
10
10
  <div id="editor"></div>
11
- <script src="https://cdn.jsdelivr.net/npm/@witty-works/editor@2.3.0/dist/witty-editor.js"></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/@witty-works/editor@2.4.0/dist/witty-editor.js"></script>
12
12
  <script>
13
13
  const editor = WittyEditor.mount(document.getElementById('editor'), {
14
14
  endpoint: 'https://your-nlp-api.example/',
@@ -38,7 +38,8 @@ Pin an exact version, as above, rather than a range: the script runs with access
38
38
  | `delay` | `500` | Debounce after the last edit, in ms |
39
39
  | `maxRequestLength` | `1000` | Characters per check request; set it to the API's `TEXT_MAX_LENGTH` if that differs (see Long texts) |
40
40
  | `maxTextLength` | `20000` | Characters of the text checked at all |
41
- | `onStatus` | none | `{state: 'idle', alerts, limitReached}`, `{state: 'unauthorized'}` or `{state: 'error', message}`; after a gender format switch, the idle status also has `genderFormatSwitch` |
41
+ | `installationId` | random per editor | Opaque id sent with each check, as the extension sends its installation id; it only ends up in the API's request logs. Pass a stable one to tell installations apart across page loads, never personal data |
42
+ | `onStatus` | none | The check's state (see Status and errors) |
42
43
  | `onSettingsChange` | none | Called with the settings when the user changes one, e.g. to store them |
43
44
 
44
45
  It returns a handle:
@@ -51,6 +52,20 @@ It returns a handle:
51
52
  - `editor`: the underlying [TipTap](https://tiptap.dev) editor.
52
53
  - `destroy()`: remove the editor and everything it added to the page.
53
54
 
55
+ ## Status and errors
56
+
57
+ `onStatus` receives:
58
+
59
+ | Status | When | Alerts |
60
+ |---|---|---|
61
+ | `{state: 'idle', alerts, limitReached}` | A check finished; after a gender format switch it also has `genderFormatSwitch` | Shown |
62
+ | `{state: 'unauthorized'}` | The API refused the key (401) or the token behind it (403) | Cleared |
63
+ | `{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 |
64
+ | `{state: 'unsupportedLanguage'}` | The API could not tell the text's language (422) | Cleared |
65
+ | `{state: 'error', message}` | Anything else, e.g. the API is unreachable or answered 5xx | Kept until the next check |
66
+
67
+ 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`).
68
+
54
69
  ## The Witty menu
55
70
 
56
71
  The W icon at the end of the toolbar shows whether Witty is checking, and opens a menu (a keyboard-operable ARIA menu: arrow keys, Home and End move, Escape closes and returns focus to the icon):