@quillmark/svelte 0.36.0 → 0.37.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 +18 -14
- package/THEMING.md +1 -1
- package/dist/core/codec/decode.d.ts +4 -2
- package/dist/core/codec/decode.js +5 -2
- package/dist/core/codec/field.d.ts +14 -10
- package/dist/core/codec/field.js +34 -24
- package/dist/core/codec/index.d.ts +3 -3
- package/dist/core/codec/index.js +2 -2
- package/dist/core/codec/prose.css +20 -4
- package/dist/core/codec/review.d.ts +4 -5
- package/dist/core/codec/review.js +6 -21
- package/dist/core/codec/schema.d.ts +12 -2
- package/dist/core/codec/schema.js +27 -5
- package/dist/core/codec/shortcuts.d.ts +3 -2
- package/dist/core/codec/shortcuts.js +3 -2
- package/dist/core/codec/table-view.js +15 -3
- package/dist/core/theme.css +44 -17
- package/dist/core/tooltip.css +49 -0
- package/dist/core/tooltip.d.ts +6 -0
- package/dist/core/tooltip.js +176 -0
- package/dist/preview/Preview.svelte +22 -1
- package/dist/preview/controller.js +38 -0
- package/dist/preview/strings.d.ts +2 -0
- package/dist/preview/strings.js +1 -0
- package/dist/visual/ArrayField.svelte +262 -145
- package/dist/visual/Card.svelte +21 -11
- package/dist/visual/CardControls.svelte +3 -3
- package/dist/visual/DateField.svelte +47 -5
- package/dist/visual/DiagnosticList.svelte +3 -2
- package/dist/visual/EnumField.svelte +6 -1
- package/dist/visual/EnumField.svelte.d.ts +2 -0
- package/dist/visual/Field.svelte +3 -3
- package/dist/visual/FieldHint.svelte +22 -13
- package/dist/visual/FieldLabel.svelte +6 -42
- package/dist/visual/FieldLabel.svelte.d.ts +0 -3
- package/dist/visual/FormatPopover.svelte +53 -20
- package/dist/visual/MatrixAdd.svelte +9 -10
- package/dist/visual/MatrixField.svelte +114 -18
- package/dist/visual/NumberField.svelte +21 -5
- package/dist/visual/ObjectField.svelte +6 -2
- package/dist/visual/ProseField.svelte +6 -3
- package/dist/visual/ProseField.svelte.d.ts +2 -1
- package/dist/visual/ProseValue.svelte +13 -6
- package/dist/visual/ProseValue.svelte.d.ts +4 -1
- package/dist/visual/ReviewCard.svelte +93 -33
- package/dist/visual/ReviewCard.svelte.d.ts +2 -1
- package/dist/visual/ReviewProposal.svelte +0 -6
- package/dist/visual/TipsCard.svelte +1 -1
- package/dist/visual/VariantField.svelte +1 -0
- package/dist/visual/VisualEditor.svelte +12 -6
- package/dist/visual/VisualEditor.svelte.d.ts +5 -1
- package/dist/visual/VisualEditorInner.svelte +218 -302
- package/dist/visual/VisualEditorInner.svelte.d.ts +5 -1
- package/dist/visual/controls.css +2 -2
- package/dist/visual/guidance.d.ts +0 -2
- package/dist/visual/guidance.js +0 -10
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +14 -4
- package/dist/visual/proposals.js +28 -5
- package/dist/visual/props.d.ts +1 -1
- package/dist/visual/review-order.d.ts +51 -0
- package/dist/visual/review-order.js +87 -0
- package/dist/visual/review.d.ts +27 -1
- package/dist/visual/review.js +1 -1
- package/dist/visual/review.svelte.d.ts +34 -17
- package/dist/visual/review.svelte.js +187 -44
- package/dist/visual/strings.d.ts +38 -19
- package/dist/visual/strings.js +81 -24
- package/dist/visual/structure.d.ts +17 -3
- package/dist/visual/structure.js +71 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ const preview = createPreview(session, {
|
|
|
89
89
|
preview.refresh(session.update(doc)); // repaint dirtyPages ∩ visible
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
In Svelte, `<Preview {session} onPick={…} />` exposes the same verbs (`refresh`, `scrollToField`, `focusPosition`, `endFollow`, `setZoom`) via `bind:this`.
|
|
92
|
+
In Svelte, `<Preview {session} onPick={…} />` exposes the same verbs (`refresh`, `scrollToField`, `focusPosition`, `washField`, `endFollow`, `setZoom`) via `bind:this`.
|
|
93
93
|
|
|
94
94
|
`<Preview>` binds **once**, at mount: swapping `session`, `margin`, `onPick`, `onError` or `strings` in place changes nothing on screen and reports `rebind-ignored` through `onError` at `dev` severity, naming the prop. Swap by remounting (`{#key session}`); drive in-place edits through `refresh(change)`. `class` and `style` are the exceptions, landing on the root element and staying live.
|
|
95
95
|
|
|
@@ -145,7 +145,7 @@ Hand it a different `doc` and the editor **re-keys itself**: every leaf remounts
|
|
|
145
145
|
<button onclick={() => editor?.focusField('main.subject')}>Jump to subject</button>
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
`insertCard` hands back the new card's `cardId`; `removeCard`, `moveCard` and `setKind` take one. `focusField` reaches any mounted field: a prose leaf takes its view's focus, a form control the same handoff a click on its label takes, and either way the group holding it is revealed first. `washField` plays the same arrival wash over a field and nothing else, for a change the host wrote: focus, scroll and closed groups stay as they are, and a field in a closed group washes nothing. A card key or a path the surface does not hold is a no-op that reports `target-unknown` through `onError` at `dev` severity.
|
|
148
|
+
`insertCard` hands back the new card's `cardId`; `removeCard`, `moveCard` and `setKind` take one. `focusField` reaches any mounted field: a prose leaf takes its view's focus, a form control the same handoff a click on its label takes, and either way the group holding it is revealed first. `revealField` reveals, scrolls to and washes a field without focusing it, so a touch screen raises no keyboard. `washField` plays the same arrival wash over a field and nothing else, for a change the host wrote: focus, scroll and closed groups stay as they are, and a field in a closed group washes nothing. A card key or a path the surface does not hold is a no-op that reports `target-unknown` through `onError` at `dev` severity.
|
|
149
149
|
|
|
150
150
|
### Review
|
|
151
151
|
|
|
@@ -174,6 +174,7 @@ type ReviewItem =
|
|
|
174
174
|
| {
|
|
175
175
|
id: string;
|
|
176
176
|
field: DocPath;
|
|
177
|
+
card?: string;
|
|
177
178
|
replace: string[];
|
|
178
179
|
before?: string;
|
|
179
180
|
after: string;
|
|
@@ -181,20 +182,21 @@ type ReviewItem =
|
|
|
181
182
|
| {
|
|
182
183
|
id: string;
|
|
183
184
|
field: DocPath;
|
|
185
|
+
card?: string;
|
|
184
186
|
insert: { after: string } | { before: string } | 'end';
|
|
185
187
|
after: string;
|
|
186
188
|
}
|
|
187
|
-
| { id: string; field: DocPath; before?: unknown; after?: unknown }
|
|
188
|
-
| { id: string; add: Card; after?: number }
|
|
189
|
-
| { id: string; remove: number };
|
|
189
|
+
| { id: string; field: DocPath; card?: string; before?: unknown; after?: unknown }
|
|
190
|
+
| { id: string; add: Card; after?: number; afterCard?: string }
|
|
191
|
+
| { id: string; remove: number; card?: string };
|
|
190
192
|
```
|
|
191
193
|
|
|
192
194
|
- **A proposal in text** reads the blocks `replace` names as rewritten to `after`, Markdown: the words that would go are struck, the words that would come are tinted, and blocks it adds stand in flow where they would land. `''` proposes the blocks' removal. `insert` proposes new blocks after or before the block it names, or at the field's end; in a field holding one empty paragraph it proposes that paragraph's text. A paragraph takes one proposal that rewrites it and one that adds after it, the first of each, whole. A word the proposal keeps and formats anew is drawn as a word it changes. The proposal is an edit of `before`, the blocks as its writer read them, or without one of the paragraph as it stood when the item arrived: what the reader writes in the paragraph meanwhile and while it stands is theirs, neither struck nor lost when the proposal is taken. Where the reader's writing meets the proposal's own words, the answer card says **Changed since proposed** and `onReviewDrawn` names the item `outdated`; where it reaches past them, the proposal reads as the whole paragraph as it now stands giving way to the whole of `after`. A block `replace` names that is gone, or that `before` does not read as, makes the proposal outdated too; a block an undo puts back under a new id is still the block it named. A proposal that would write nothing, its paragraph already reading as proposed, draws nothing.
|
|
193
195
|
- **A proposal for a field** is drawn in its control as what Accept would write, and is outdated where the field no longer holds its `before`. A one-line or multi-line text field is drawn as a word diff in the field, the words that would go struck and the words that would come tinted in their own formatting; the diff is carried from `before`, as a paragraph's is, so what the reader types beside it is theirs and kept by Accept, and the proposal is outdated only where that typing meets its words. A number strikes its figures and tints the proposed ones. A choice, a date, a switch, or a record or list proposed whole shows in its control as the value that would come under the review tint, a cleared one as the default it would print or the empty control, and a field on its default drops its Default tag meanwhile. A commit on a choice, a date or a switch answers its proposal: the proposed value accepts it, any other value is written and dismisses it, and ⌘Z takes either back. Accept writes the whole value.
|
|
194
196
|
- **A proposal for a place inside a field** names it by its path, `main.contact.email` or `main.signature_block[2]`, and is drawn in the control of that place as a field's is: a record's cell, a list's row, ringed and struck where the member goes, or for a member past the last, a row after the list's last in the controls it would have, holding the proposed value under the review tint and taking no input. A choice with variants takes its discriminant at `main.distribution.value` and each cell of its world beside it, and a checklist each member at `main.checks.figures`, drawn on its tick, and each cell inside one. Where no control of its own is drawn, inside a closed row, it marks the nearest one. Accept writes the field's whole value with that place alone changed, down the lane an edit of the place takes. In a list, `after` absent takes the member out, and an index past the last appends one. A member's `before` finds it: where the member at the index no longer holds it, the nearest that does and that no other open proposal of the list has found, so taking one member out does not move the next proposal onto the wrong row. One whose `before` nothing holds is outdated. An item in a closed group marks the group's header, and stepping to it opens the group.
|
|
195
|
-
- **A proposed card** is drawn where it would stand: `add` as a preview of the card, its title, each field it fills by name and the start of its body, after the card at index `after` (before the first card without one), and `remove` as a ring round the card at that index, its values
|
|
197
|
+
- **A proposed card** is drawn where it would stand: `add` as a preview of the card, its title, each field it fills by name and the start of its body, after the card at index `after` (before the first card without one), and `remove` as a ring round the card at that index, its values struck and _Proposed removal_ in its header. Accept writes it as the reader's own card operation, the added card under the `$id` it carries, and `onChange` reports it as a `structure` change; ⌘Z takes it back. Cards added after the same card stand in the list's order.
|
|
196
198
|
|
|
197
|
-
`proposalsBetween(quill, base, answer)`, from `@quillmark/svelte/visual`, makes the list from an assistant's answer. `base` is the document as the assistant read it, a snapshot taken when it was asked, and `answer` a copy of it the assistant edited; neither is the live document, which the editor compares each item with as it draws, so what the reader typed meanwhile is theirs and a place both changed is `outdated`. It returns `{ items }`, with `before` filled in: one `replace` per block the answer rewrote or took out and one `insert` per run of blocks it added, an item per record cell and list member that changed elsewhere, at the paths of `base`, and an item per card it added, after the card of `base` it follows, and per card it took out.
|
|
199
|
+
`proposalsBetween(quill, base, answer)`, from `@quillmark/svelte/visual`, makes the list from an assistant's answer. `base` is the document as the assistant read it, a snapshot taken when it was asked, and `answer` a copy of it the assistant edited; neither is the live document, which the editor compares each item with as it draws, so what the reader typed meanwhile is theirs and a place both changed is `outdated`. It returns `{ items }`, with `before` filled in: one `replace` per block the answer rewrote or took out and one `insert` per run of blocks it added, an item per record cell and list member that changed elsewhere, at the paths of `base`, and an item per card it added, after the card of `base` it follows, and per card it took out. An item names its card one of two ways. `card` beside a `field`, `card` on a removal and `afterCard` on an added card name it by its `$id`, wherever it stands when the item is drawn, and `proposalsBetween` fills them in for every card of `base` that has one: the list holds over a live document whose cards were added, removed or moved since the snapshot. Without one, the path's index, `remove` and `after` name the card by index, read against the cards as they stood when the list was set, and a card added, removed or moved between the snapshot and then is not carried. Either way the editor keeps each item on its card through every card added, removed or moved while the list stands, by `applyCardOps`, by the reader or by an accepted card item. An item whose card is gone goes `undrawn` as `field`, a removal whose card is gone as `applied`, and a card added after one that is gone stands last.
|
|
198
200
|
|
|
199
201
|
```ts
|
|
200
202
|
const base = doc.clone(); // when the assistant is asked
|
|
@@ -203,6 +205,8 @@ const { items } = proposalsBetween(quill, base, answer);
|
|
|
203
205
|
review = items;
|
|
204
206
|
```
|
|
205
207
|
|
|
208
|
+
Every item may carry a `note`, why its writer made it, which the answer card shows above its answers cut to one line, and a `group`, the kind of change it is, a name of the host's. `proposalsBetween`'s fourth argument takes `{ mint, label }`, where `label(item)` returns the `note` and `group` for each item it makes from what the host knows of the edit behind it, a block id or a field path it wrote; a function there is `mint` alone.
|
|
209
|
+
|
|
206
210
|
The editor makes every write an answer asks for:
|
|
207
211
|
|
|
208
212
|
| `action` | What the reader did | What is written |
|
|
@@ -211,7 +215,7 @@ The editor makes every write an answer asks for:
|
|
|
211
215
|
| `dismiss` | Turned a proposal down. | Nothing. |
|
|
212
216
|
| `reopen` | Undid an accept or a dismissal with ⌘Z. | Before the event, what an accept wrote is taken back by its own undo. The item is open again. |
|
|
213
217
|
|
|
214
|
-
Every answer to the current item moves on to the next open one, in the page's order and round from the end, without moving the caret or the focus, so a review is a run of answers. A review starts on its first item. The caret entering an item or a press on one makes it current at once
|
|
218
|
+
Every answer to the current item moves on to the next open one, in the page's order and round from the end, without moving the caret or the focus, so a review is a run of answers. A review starts on its first item. The caret entering an item or a press on one makes it current at once; the pointer over one does not, and leaving an item keeps it current.
|
|
215
219
|
|
|
216
220
|
An answered item is drawn no more from the moment of the answer: a dismissed one wrote nothing, and an accepted one is plain text in the document, the reader's like any other. The editor keeps no record of what an accept replaced; a host that offers to take a whole answer back keeps its own snapshot of the document from before it.
|
|
217
221
|
|
|
@@ -221,15 +225,15 @@ The host sets the list once and clears it once. It sets it when an answer arrive
|
|
|
221
225
|
|
|
222
226
|
`onReviewDrawn` reports what the editor draws of the list, on each change once the leaves have drawn: `open`, the items drawn in document order, each still waiting for an answer, so a host's bar shows Keep once it is empty; `outdated`, the open proposals the reader's own writing meets; and `undrawn`, every listed item it does not draw, each with why: `block` (no block it names stands in its field, or no leaf of the field is mounted), `field` (the path names no field the editor holds, or a place inside one its schema does not declare), `parse` (`after` is not Markdown the leaf reads), `taken` (an earlier item has the paragraph or the field) or `applied` (the text already reads as proposed). A host's count and its next and previous read `open`, so they agree with the page.
|
|
223
227
|
|
|
224
|
-
The verbs complete it. `answerReview(ids | 'all', 'accept' | 'dismiss')` answers items as the answer card would, in document order, and returns the ids answered: `onReview` hears each, an item that cannot be answered stands, `'all'` with `'accept'` leaves every outdated item open, and neither the focus nor the caret moves; answering the current item moves on as the card does. `stepReview(1 | -1)` brings the next or previous drawn item to the reader, round from either end, with the caret in it or the focus in its field (`{ focus: false }` only lights it), and resolves its id; it scrolls the item's own scroller only as far as it must to show it, so an editor in a pane that scrolls on its own steps within that pane. `revealReview(id)` brings one item to the reader: it opens the group holding the item, scrolls it to the middle of the pane and lights it, and resolves `false` for an item the editor does not draw; `{ focus: true }` also puts the caret in it.
|
|
228
|
+
The verbs complete it. `answerReview(ids | 'all' | { group }, 'accept' | 'dismiss')` answers items as the answer card would, in document order, and returns the ids answered: `onReview` hears each, an item that cannot be answered stands, `'all'` or `{ group }` with `'accept'` leaves every outdated item open, and neither the focus nor the caret moves; answering the current item moves on as the card does. `stepReview(1 | -1)` brings the next or previous drawn item to the reader, round from either end, with the caret in it or the focus in its field (`{ focus: false }` only lights it, and `{ group }` passes over every item of another group), and resolves its id; it scrolls the item's own scroller only as far as it must to show it, so an editor in a pane that scrolls on its own steps within that pane. `revealReview(id)` brings one item to the reader: it opens the group holding the item, scrolls it to the middle of the pane and lights it, and resolves `false` for an item the editor does not draw; `{ focus: true }` also puts the caret in it.
|
|
225
229
|
|
|
226
|
-
The **answer card** floats on the current item, below it or above it where there is no room, with **Dismiss** and **Accept** and their keys. It scrolls with the item and is clipped at the pane's edge as the text is. It keeps clear of `reviewInset`, the px the host's chrome takes at the foot of the pane, while the item shows, steps aside while the reader types, and never takes the focus: a press on it leaves the focus where it was, and Alt+F10 puts the keyboard on it, Escape handing the focus back. Under a finger it drops the key hints and its buttons are tap-sized.
|
|
230
|
+
The **answer card** floats on the current item, below the paragraph or block it stands in, beside that paragraph's last line where the line ends short of it, centred on the line of a one-line field so it stands inside the field rather than over the next field's label, or above it where there is no room, so it covers none of the item's own paragraph, with **Dismiss** and **Accept** and their keys, and the item's `note` above them on one line. It scrolls with the item and is clipped at the pane's edge as the text is. It keeps clear of `reviewInset`, the px the host's chrome takes at the foot of the pane, while the item shows, steps aside while the reader types, and never takes the focus: a press on it leaves the focus where it was, and Alt+F10 puts the keyboard on it, Escape handing the focus back. Under a finger, or on a screen with no hover, it drops the key hints and its buttons are tap-sized.
|
|
227
231
|
|
|
228
|
-
While a review is open, `REVIEW_KEYS` answer the current item from anywhere on the page but another editor or a text box outside this one: ⌘/Ctrl+Enter accepts it, ⌘/Ctrl
|
|
232
|
+
While a review is open, `REVIEW_KEYS` answer the current item from anywhere on the page but another editor or a text box outside this one: ⌘/Ctrl+Enter accepts it, ⌘/Ctrl+Backspace dismisses it, and ⌘/Ctrl+⌥/Alt+↓ and ↑ step to the next and previous item, moving the caret along when pressed in the editor. The two answer keys are the card's, so they answer an item the card stands on in view: with the item scrolled out of the pane the first press brings it back and the next answers it, and while the reader types in the editor, where the card steps aside, both stay the leaf's own keys. A proposal that only adds blocks is current from anywhere in the paragraph it adds after; where a proposal also rewrites that paragraph, the caret names the rewrite, and `revealReview(id, { focus: true })` puts it in the one asked for. Every word the review draws is a `strings` key, and its one hue is `--qm-review` ([THEMING.md](THEMING.md)).
|
|
229
233
|
|
|
230
234
|
### Wording
|
|
231
235
|
|
|
232
|
-
The package ships English and a seam to replace it. `strings` is keyed and **partial**: set what you have translations for, and the rest stay the package's. Several keys are **accessible names** rather than decoration (the card controls, the add trigger), so an untranslated surface reads the wrong language to a screen reader. `DEFAULT_VISUAL_STRINGS` is the English, exported so you can compose against it. `<Preview>` takes its own `strings`: the states it shows when there is nothing to paint, the zoom pill's action, and
|
|
236
|
+
The package ships English and a seam to replace it. `strings` is keyed and **partial**: set what you have translations for, and the rest stay the package's. Several keys are **accessible names** rather than decoration (the card controls, the add trigger), so an untranslated surface reads the wrong language to a screen reader. A string is words alone: a glyph drawn beside it, the `+` on every add control, is the control's own. `DEFAULT_VISUAL_STRINGS` is the English, exported so you can compose against it. A control's name is the name alone: where it has a shortcut the editor prints the keys beside the name in the control's tooltip and states them as `aria-keyshortcuts`, both read off the binding, so a translation carries no chord. `<Preview>` takes its own `strings`: the states it shows when there is nothing to paint, the zoom pill's action, and what a screen reader hears: the names of the pane and each page, and the pages standing again after a state it was told of.
|
|
233
237
|
|
|
234
238
|
```svelte
|
|
235
239
|
<VisualEditor
|
|
@@ -237,14 +241,14 @@ The package ships English and a seam to replace it. `strings` is keyed and **par
|
|
|
237
241
|
{quill}
|
|
238
242
|
strings={{
|
|
239
243
|
cardDelete: 'Supprimer la carte',
|
|
240
|
-
addCard: '
|
|
244
|
+
addCard: 'Ajouter une carte'
|
|
241
245
|
}}
|
|
242
246
|
formatDiagnostic={(d) =>
|
|
243
247
|
d.code === 'validation::type_mismatch' ? `${d.path} : type incorrect` : undefined}
|
|
244
248
|
/>
|
|
245
249
|
```
|
|
246
250
|
|
|
247
|
-
`formatDiagnostic` gets the whole `Diagnostic` and returns `undefined` to take its own message. Validation and edit diagnostics re-word from `code`, `path` and `args`; parse errors and render warnings carry their detail inside English text and stand as they are ([INVARIANTS.md](prose/INVARIANTS.md#diagnostics)).
|
|
251
|
+
`formatDiagnostic` gets the whole `Diagnostic` and returns `undefined` to take its own message. Validation and edit diagnostics re-word from `code`, `path` and `args`; parse errors and render warnings carry their detail inside English text and stand as they are ([INVARIANTS.md](prose/INVARIANTS.md#diagnostics)). A screen reader hears the errors the page draws from one hidden status region, once they have changed and held still, in the words of `diagAnnounced`, which is handed each error's field label and text.
|
|
248
252
|
|
|
249
253
|
### Fonts
|
|
250
254
|
|
package/THEMING.md
CHANGED
|
@@ -81,7 +81,7 @@ One thing still outranks us: an **unlayered** blanket reset of your own (`* { pa
|
|
|
81
81
|
|
|
82
82
|
Ink steps `fg → bg` and the borders and hover fills step `bg → fg`, mixed in **oklab**, so inverting the two poles inverts all of them together.
|
|
83
83
|
|
|
84
|
-
**Planes are the exception**, and deliberately: the raised plane is the brighter one in both schemes, which is what makes a card read as a card rather than as a differently-tinted page. So the column under the cards sinks from `--qm-bg` toward shadow and a floating surface rises from it toward light, and neither reads the ink pole. How far each steps is a function of the card's own lightness — a dark card has to spend more before the plane above it reads as lifted — so a palette pinned at neither pole takes a proportionate step without being told which scheme it is in.
|
|
84
|
+
**Planes are the exception**, and deliberately: the raised plane is the brighter one in both schemes, which is what makes a card read as a card rather than as a differently-tinted page. So the column under the cards sinks from `--qm-bg` toward shadow and a floating surface rises from it toward light, and neither reads the ink pole. How far each steps is a function of the card's own lightness — a dark card has to spend more before the plane above it reads as lifted — so a palette pinned at neither pole takes a proportionate step without being told which scheme it is in. The label ink a floating surface holds lifts by the step the surface took, so a menu's shortcut or a popover's note stands as far off its plane as a field's label stands off the card: whatever contrast your poles give a label on a card, they give it on a menu.
|
|
85
85
|
|
|
86
86
|
Which way the poles default is **your `color-scheme`**, not the operating system's. Declare the scheme your app is in and the surface lands on it, along with native chrome, which reads the same property:
|
|
87
87
|
|
|
@@ -23,8 +23,9 @@ export declare function fitsInline(rt: Content): boolean;
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function fitsPlain(rt: Content): boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Whether a leaf so declared edits `rt` losing nothing: {@link fitsInline} narrowed
|
|
27
|
-
* fitsPlain} plain
|
|
26
|
+
* Whether a leaf so declared edits `rt` losing nothing: {@link fitsInline} narrowed, {@link
|
|
27
|
+
* fitsPlain} plain and upstream's `isLines` on a leaf of `paragraphs`, past which the decode drops
|
|
28
|
+
* what the first commit would store. On the block
|
|
28
29
|
* schema, anything but a construct read and not edited (`isEditedIsland`) and an island where the
|
|
29
30
|
* leaf mounts no island view (`islands`), which draws as a placeholder atom a keystroke deletes
|
|
30
31
|
* unseen.
|
|
@@ -32,5 +33,6 @@ export declare function fitsPlain(rt: Content): boolean;
|
|
|
32
33
|
export declare function fitsLeaf(rt: Content, leaf: {
|
|
33
34
|
inline: boolean;
|
|
34
35
|
plaintext: boolean;
|
|
36
|
+
paragraphs?: boolean;
|
|
35
37
|
islands: boolean;
|
|
36
38
|
}): boolean;
|
|
@@ -75,8 +75,9 @@ export function fitsPlain(rt) {
|
|
|
75
75
|
return core().isPlain({ ...rt, marks: [] });
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* Whether a leaf so declared edits `rt` losing nothing: {@link fitsInline} narrowed
|
|
79
|
-
* fitsPlain} plain
|
|
78
|
+
* Whether a leaf so declared edits `rt` losing nothing: {@link fitsInline} narrowed, {@link
|
|
79
|
+
* fitsPlain} plain and upstream's `isLines` on a leaf of `paragraphs`, past which the decode drops
|
|
80
|
+
* what the first commit would store. On the block
|
|
80
81
|
* schema, anything but a construct read and not edited (`isEditedIsland`) and an island where the
|
|
81
82
|
* leaf mounts no island view (`islands`), which draws as a placeholder atom a keystroke deletes
|
|
82
83
|
* unseen.
|
|
@@ -86,6 +87,8 @@ export function fitsLeaf(rt, leaf) {
|
|
|
86
87
|
return fitsInline(rt);
|
|
87
88
|
if (leaf.plaintext)
|
|
88
89
|
return fitsPlain(rt);
|
|
90
|
+
if (leaf.paragraphs)
|
|
91
|
+
return core().isLines(rt);
|
|
89
92
|
const islands = rt.islands ?? [];
|
|
90
93
|
if (!leaf.islands && islands.length)
|
|
91
94
|
return false;
|
|
@@ -6,7 +6,7 @@ import type { EditorErrorHandler } from '../errors.js';
|
|
|
6
6
|
import { type Delta } from './positions.js';
|
|
7
7
|
import { type TextCap } from './cap.js';
|
|
8
8
|
import { type LeaveStrings } from './leave.js';
|
|
9
|
-
import { type ReviewAction, type ReviewReport, type
|
|
9
|
+
import { type ReviewAction, type ReviewReport, type TextReview } from './review.js';
|
|
10
10
|
import { type ValueProposal, type ValueState } from './value-diff.js';
|
|
11
11
|
import { type TableChromeStrings } from './table-view.js';
|
|
12
12
|
import { type SlashState, type SlashStrings } from './slash.js';
|
|
@@ -25,6 +25,9 @@ export interface CreateFieldOpts {
|
|
|
25
25
|
/** A mark-free schema (a `text` field): literal text, no formatting and no
|
|
26
26
|
* anchors, in paragraphs and hard breaks or, with `inline`, one textblock. */
|
|
27
27
|
plaintext?: boolean;
|
|
28
|
+
/** A `richtext` field of `shape: lines`: formatted paragraphs and hard breaks, with no
|
|
29
|
+
* list, heading, quote, code block or island. */
|
|
30
|
+
paragraphs?: boolean;
|
|
28
31
|
/** The id of the note the caller draws inside `container` for a held leaf →
|
|
29
32
|
* `aria-describedby` while it holds. */
|
|
30
33
|
heldNoteId?: string;
|
|
@@ -93,9 +96,9 @@ export interface CreateFieldOpts {
|
|
|
93
96
|
onReview?(id: string, action: ReviewAction): void;
|
|
94
97
|
/** The leaf is writing a taken proposal, and is done: the commit between is the answer's. */
|
|
95
98
|
onReviewWriting?(on: boolean): void;
|
|
96
|
-
/** The review item
|
|
97
|
-
*
|
|
98
|
-
onReviewPoint?(id: string | undefined
|
|
99
|
+
/** The review item holding the caret, `undefined` once it has left. The report holds off
|
|
100
|
+
* while the reader types inside the item. */
|
|
101
|
+
onReviewPoint?(id: string | undefined): void;
|
|
99
102
|
/** What the leaf draws of the review items, on each change: the ids drawn, and the items
|
|
100
103
|
* whose anchor the leaf holds that it does not draw, each with why. An item whose anchor
|
|
101
104
|
* the leaf does not hold is in neither. */
|
|
@@ -225,17 +228,18 @@ export declare function emptyContent(): Content;
|
|
|
225
228
|
/** Whether `rt` is the empty leaf: {@link emptyContent}, nothing typed and no shape left. */
|
|
226
229
|
export declare function isEmptyContent(rt: Content): boolean;
|
|
227
230
|
/**
|
|
228
|
-
* The
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
+
* The `contenteditable`'s role and naming attributes, shared with `ProseValue`. A `div` takes no
|
|
232
|
+
* name without a role, so every leaf states itself a textbox, one-line or not by `multiline`.
|
|
233
|
+
* `aria-labelledby` supersedes `aria-label`. A leaf on a schema of paragraphs and hard breaks
|
|
234
|
+
* alone carries `data-qm-lines`, which sets its paragraphs single spaced (`prose.css`).
|
|
231
235
|
*/
|
|
232
236
|
export declare function proseAttributes(opts: {
|
|
233
237
|
label?: string;
|
|
234
238
|
labelledBy?: string;
|
|
235
239
|
describedBy?: string;
|
|
236
|
-
}): Record<string, string
|
|
237
|
-
/** A held leaf's attributes, described by its note as well. A
|
|
238
|
-
*
|
|
240
|
+
}, multiline: boolean, lines?: boolean): Record<string, string>;
|
|
241
|
+
/** A held leaf's attributes, described by its note as well. A held leaf draws its structure
|
|
242
|
+
* in the block schema, and a non-editable view is no tab stop, so it states both itself. */
|
|
239
243
|
export declare function heldAttributes(opts: {
|
|
240
244
|
label?: string;
|
|
241
245
|
labelledBy?: string;
|
package/dist/core/codec/field.js
CHANGED
|
@@ -16,6 +16,7 @@ import { EditorState, NodeSelection, Plugin, PluginKey, Selection, TextSelection
|
|
|
16
16
|
import { Decoration, DecorationSet, EditorView } from 'prosemirror-view';
|
|
17
17
|
import { revealProps } from './reveal.js';
|
|
18
18
|
import { core } from '../lifecycle.js';
|
|
19
|
+
import { tooltips } from '../tooltip.js';
|
|
19
20
|
import { reportError, errorMessage } from '../errors.js';
|
|
20
21
|
import { decode, fitsLeaf } from './decode.js';
|
|
21
22
|
import { offsetToPM, pmToOffset, buildLineIndex, lineIndexOf, mapThroughDelta } from './positions.js';
|
|
@@ -32,7 +33,7 @@ import { FIELD_KEYS, markKeymap } from './shortcuts.js';
|
|
|
32
33
|
import { remoteKey } from './remote.js';
|
|
33
34
|
import { renameBlocks, reviewLayer } from './review.js';
|
|
34
35
|
import { valueDiffPlugin } from './value-diff.js';
|
|
35
|
-
import { blockSchema, isBlockSchema, isInlineSchema,
|
|
36
|
+
import { blockSchema, isBlockSchema, isInlineSchema, isParagraphsSchema, leafSchema } from './schema.js';
|
|
36
37
|
import { linkPastePlugin } from './link-paste.js';
|
|
37
38
|
import { dragMovePlugin } from './drag-move.js';
|
|
38
39
|
import { linePastePlugin } from './line-paste.js';
|
|
@@ -196,29 +197,30 @@ function changeCommittable(doc, addr) {
|
|
|
196
197
|
return stored !== null && typeof stored === 'object';
|
|
197
198
|
}
|
|
198
199
|
/**
|
|
199
|
-
* The
|
|
200
|
-
*
|
|
201
|
-
*
|
|
200
|
+
* The `contenteditable`'s role and naming attributes, shared with `ProseValue`. A `div` takes no
|
|
201
|
+
* name without a role, so every leaf states itself a textbox, one-line or not by `multiline`.
|
|
202
|
+
* `aria-labelledby` supersedes `aria-label`. A leaf on a schema of paragraphs and hard breaks
|
|
203
|
+
* alone carries `data-qm-lines`, which sets its paragraphs single spaced (`prose.css`).
|
|
202
204
|
*/
|
|
203
|
-
export function proseAttributes(opts) {
|
|
204
|
-
const attrs = {};
|
|
205
|
+
export function proseAttributes(opts, multiline, lines = false) {
|
|
206
|
+
const attrs = { role: 'textbox', 'aria-multiline': String(multiline) };
|
|
207
|
+
if (lines)
|
|
208
|
+
attrs['data-qm-lines'] = '';
|
|
205
209
|
if (opts.labelledBy)
|
|
206
210
|
attrs['aria-labelledby'] = opts.labelledBy;
|
|
207
211
|
else if (opts.label)
|
|
208
212
|
attrs['aria-label'] = opts.label;
|
|
209
213
|
if (opts.describedBy)
|
|
210
214
|
attrs['aria-describedby'] = opts.describedBy;
|
|
211
|
-
return
|
|
215
|
+
return attrs;
|
|
212
216
|
}
|
|
213
|
-
/** A held leaf's attributes, described by its note as well. A
|
|
214
|
-
*
|
|
217
|
+
/** A held leaf's attributes, described by its note as well. A held leaf draws its structure
|
|
218
|
+
* in the block schema, and a non-editable view is no tab stop, so it states both itself. */
|
|
215
219
|
export function heldAttributes(opts, noteId) {
|
|
216
220
|
const describedBy = [opts.describedBy, noteId].filter(Boolean).join(' ') || undefined;
|
|
217
221
|
return {
|
|
218
|
-
...proseAttributes({ ...opts, describedBy }),
|
|
219
|
-
role: 'textbox',
|
|
222
|
+
...proseAttributes({ ...opts, describedBy }, true),
|
|
220
223
|
'aria-readonly': 'true',
|
|
221
|
-
'aria-multiline': 'true',
|
|
222
224
|
tabindex: '0'
|
|
223
225
|
};
|
|
224
226
|
}
|
|
@@ -232,7 +234,8 @@ export function createField(opts) {
|
|
|
232
234
|
const inline = !!opts.inline;
|
|
233
235
|
const plaintext = !!opts.plaintext;
|
|
234
236
|
// The declared type picks the schema; `plaintext` suppresses every mark (`schema.ts`).
|
|
235
|
-
const
|
|
237
|
+
const paragraphs = !!opts.paragraphs;
|
|
238
|
+
const schema = leafSchema({ plaintext, inline, paragraphs });
|
|
236
239
|
const block = isBlockSchema(schema);
|
|
237
240
|
// Bound once: the reader reads live, so every read sees the commit before it.
|
|
238
241
|
const reader = opts.quill.reader(doc);
|
|
@@ -269,7 +272,8 @@ export function createField(opts) {
|
|
|
269
272
|
if (!parsed.has(markdown)) {
|
|
270
273
|
let node;
|
|
271
274
|
try {
|
|
272
|
-
|
|
275
|
+
const shape = paragraphs && !inline ? 'lines' : undefined;
|
|
276
|
+
node = decode(core().importMarkdown(markdown, shape).content, schema);
|
|
273
277
|
}
|
|
274
278
|
catch {
|
|
275
279
|
node = undefined;
|
|
@@ -280,7 +284,7 @@ export function createField(opts) {
|
|
|
280
284
|
},
|
|
281
285
|
act: (id, action) => opts.onReview?.(id, action),
|
|
282
286
|
writing: (on) => opts.onReviewWriting?.(on),
|
|
283
|
-
point: (id
|
|
287
|
+
point: (id) => opts.onReviewPoint?.(id),
|
|
284
288
|
drew: (report) => opts.onReviewDrawn?.(report)
|
|
285
289
|
});
|
|
286
290
|
let valueProposal;
|
|
@@ -292,14 +296,15 @@ export function createField(opts) {
|
|
|
292
296
|
// Judged of the value being mounted rather than read off a diagnostic: a routed set
|
|
293
297
|
// can predate the value it arrives with, and `validation::not_plain` stands in for
|
|
294
298
|
// `not_single_line` on a one-line `text` field.
|
|
295
|
-
const holds = (rt) => !fitsLeaf(rt, { inline, plaintext, islands: true });
|
|
299
|
+
const holds = (rt) => !fitsLeaf(rt, { inline, plaintext, paragraphs, islands: true });
|
|
296
300
|
let held = holds(reconciler.last);
|
|
297
|
-
const
|
|
301
|
+
const lines = isParagraphsSchema(schema);
|
|
302
|
+
const named = proseAttributes(opts, !inline, lines);
|
|
298
303
|
const defaultNamed = {
|
|
299
304
|
...proseAttributes({
|
|
300
305
|
...opts,
|
|
301
306
|
describedBy: [opts.describedBy, opts.defaultNoteId].filter(Boolean).join(' ') || undefined
|
|
302
|
-
}),
|
|
307
|
+
}, !inline, lines),
|
|
303
308
|
'data-default': ''
|
|
304
309
|
};
|
|
305
310
|
const heldNamed = heldAttributes(opts, opts.heldNoteId);
|
|
@@ -313,6 +318,10 @@ export function createField(opts) {
|
|
|
313
318
|
// where the derivation is out of reach (jsdom).
|
|
314
319
|
const lineBox = Number.parseFloat(getComputedStyle(container).lineHeight);
|
|
315
320
|
const clearance = Number.isFinite(lineBox) ? lineBox : undefined;
|
|
321
|
+
// An island's chrome names itself by tip, and a leaf mounted outside the editor has no shell
|
|
322
|
+
// that serves them.
|
|
323
|
+
const root = block ? container.closest('[data-qm-root]') : null;
|
|
324
|
+
const releaseTips = root ? tooltips(root) : undefined;
|
|
316
325
|
// Prepended, so what the caller draws inside `container` (a held leaf's note)
|
|
317
326
|
// follows the text it is about.
|
|
318
327
|
view = new EditorView((dom) => container.prepend(dom), {
|
|
@@ -820,6 +829,7 @@ export function createField(opts) {
|
|
|
820
829
|
};
|
|
821
830
|
},
|
|
822
831
|
destroy() {
|
|
832
|
+
releaseTips?.();
|
|
823
833
|
view.destroy();
|
|
824
834
|
}
|
|
825
835
|
};
|
|
@@ -873,8 +883,8 @@ export function proseLeafPlugins(schema, opts) {
|
|
|
873
883
|
// Each answers to something only the block schema holds.
|
|
874
884
|
if (isBlockSchema(schema))
|
|
875
885
|
list.push(gapCursor(), pastAtomPlugin(), islandPastePlugin(), tablePastePlugin(), tableCopyPlugin(), markdownPastePlugin(), wordPastePlugin(), listPastePlugin(), taskPlugin(), nestingPlugin());
|
|
876
|
-
if (schema
|
|
877
|
-
list.push(plainClipboardPlugin());
|
|
886
|
+
if (isParagraphsSchema(schema))
|
|
887
|
+
list.push(plainClipboardPlugin(schema));
|
|
878
888
|
if (isInlineSchema(schema))
|
|
879
889
|
list.push(linePastePlugin());
|
|
880
890
|
if (opts.placeholder)
|
|
@@ -882,18 +892,18 @@ export function proseLeafPlugins(schema, opts) {
|
|
|
882
892
|
return list;
|
|
883
893
|
}
|
|
884
894
|
/**
|
|
885
|
-
*
|
|
895
|
+
* The clipboard text of a leaf of paragraphs is literal both ways, spelled as the engine spells a `text` value:
|
|
886
896
|
* a lone `\n` a hard break, a blank line a paragraph boundary, and a run of `\n` its pairs as
|
|
887
897
|
* paragraph boundaries, an odd one over a hard break before them. Upstream's defaults split pasted
|
|
888
898
|
* text on any run of newlines and write a copy's breaks as nothing.
|
|
889
899
|
*/
|
|
890
|
-
function plainClipboardPlugin() {
|
|
891
|
-
const { paragraph, hard_break } =
|
|
900
|
+
function plainClipboardPlugin(schema) {
|
|
901
|
+
const { paragraph, hard_break } = schema.nodes;
|
|
892
902
|
const line = (text) => paragraph.create(null, text
|
|
893
903
|
.split('\n')
|
|
894
904
|
.flatMap((part, i) => [
|
|
895
905
|
...(i ? [hard_break.create()] : []),
|
|
896
|
-
...(part ? [
|
|
906
|
+
...(part ? [schema.text(part)] : [])
|
|
897
907
|
]));
|
|
898
908
|
return new Plugin({
|
|
899
909
|
props: {
|
|
@@ -11,16 +11,16 @@ export { DEFAULT_SLASH_STRINGS } from './slash.js';
|
|
|
11
11
|
export type { SlashState, SlashStrings } from './slash.js';
|
|
12
12
|
export { DEFAULT_LEAVE_STRINGS } from './leave.js';
|
|
13
13
|
export type { LeaveStrings } from './leave.js';
|
|
14
|
-
export type { BlockPlace, LeafUndrawn, ReviewAction, ReviewReport,
|
|
14
|
+
export type { BlockPlace, LeafUndrawn, ReviewAction, ReviewReport, TextReview } from './review.js';
|
|
15
15
|
export { wordDiff } from './review-diff.js';
|
|
16
16
|
export { valueDiffPlugin } from './value-diff.js';
|
|
17
17
|
export type { ValueProposal, ValueState } from './value-diff.js';
|
|
18
18
|
export { asContent, planValue, valueChanges } from './value-plan.js';
|
|
19
19
|
export type { ValuePlan, ValueChange } from './value-plan.js';
|
|
20
20
|
export type { DiffHunk } from './review-diff.js';
|
|
21
|
-
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
|
|
21
|
+
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, LIST_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
|
|
22
22
|
export type { EditorShortcut, ShortcutScope, ShortcutStrings } from './shortcuts.js';
|
|
23
|
-
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, hasMarks } from './schema.js';
|
|
23
|
+
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
|
|
24
24
|
export { rendersHref, storableUrl } from './urls.js';
|
|
25
25
|
export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent, usvLength } from './decode.js';
|
|
26
26
|
export { pmToContent, lower } from './encode.js';
|
package/dist/core/codec/index.js
CHANGED
|
@@ -31,10 +31,10 @@ export { asContent, planValue, valueChanges } from './value-plan.js';
|
|
|
31
31
|
// The rich editor's shortcuts as a host lists them, read off the tables the keymaps bind from;
|
|
32
32
|
// the visual tier's `strings` set extends their wording, and the formatting popover binds its
|
|
33
33
|
// link chord from `FIELD_KEYS`.
|
|
34
|
-
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
|
|
34
|
+
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, LIST_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
|
|
35
35
|
// Schemas (the decode/encode target; the VisualEditor mounts them). `hasMarks` is
|
|
36
36
|
// what a mark surface asks before offering itself over a leaf.
|
|
37
|
-
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, hasMarks } from './schema.js';
|
|
37
|
+
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
|
|
38
38
|
// The url edge: `rendersHref` is the link gate the prompt re-asks on submit, and
|
|
39
39
|
// `storableUrl` the encode the store's own refusal requires of the value it takes
|
|
40
40
|
// (`visual/links.ts`).
|
|
@@ -72,6 +72,12 @@ li.ProseMirror-selectednode::after {
|
|
|
72
72
|
margin-top: var(--_qm-space-3);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/* A leaf of lines sets its paragraphs single spaced, as the page does: in that shape a
|
|
76
|
+
paragraph break and a hard break are one line break. */
|
|
77
|
+
.ProseMirror[data-qm-lines] > * + * {
|
|
78
|
+
margin-top: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
/* A blockquote's UA indent was its only mark, and the reset above takes it. The rule
|
|
76
82
|
and the inset carry it instead: the same hairline every surface reads, so a quote
|
|
77
83
|
reads as set apart without a fill or a second box. */
|
|
@@ -339,7 +345,7 @@ li.ProseMirror-selectednode::after {
|
|
|
339
345
|
font-style: normal;
|
|
340
346
|
line-height: 1;
|
|
341
347
|
white-space: nowrap;
|
|
342
|
-
color: var(--_qm-ink-label);
|
|
348
|
+
color: var(--_qm-ink-label-raised);
|
|
343
349
|
pointer-events: none;
|
|
344
350
|
}
|
|
345
351
|
.qm-leave-hint:empty {
|
|
@@ -457,10 +463,13 @@ li.ProseMirror-selectednode::after {
|
|
|
457
463
|
/* The header row is the one weight distinction the island draws: `header` is a
|
|
458
464
|
separate field in the model rather than a flag on a row, so the surface says so.
|
|
459
465
|
It takes a tone with it, the band rung, a step toward the ink at both poles. The
|
|
460
|
-
rest of a table's type is paper's.
|
|
466
|
+
rest of a table's type is paper's. Its words hold the ink whatever the table inherits:
|
|
467
|
+
the band leaves the label rung under 4.5:1 at the dark pole, so a header in a table
|
|
468
|
+
that would go is struck and not stepped back. */
|
|
461
469
|
.qm-table-header-row .qm-table-cell {
|
|
462
470
|
font-weight: var(--_qm-weight-strong);
|
|
463
471
|
background: var(--_qm-surface-band);
|
|
472
|
+
color: var(--_qm-ink);
|
|
464
473
|
}
|
|
465
474
|
/* The corner cells take the frame's corner, inside its stroke, so a header's band or a
|
|
466
475
|
selection's wash keeps to the rounded edge rather than painting a square one over
|
|
@@ -846,10 +855,17 @@ li.ProseMirror-selectednode::after {
|
|
|
846
855
|
calc(-1 * var(--_qm-space)) 0 0 var(--_qm-review-lit),
|
|
847
856
|
var(--_qm-space) 0 0 var(--_qm-review-lit);
|
|
848
857
|
}
|
|
849
|
-
/* A block the proposal takes whole that
|
|
850
|
-
.
|
|
858
|
+
/* A block the proposal takes whole that is no line of words. A rule has nothing to read
|
|
859
|
+
and recedes. An island's words are struck where they stand, at the ink a struck word
|
|
860
|
+
takes, so a table that would go is still read cell by cell. */
|
|
861
|
+
.ProseMirror hr.qm-review-out {
|
|
851
862
|
opacity: var(--_qm-opacity-muted);
|
|
852
863
|
}
|
|
864
|
+
.ProseMirror div.qm-review-out {
|
|
865
|
+
color: var(--_qm-ink-label);
|
|
866
|
+
text-decoration: line-through;
|
|
867
|
+
text-decoration-color: var(--_qm-review-line);
|
|
868
|
+
}
|
|
853
869
|
/* The empty paragraph a proposal writes into shows the proposal, not the leaf's ghost. */
|
|
854
870
|
.ProseMirror .qm-review-held.qm-prose-placeholder[data-placeholder]::after {
|
|
855
871
|
content: none;
|
|
@@ -38,8 +38,6 @@ export type BlockPlace = {
|
|
|
38
38
|
* so, turned it down, or undid an answer, so the item is open again with whatever was written
|
|
39
39
|
* for it taken back by the leaf's own undo. */
|
|
40
40
|
export type ReviewAction = 'accept' | 'dismiss' | 'reopen';
|
|
41
|
-
/** What brought an item under attention: the pointer over it, or the caret in it. */
|
|
42
|
-
export type ReviewVia = 'pointer' | 'caret';
|
|
43
41
|
/** What the plugin reads and reports through; every reader is live. */
|
|
44
42
|
export interface ReviewChannel {
|
|
45
43
|
items(): readonly TextReview[];
|
|
@@ -51,8 +49,8 @@ export interface ReviewChannel {
|
|
|
51
49
|
act(id: string, action: ReviewAction): void;
|
|
52
50
|
/** The leaf is writing a taken proposal, and is done. */
|
|
53
51
|
writing?(on: boolean): void;
|
|
54
|
-
/** The item the
|
|
55
|
-
point(id: string | undefined
|
|
52
|
+
/** The item the caret is in, `undefined` once it has left. */
|
|
53
|
+
point(id: string | undefined): void;
|
|
56
54
|
/** What the leaf draws and what it holds and does not draw, on each change of either. */
|
|
57
55
|
drew(report: ReviewReport): void;
|
|
58
56
|
}
|
|
@@ -62,7 +60,8 @@ export interface ReviewChannel {
|
|
|
62
60
|
export type LeafUndrawn = 'parse' | 'taken' | 'applied' | 'block';
|
|
63
61
|
/** What a leaf draws of the items it was handed. */
|
|
64
62
|
export interface ReviewReport {
|
|
65
|
-
/** The ids drawn, in the order the
|
|
63
|
+
/** The ids drawn, in the leaf's order: what is added ahead of the first block, then each
|
|
64
|
+
* block's rewrite ahead of what is added after it. */
|
|
66
65
|
ids: readonly string[];
|
|
67
66
|
/** The drawn proposals the reader's own writing meets: words both changed, or a block one
|
|
68
67
|
* names gone or no longer the block it read. */
|
|
@@ -625,6 +625,7 @@ function draw(state, channel, bases) {
|
|
|
625
625
|
spans.push({
|
|
626
626
|
id: item.id,
|
|
627
627
|
adds: !covered.length,
|
|
628
|
+
ahead,
|
|
628
629
|
from: reach(covered[0] ?? last)[0],
|
|
629
630
|
to: reach(last)[1]
|
|
630
631
|
});
|
|
@@ -716,21 +717,15 @@ export function reviewLayer(channel) {
|
|
|
716
717
|
/** Tell the channel what the leaf draws, where that moved. */
|
|
717
718
|
const report = (state) => {
|
|
718
719
|
const { spans, outdated, undrawn } = drawn(state);
|
|
719
|
-
const
|
|
720
|
+
const turn = (s) => (s.ahead ? 0 : s.adds ? 2 : 1);
|
|
721
|
+
const placed = [...spans].sort((a, b) => a.from - b.from || turn(a) - turn(b));
|
|
722
|
+
const next = { ids: placed.map((s) => s.id), outdated, undrawn };
|
|
720
723
|
const joined = JSON.stringify(next);
|
|
721
724
|
if (joined === reported)
|
|
722
725
|
return;
|
|
723
726
|
reported = joined;
|
|
724
727
|
channel.drew(next);
|
|
725
728
|
};
|
|
726
|
-
let hovered;
|
|
727
|
-
const hover = (id) => {
|
|
728
|
-
if (id === hovered)
|
|
729
|
-
return;
|
|
730
|
-
hovered = id;
|
|
731
|
-
channel.point(id, 'pointer');
|
|
732
|
-
};
|
|
733
|
-
const idAt = (target) => (target instanceof Element ? target.closest('[data-qm-review]') : null)?.getAttribute('data-qm-review') ?? undefined;
|
|
734
729
|
let caret;
|
|
735
730
|
/** The item the reader typed in, quiet until the caret has left it. */
|
|
736
731
|
let muted;
|
|
@@ -748,7 +743,7 @@ export function reviewLayer(channel) {
|
|
|
748
743
|
if (next === caret)
|
|
749
744
|
return;
|
|
750
745
|
caret = next;
|
|
751
|
-
channel.point(next
|
|
746
|
+
channel.point(next);
|
|
752
747
|
};
|
|
753
748
|
const plugin = new Plugin({
|
|
754
749
|
key: reviewKey,
|
|
@@ -765,14 +760,6 @@ export function reviewLayer(channel) {
|
|
|
765
760
|
props: {
|
|
766
761
|
decorations,
|
|
767
762
|
handleDOMEvents: {
|
|
768
|
-
mouseover: (_view, e) => {
|
|
769
|
-
hover(idAt(e.target));
|
|
770
|
-
return false;
|
|
771
|
-
},
|
|
772
|
-
mouseleave: () => {
|
|
773
|
-
hover(undefined);
|
|
774
|
-
return false;
|
|
775
|
-
},
|
|
776
763
|
focus: (view) => {
|
|
777
764
|
follow(view, false);
|
|
778
765
|
return false;
|
|
@@ -800,10 +787,8 @@ export function reviewLayer(channel) {
|
|
|
800
787
|
follow(view, reviewKey.getState(prev)?.edits !== reviewKey.getState(view.state)?.edits);
|
|
801
788
|
},
|
|
802
789
|
destroy() {
|
|
803
|
-
if (hovered !== undefined)
|
|
804
|
-
channel.point(undefined, 'pointer');
|
|
805
790
|
if (caret !== undefined)
|
|
806
|
-
channel.point(undefined
|
|
791
|
+
channel.point(undefined);
|
|
807
792
|
if (reported !== NOTHING)
|
|
808
793
|
channel.drew({ ids: [], outdated: [], undrawn: [] });
|
|
809
794
|
host = undefined;
|