@quillmark/svelte 0.35.1 → 0.37.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 +30 -18
- package/THEMING.md +1 -1
- package/dist/core/address.d.ts +5 -0
- package/dist/core/address.js +14 -0
- package/dist/core/codec/decode.d.ts +4 -2
- package/dist/core/codec/decode.js +5 -2
- package/dist/core/codec/field.d.ts +42 -16
- package/dist/core/codec/field.js +97 -28
- package/dist/core/codec/index.d.ts +8 -5
- package/dist/core/codec/index.js +4 -5
- package/dist/core/codec/prose.css +25 -81
- package/dist/core/codec/review.d.ts +31 -26
- package/dist/core/codec/review.js +93 -169
- package/dist/core/codec/schema.d.ts +12 -2
- package/dist/core/codec/schema.js +27 -5
- package/dist/core/codec/shortcuts.d.ts +5 -4
- package/dist/core/codec/shortcuts.js +9 -8
- package/dist/core/codec/table-view.js +15 -3
- package/dist/core/codec/value-diff.d.ts +21 -0
- package/dist/core/codec/value-diff.js +83 -0
- package/dist/core/codec/value-plan.d.ts +29 -0
- package/dist/core/codec/value-plan.js +157 -0
- package/dist/core/theme.css +46 -15
- 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 +374 -96
- package/dist/visual/Card.svelte +33 -12
- package/dist/visual/Card.svelte.d.ts +3 -0
- 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 +20 -5
- package/dist/visual/EnumField.svelte.d.ts +5 -0
- package/dist/visual/Field.svelte +56 -47
- package/dist/visual/FieldHint.svelte +20 -8
- package/dist/visual/FormatPopover.svelte +54 -20
- package/dist/visual/MatrixField.svelte +48 -6
- package/dist/visual/MatrixField.svelte.d.ts +5 -0
- package/dist/visual/NumberField.svelte +131 -6
- package/dist/visual/NumberField.svelte.d.ts +5 -0
- package/dist/visual/ObjectField.svelte +60 -18
- package/dist/visual/ProseField.svelte +21 -5
- package/dist/visual/ProseField.svelte.d.ts +5 -1
- package/dist/visual/ProseValue.svelte +49 -8
- package/dist/visual/ProseValue.svelte.d.ts +7 -1
- package/dist/visual/ReviewCard.svelte +400 -0
- package/dist/visual/ReviewCard.svelte.d.ts +20 -0
- package/dist/visual/ReviewProposal.svelte +98 -138
- package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
- package/dist/visual/ReviewRows.svelte +6 -25
- package/dist/visual/ReviewRows.svelte.d.ts +1 -3
- package/dist/visual/SlashMenu.svelte +1 -0
- package/dist/visual/TipsCard.svelte +1 -1
- package/dist/visual/VariantField.svelte +45 -4
- package/dist/visual/VariantField.svelte.d.ts +5 -0
- package/dist/visual/VisualEditor.svelte +24 -9
- package/dist/visual/VisualEditor.svelte.d.ts +8 -1
- package/dist/visual/VisualEditorInner.svelte +917 -280
- package/dist/visual/VisualEditorInner.svelte.d.ts +8 -1
- package/dist/visual/controls.css +2 -2
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +25 -24
- package/dist/visual/proposals.js +92 -32
- package/dist/visual/props.d.ts +18 -18
- package/dist/visual/review-order.d.ts +51 -0
- package/dist/visual/review-order.js +87 -0
- package/dist/visual/review.d.ts +94 -3
- package/dist/visual/review.js +37 -2
- package/dist/visual/review.svelte.d.ts +77 -20
- package/dist/visual/review.svelte.js +306 -49
- package/dist/visual/strings.d.ts +59 -25
- package/dist/visual/strings.js +90 -29
- package/dist/visual/structure.d.ts +17 -3
- package/dist/visual/structure.js +71 -5
- package/dist/visual/undo.svelte.d.ts +3 -1
- package/dist/visual/undo.svelte.js +7 -3
- 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
|
|
|
@@ -161,18 +161,20 @@ Hand it a different `doc` and the editor **re-keys itself**: every leaf remounts
|
|
|
161
161
|
/* heard for each answer; the editor draws it, and the list stays as it was set */
|
|
162
162
|
}}
|
|
163
163
|
onReviewFocus={(id) => {
|
|
164
|
-
/* the item
|
|
164
|
+
/* the current item, which the answer card and the review keys answer, or undefined */
|
|
165
165
|
}}
|
|
166
|
+
reviewInset={barHeight}
|
|
166
167
|
/>
|
|
167
168
|
```
|
|
168
169
|
|
|
169
|
-
An item names its place by the **blocks** of a rich text field or a body, by the ids `doc.blocks(addr)` reads,
|
|
170
|
+
An item names its place by the **blocks** of a rich text field or a body, by the ids `doc.blocks(addr)` reads, by a **field**'s path, or by a **card** it adds or takes out:
|
|
170
171
|
|
|
171
172
|
```ts
|
|
172
173
|
type ReviewItem =
|
|
173
174
|
| {
|
|
174
175
|
id: string;
|
|
175
176
|
field: DocPath;
|
|
177
|
+
card?: string;
|
|
176
178
|
replace: string[];
|
|
177
179
|
before?: string;
|
|
178
180
|
after: string;
|
|
@@ -180,25 +182,31 @@ type ReviewItem =
|
|
|
180
182
|
| {
|
|
181
183
|
id: string;
|
|
182
184
|
field: DocPath;
|
|
185
|
+
card?: string;
|
|
183
186
|
insert: { after: string } | { before: string } | 'end';
|
|
184
187
|
after: string;
|
|
185
188
|
}
|
|
186
|
-
| { id: string; field: DocPath; before?: unknown; after?: unknown }
|
|
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 };
|
|
187
192
|
```
|
|
188
193
|
|
|
189
|
-
- **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
|
|
190
|
-
- **A proposal for a field**
|
|
191
|
-
- **A proposal for a place inside a field** names it by its path, `main.contact.email` or `main.signature_block[2]`, and
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
192
198
|
|
|
193
|
-
`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
|
|
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.
|
|
194
200
|
|
|
195
201
|
```ts
|
|
196
202
|
const base = doc.clone(); // when the assistant is asked
|
|
197
203
|
const answer = base.clone(); // the assistant edits this copy
|
|
198
|
-
const { items
|
|
204
|
+
const { items } = proposalsBetween(quill, base, answer);
|
|
199
205
|
review = items;
|
|
200
206
|
```
|
|
201
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
|
+
|
|
202
210
|
The editor makes every write an answer asks for:
|
|
203
211
|
|
|
204
212
|
| `action` | What the reader did | What is written |
|
|
@@ -207,21 +215,25 @@ The editor makes every write an answer asks for:
|
|
|
207
215
|
| `dismiss` | Turned a proposal down. | Nothing. |
|
|
208
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. |
|
|
209
217
|
|
|
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.
|
|
219
|
+
|
|
210
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.
|
|
211
221
|
|
|
212
|
-
⌘Z/Ctrl+Z from anywhere in the editor takes back the answers given since the reader's last edit, newest first, one answer or one `answerReview` call at a time, and each comes back as `reopen`; past that edit a taken proposal is still undone in its own text field, with its `reopen`, and a field's value and a dismissal are final.
|
|
222
|
+
⌘Z/Ctrl+Z from anywhere in the editor, or from the host's chrome outside a text box, takes back the answers given since the reader's last edit, newest first, one answer or one `answerReview` call at a time, and each comes back as `reopen`; past that edit a taken proposal is still undone in its own text field, with its `reopen`, and a field's value, a card and a dismissal are final. No answer raises a toast; a host's `answerReview` batch is taken back whole.
|
|
223
|
+
|
|
224
|
+
The host sets the list once and clears it once. It sets it when an answer arrives, and clears it when the reader keeps the result or asks again, or the document closes; between the two it does not touch the list. The editor draws every answer while the list holds the item: an answered item goes, and an item reopened by ⌘Z is drawn open again. A field's proposal the schema refuses stays, unanswered, and the field says why as it does for any refused value.
|
|
213
225
|
|
|
214
|
-
|
|
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.
|
|
215
227
|
|
|
216
|
-
|
|
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.
|
|
217
229
|
|
|
218
|
-
The
|
|
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.
|
|
219
231
|
|
|
220
|
-
|
|
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)).
|
|
221
233
|
|
|
222
234
|
### Wording
|
|
223
235
|
|
|
224
|
-
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.
|
|
225
237
|
|
|
226
238
|
```svelte
|
|
227
239
|
<VisualEditor
|
|
@@ -229,14 +241,14 @@ The package ships English and a seam to replace it. `strings` is keyed and **par
|
|
|
229
241
|
{quill}
|
|
230
242
|
strings={{
|
|
231
243
|
cardDelete: 'Supprimer la carte',
|
|
232
|
-
addCard: '
|
|
244
|
+
addCard: 'Ajouter une carte'
|
|
233
245
|
}}
|
|
234
246
|
formatDiagnostic={(d) =>
|
|
235
247
|
d.code === 'validation::type_mismatch' ? `${d.path} : type incorrect` : undefined}
|
|
236
248
|
/>
|
|
237
249
|
```
|
|
238
250
|
|
|
239
|
-
`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.
|
|
240
252
|
|
|
241
253
|
### Fonts
|
|
242
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
|
|
package/dist/core/address.d.ts
CHANGED
|
@@ -86,3 +86,8 @@ export interface NestedAddr {
|
|
|
86
86
|
* the path resolves to nothing. `path` itself where it names no card, or a card past `was`.
|
|
87
87
|
*/
|
|
88
88
|
export declare function cardMoved(path: DocPath, was: readonly string[], now: readonly string[]): DocPath;
|
|
89
|
+
/** The index of the card `path` names, `undefined` where it names none. */
|
|
90
|
+
export declare function cardOfPath(path: DocPath): number | undefined;
|
|
91
|
+
/** `path` naming the card at `index` in place of the card it names; `path` itself where it
|
|
92
|
+
* names none. */
|
|
93
|
+
export declare function pathOnCard(path: DocPath, index: number): DocPath;
|
package/dist/core/address.js
CHANGED
|
@@ -99,6 +99,20 @@ export function cardMoved(path, was, now) {
|
|
|
99
99
|
return path;
|
|
100
100
|
return core().formatDocPath([{ ...head, index }, ...segs.slice(1)]);
|
|
101
101
|
}
|
|
102
|
+
/** The index of the card `path` names, `undefined` where it names none. */
|
|
103
|
+
export function cardOfPath(path) {
|
|
104
|
+
const head = segsOf(path)?.[0];
|
|
105
|
+
return head?.seg === 'card' ? head.index : undefined;
|
|
106
|
+
}
|
|
107
|
+
/** `path` naming the card at `index` in place of the card it names; `path` itself where it
|
|
108
|
+
* names none. */
|
|
109
|
+
export function pathOnCard(path, index) {
|
|
110
|
+
const segs = segsOf(path);
|
|
111
|
+
const head = segs?.[0];
|
|
112
|
+
if (!segs || head?.seg !== 'card' || head.index === index)
|
|
113
|
+
return path;
|
|
114
|
+
return core().formatDocPath([{ ...head, index }, ...segs.slice(1)]);
|
|
115
|
+
}
|
|
102
116
|
/**
|
|
103
117
|
* `parseDocPath`, with a malformed path as `undefined` rather than a throw. The gate is read
|
|
104
118
|
* outside the try: an uninitialized core is not a malformed path.
|
|
@@ -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,8 @@ 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
|
+
import { type ValueProposal, type ValueState } from './value-diff.js';
|
|
10
11
|
import { type TableChromeStrings } from './table-view.js';
|
|
11
12
|
import { type SlashState, type SlashStrings } from './slash.js';
|
|
12
13
|
/** Options for {@link createField}. */
|
|
@@ -24,6 +25,9 @@ export interface CreateFieldOpts {
|
|
|
24
25
|
/** A mark-free schema (a `text` field): literal text, no formatting and no
|
|
25
26
|
* anchors, in paragraphs and hard breaks or, with `inline`, one textblock. */
|
|
26
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;
|
|
27
31
|
/** The id of the note the caller draws inside `container` for a held leaf →
|
|
28
32
|
* `aria-describedby` while it holds. */
|
|
29
33
|
heldNoteId?: string;
|
|
@@ -87,21 +91,21 @@ export interface CreateFieldOpts {
|
|
|
87
91
|
/** An edit leaving the leaf empty removes the field: an optional cell (`t?`), whose
|
|
88
92
|
* unanswered `none` is what the empty leaf draws and an empty answer would hide. */
|
|
89
93
|
emptyUnsets?: boolean;
|
|
90
|
-
/** The review
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* that took the answer back, `chord` where a key gave it. A proposal taken is written by
|
|
94
|
-
* then. */
|
|
95
|
-
onReview?(id: string, action: ReviewAction, chord?: boolean): void;
|
|
94
|
+
/** The leaf answered the review item `id`, or an undo took the answer back. A proposal
|
|
95
|
+
* taken is written by then. */
|
|
96
|
+
onReview?(id: string, action: ReviewAction): void;
|
|
96
97
|
/** The leaf is writing a taken proposal, and is done: the commit between is the answer's. */
|
|
97
98
|
onReviewWriting?(on: boolean): void;
|
|
98
|
-
/** The review item
|
|
99
|
-
*
|
|
100
|
-
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;
|
|
101
102
|
/** What the leaf draws of the review items, on each change: the ids drawn, and the items
|
|
102
103
|
* whose anchor the leaf holds that it does not draw, each with why. An item whose anchor
|
|
103
104
|
* the leaf does not hold is in neither. */
|
|
104
105
|
onReviewDrawn?(report: ReviewReport): void;
|
|
106
|
+
/** On each draw of a whole proposed value, how it stands against what the leaf holds
|
|
107
|
+
* (`value-diff.ts`). */
|
|
108
|
+
onValuePlanned?(id: string, state: ValueState): void;
|
|
105
109
|
onFocus?(addr: Addr): void;
|
|
106
110
|
/** Fired with the new caret offset after an edit or a selection move. */
|
|
107
111
|
onCaretMove?(addr: Addr, pos: number): void;
|
|
@@ -116,6 +120,19 @@ export interface CreateFieldOpts {
|
|
|
116
120
|
onError?: EditorErrorHandler;
|
|
117
121
|
}
|
|
118
122
|
/** The prose-leaf handle (INVARIANTS §Surface). */
|
|
123
|
+
/** A leaf's open proposals written into a copy of its document, and the way between the two. */
|
|
124
|
+
export interface LeafProjection {
|
|
125
|
+
/** The proposals written, in the order the leaf was handed them. */
|
|
126
|
+
ids: readonly string[];
|
|
127
|
+
/** A content offset in the leaf as it stands, as an offset in the projection. */
|
|
128
|
+
toProjection(pos: number): number;
|
|
129
|
+
/** A content offset in the projection, as one in the leaf as it stands, or the proposal
|
|
130
|
+
* that adds the block holding it. Inside a stretch a proposal rewrites, the offset is the
|
|
131
|
+
* nearest the leaf holds. */
|
|
132
|
+
toLive(pos: number): number | {
|
|
133
|
+
review: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
119
136
|
export interface FieldController {
|
|
120
137
|
/** The mounted `container`: the leaf's element, for a caller that has to reach the
|
|
121
138
|
* DOM the view sits in (the arrival wash, `core/bloom.ts`) rather than re-find it. */
|
|
@@ -155,6 +172,9 @@ export interface FieldController {
|
|
|
155
172
|
* `text` leaf holds no anchors and draws none.
|
|
156
173
|
*/
|
|
157
174
|
setReview(items: readonly TextReview[], lit?: string): void;
|
|
175
|
+
/** Draw a whole proposed value over a one-line leaf as a word diff, or none
|
|
176
|
+
* (`value-diff.ts`). A leaf that holds blocks draws none. */
|
|
177
|
+
setValueProposal(p: ValueProposal | undefined): void;
|
|
158
178
|
/** The elements the review item `id` draws, in document order; `[]` for one not drawn. */
|
|
159
179
|
reviewElements(id: string): HTMLElement[];
|
|
160
180
|
/** Put the caret in the review item `id` and focus the leaf; false for one not drawn. */
|
|
@@ -167,6 +187,12 @@ export interface FieldController {
|
|
|
167
187
|
reopenReview(id: string): void;
|
|
168
188
|
/** Undo the leaf's newest step, a taken proposal's, reported as `reopen`. */
|
|
169
189
|
undoReview(): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Write every proposal the leaf draws into `target`, a copy of the document the leaf edits,
|
|
192
|
+
* as their accepts would commit them, dispatching nothing: the leaf, its history and its
|
|
193
|
+
* document are as they were. `undefined` where the leaf draws none.
|
|
194
|
+
*/
|
|
195
|
+
projectReview(target: Document): LeafProjection | undefined;
|
|
170
196
|
/** Ids of the anchors touching content range `[from, to]`: a selection's anchor state. */
|
|
171
197
|
anchorsInRange(from: number, to: number): string[];
|
|
172
198
|
/**
|
|
@@ -202,17 +228,17 @@ export declare function emptyContent(): Content;
|
|
|
202
228
|
/** Whether `rt` is the empty leaf: {@link emptyContent}, nothing typed and no shape left. */
|
|
203
229
|
export declare function isEmptyContent(rt: Content): boolean;
|
|
204
230
|
/**
|
|
205
|
-
* The
|
|
206
|
-
*
|
|
207
|
-
*
|
|
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`.
|
|
208
234
|
*/
|
|
209
235
|
export declare function proseAttributes(opts: {
|
|
210
236
|
label?: string;
|
|
211
237
|
labelledBy?: string;
|
|
212
238
|
describedBy?: string;
|
|
213
|
-
}): Record<string, string
|
|
214
|
-
/** A held leaf's attributes, described by its note as well. A
|
|
215
|
-
*
|
|
239
|
+
}, multiline: boolean): Record<string, string>;
|
|
240
|
+
/** A held leaf's attributes, described by its note as well. A held leaf draws its structure
|
|
241
|
+
* in the block schema, and a non-editable view is no tab stop, so it states both itself. */
|
|
216
242
|
export declare function heldAttributes(opts: {
|
|
217
243
|
label?: string;
|
|
218
244
|
labelledBy?: string;
|