@witty-works/editor 2.2.1 → 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 +24 -5
- package/dist/witty-editor.js +50 -50
- package/package.json +1 -1
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.
|
|
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
|
-
| `
|
|
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,15 +52,29 @@ 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):
|
|
57
72
|
|
|
58
73
|
- **Settings…**: Witty's categories and preferences, as in the browser extension.
|
|
59
|
-
- **Switch gender format…**: rewrites every gendered form in the text into one of the eight German separator formats (`/in`, `/-in`, `_in`, `*in`, `:in`, `(-)`, `()`, `In`), labelled as in the settings. The Inklusivum (`de-e`) is listed but not available yet.
|
|
74
|
+
- **Switch gender format…**: rewrites every gendered form in the text into one of the eight German separator formats (`/in`, `/-in`, `_in`, `*in`, `:in`, `(-)`, `()`, `In`), labelled as in the settings. It also genders roles in the generic masculine (`Der Lehrer` → `Die:der Lehrer:in`) and pair formulas (`Schüler und Schülerinnen` → `Schüler:innen`), as far as the API marks them. The Inklusivum (`de-e`) is listed but not available yet.
|
|
60
75
|
- **Help** and **About**: the Witty Works help on the editor and the website, in a new tab.
|
|
61
76
|
|
|
62
|
-
A switch makes the chosen format the configured one, waits until the whole text has been checked (every batch of a long text), and then applies all alerts the API marked with `bulk: "gender_format"` in one transaction, so a single undo restores the text. The result is announced in the live region and passed to `onStatus` as `genderFormatSwitch
|
|
77
|
+
A switch makes the chosen format the configured one, waits until the whole text has been checked (every batch of a long text), and then applies all alerts the API marked with `bulk: "gender_format"` in one transaction, so a single undo restores the text. The result is announced once, in the editor's live region, and passed to `onStatus` as `genderFormatSwitch`; `count` includes the gendered masculines. If only part of the text was checked (`limitReached`), what was checked is switched and the message says so.
|
|
63
78
|
|
|
64
79
|
The switch's checks ask for the gender-format alerts even where the account turned them off: `gendered_denominations_ending_advanced` is taken out of `disabled_categories` and `gendered_roles_format` is `inclusive_gender`, for those requests only; the user's settings stay as they are. If the API still sends none, because the account's stored configuration forces them off, the editor says "Switching the gender format is turned off for this account".
|
|
65
80
|
|
|
@@ -69,7 +84,11 @@ An organisation or user config can also force the gender format. The API then co
|
|
|
69
84
|
|
|
70
85
|
The editor decides what to apply by `bulk` alone, never by subcategory:
|
|
71
86
|
|
|
72
|
-
- A check result with `bulk: "gender_format"` belongs to the switch to the configured `german_gender_ending
|
|
87
|
+
- A check result with `bulk: "gender_format"` belongs to the switch to the configured `german_gender_ending`: a form in another separator format, a role in the generic masculine, or a pair formula the API recognises.
|
|
88
|
+
- `bulk_alternative` is the index into its `alternatives` of the one the switch applies. The editor applies `alternatives[bulk_alternative]` when the index is an integer within range and that alternative has a `text`, and skips the result otherwise.
|
|
89
|
+
- Without `bulk_alternative` (API versions before it), a result is applied only if it has exactly one alternative, which is then the form in the target format.
|
|
90
|
+
- Such results never overlap, and applying all of them in any order gives the same text.
|
|
91
|
+
- Feminine forms, address forms, pronouns and pair formulas the API didn't recognise are left out by the API on purpose; the editor applies nothing it isn't marked for.
|
|
73
92
|
- `bulk` is absent (or `null`) on every other result. Unknown `bulk` values are ignored.
|
|
74
93
|
- Every check response lists the groups the request can return in `bulk_actions`, whether or not a result does: `["gender_format"]` for German with a separator format, inclusive roles and the gender-format alerts on, `[]` otherwise. After the switch's check, a list without `"gender_format"` means the account keeps the switch off.
|
|
75
94
|
- `gender_separator` in the check response is the format the API applied; for German it is a `german_gender_ending` value.
|