@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.
Files changed (82) hide show
  1. package/README.md +30 -18
  2. package/THEMING.md +1 -1
  3. package/dist/core/address.d.ts +5 -0
  4. package/dist/core/address.js +14 -0
  5. package/dist/core/codec/decode.d.ts +4 -2
  6. package/dist/core/codec/decode.js +5 -2
  7. package/dist/core/codec/field.d.ts +42 -16
  8. package/dist/core/codec/field.js +97 -28
  9. package/dist/core/codec/index.d.ts +8 -5
  10. package/dist/core/codec/index.js +4 -5
  11. package/dist/core/codec/prose.css +25 -81
  12. package/dist/core/codec/review.d.ts +31 -26
  13. package/dist/core/codec/review.js +93 -169
  14. package/dist/core/codec/schema.d.ts +12 -2
  15. package/dist/core/codec/schema.js +27 -5
  16. package/dist/core/codec/shortcuts.d.ts +5 -4
  17. package/dist/core/codec/shortcuts.js +9 -8
  18. package/dist/core/codec/table-view.js +15 -3
  19. package/dist/core/codec/value-diff.d.ts +21 -0
  20. package/dist/core/codec/value-diff.js +83 -0
  21. package/dist/core/codec/value-plan.d.ts +29 -0
  22. package/dist/core/codec/value-plan.js +157 -0
  23. package/dist/core/theme.css +46 -15
  24. package/dist/core/tooltip.css +49 -0
  25. package/dist/core/tooltip.d.ts +6 -0
  26. package/dist/core/tooltip.js +176 -0
  27. package/dist/preview/Preview.svelte +22 -1
  28. package/dist/preview/controller.js +38 -0
  29. package/dist/preview/strings.d.ts +2 -0
  30. package/dist/preview/strings.js +1 -0
  31. package/dist/visual/ArrayField.svelte +374 -96
  32. package/dist/visual/Card.svelte +33 -12
  33. package/dist/visual/Card.svelte.d.ts +3 -0
  34. package/dist/visual/CardControls.svelte +3 -3
  35. package/dist/visual/DateField.svelte +47 -5
  36. package/dist/visual/DiagnosticList.svelte +3 -2
  37. package/dist/visual/EnumField.svelte +20 -5
  38. package/dist/visual/EnumField.svelte.d.ts +5 -0
  39. package/dist/visual/Field.svelte +56 -47
  40. package/dist/visual/FieldHint.svelte +20 -8
  41. package/dist/visual/FormatPopover.svelte +54 -20
  42. package/dist/visual/MatrixField.svelte +48 -6
  43. package/dist/visual/MatrixField.svelte.d.ts +5 -0
  44. package/dist/visual/NumberField.svelte +131 -6
  45. package/dist/visual/NumberField.svelte.d.ts +5 -0
  46. package/dist/visual/ObjectField.svelte +60 -18
  47. package/dist/visual/ProseField.svelte +21 -5
  48. package/dist/visual/ProseField.svelte.d.ts +5 -1
  49. package/dist/visual/ProseValue.svelte +49 -8
  50. package/dist/visual/ProseValue.svelte.d.ts +7 -1
  51. package/dist/visual/ReviewCard.svelte +400 -0
  52. package/dist/visual/ReviewCard.svelte.d.ts +20 -0
  53. package/dist/visual/ReviewProposal.svelte +98 -138
  54. package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
  55. package/dist/visual/ReviewRows.svelte +6 -25
  56. package/dist/visual/ReviewRows.svelte.d.ts +1 -3
  57. package/dist/visual/SlashMenu.svelte +1 -0
  58. package/dist/visual/TipsCard.svelte +1 -1
  59. package/dist/visual/VariantField.svelte +45 -4
  60. package/dist/visual/VariantField.svelte.d.ts +5 -0
  61. package/dist/visual/VisualEditor.svelte +24 -9
  62. package/dist/visual/VisualEditor.svelte.d.ts +8 -1
  63. package/dist/visual/VisualEditorInner.svelte +917 -280
  64. package/dist/visual/VisualEditorInner.svelte.d.ts +8 -1
  65. package/dist/visual/controls.css +2 -2
  66. package/dist/visual/index.d.ts +2 -2
  67. package/dist/visual/proposals.d.ts +25 -24
  68. package/dist/visual/proposals.js +92 -32
  69. package/dist/visual/props.d.ts +18 -18
  70. package/dist/visual/review-order.d.ts +51 -0
  71. package/dist/visual/review-order.js +87 -0
  72. package/dist/visual/review.d.ts +94 -3
  73. package/dist/visual/review.js +37 -2
  74. package/dist/visual/review.svelte.d.ts +77 -20
  75. package/dist/visual/review.svelte.js +306 -49
  76. package/dist/visual/strings.d.ts +59 -25
  77. package/dist/visual/strings.js +90 -29
  78. package/dist/visual/structure.d.ts +17 -3
  79. package/dist/visual/structure.js +71 -5
  80. package/dist/visual/undo.svelte.d.ts +3 -1
  81. package/dist/visual/undo.svelte.js +7 -3
  82. package/package.json +2 -2
@@ -35,6 +35,8 @@
35
35
  cardPath,
36
36
  nestedAddrForFieldPath,
37
37
  fieldPathForAddr,
38
+ cardOfPath,
39
+ pathOnCard,
38
40
  type DocPath,
39
41
  type Landing
40
42
  } from '../core/address.js';
@@ -42,10 +44,12 @@
42
44
  import { bloom } from '../core/bloom.js';
43
45
  import { createLifespan } from '../core/teardown.js';
44
46
  import { spacePx } from '../core/rungs.js';
47
+ import { tooltips } from '../core/tooltip.js';
45
48
  import type {
46
49
  Addr,
47
50
  CardAddr,
48
51
  Diagnostic,
52
+ Document,
49
53
  PathStep,
50
54
  PayloadItem,
51
55
  QuillFieldSchema,
@@ -54,21 +58,35 @@
54
58
  } from '@quillmark/wasm';
55
59
  import type { VisualEditorProps } from './props.js';
56
60
  import type { Delta } from '../core/codec/positions.js';
57
- import { mergeStrings, setWording } from './strings.js';
58
- import { createStructuralUndo, setStructuralUndo, type UndoOffer } from './undo.svelte.js';
61
+ import { diagnosticText, mergeStrings, setWording } from './strings.js';
62
+ import { createStructuralUndo, setStructuralUndo } from './undo.svelte.js';
59
63
  import { undoChord } from './listhistory.js';
60
64
  import { removedCards, type RemovedCard } from './removed.js';
61
- import { createReview, setReview } from './review.svelte.js';
65
+ import { createReview, setReview, type CardAdd } from './review.svelte.js';
62
66
  import {
63
67
  byBlocks,
68
+ byCard,
69
+ locate,
64
70
  onField,
71
+ reviewText,
65
72
  valueIn,
66
73
  valueWith,
74
+ NO_PROJECTION,
75
+ type CardProposal,
67
76
  type FieldProposal,
68
- type ReviewDrawn
77
+ type ReviewDrawn,
78
+ type ReviewItem,
79
+ type ReviewProjection
69
80
  } from './review.js';
81
+ import ReviewCard from './ReviewCard.svelte';
82
+ import { cardLayout, nextOpen, stepIn } from './review-order.js';
70
83
  import type { CardId, CardOp, ChangeSource } from './signals.js';
71
- import { REVIEW_KEYS, type FieldController, type LeafViews } from '../core/codec/index.js';
84
+ import {
85
+ REVIEW_KEYS,
86
+ type FieldController,
87
+ type LeafProjection,
88
+ type LeafViews
89
+ } from '../core/codec/index.js';
72
90
  import {
73
91
  IdSeq,
74
92
  controlKind,
@@ -79,6 +97,9 @@
79
97
  cardTitle,
80
98
  kindTitle,
81
99
  fieldValues,
100
+ fieldTitle,
101
+ humanize,
102
+ placeCardInto,
82
103
  bodyEnabled,
83
104
  provenanceMap,
84
105
  resolvedByCardIndex,
@@ -129,7 +150,7 @@
129
150
  onReview,
130
151
  onReviewFocus,
131
152
  onReviewDrawn,
132
- reviewAdvance = true,
153
+ reviewInset = 0,
133
154
  class: className,
134
155
  style
135
156
  }: VisualEditorProps = $props();
@@ -167,6 +188,12 @@
167
188
  /** The card keys as they stood when the host set its review list: an item names its card by
168
189
  * index into these, so it stays on that card through every card op since. */
169
190
  let listed: { list: VisualEditorProps['review']; cards: readonly string[] } | undefined;
191
+ /** A card the list named, taken out and put back under a new key, is still the card it
192
+ * named. */
193
+ function relist(was: string, now: string): void {
194
+ const held = cardsListed();
195
+ listed = { list: review, cards: held.map((key) => (key === was ? now : key)) };
196
+ }
170
197
  function cardsListed(): readonly string[] {
171
198
  const held = listed;
172
199
  if (held && held.list === review) return held.cards;
@@ -207,7 +234,7 @@
207
234
  function report(source: ChangeSource, cardId?: CardId, at?: Addr | number, op?: CardOp): void {
208
235
  const path =
209
236
  at == null ? undefined : typeof at === 'number' ? cardPath(at, liveKinds()) : pathFor(at);
210
- settled();
237
+ reviewing.settled();
211
238
  onChange?.({ source, cardId, path, ...(op ? { op } : {}) });
212
239
  }
213
240
  function rederive(): void {
@@ -317,18 +344,40 @@
317
344
  const addr = nearestAddrForFieldPath(path);
318
345
  return addr && declaredField(addr) ? resolveCardKey(addr, cardIds) : undefined;
319
346
  };
320
- /** Take a field's answer back: the value it replaced written back, if any, and the item
321
- * reopened. */
347
+ /** The key of the prose leaf a rich text field's or a body's path names. */
348
+ function proseKeyFor(path: DocPath): string | undefined {
349
+ const addr = addrForFieldPath(path);
350
+ if (!addr) return undefined;
351
+ const key = addr.field == null ? resolveCardKey({ card: addr.card }, cardIds) : reviewed(path);
352
+ return key && fieldKeyToString(key);
353
+ }
354
+ /** Take a field's or a card's answer back: what it wrote taken back, if anything, and the
355
+ * item reopened and brought into view, where no leaf's own undo scrolls to it. */
322
356
  const giveBack = (id: string, leaf: string, back?: () => void): void => {
323
357
  back?.();
324
358
  reviewing.heard(id, 'reopen', leaf);
359
+ void reveal(id, false, true);
325
360
  };
326
- /** The host's list with each card it names by index moved to where that card stands now. */
361
+ /** The session key of the card holding `$id` `id`. */
362
+ function cardKeyFor(id: string): string | undefined {
363
+ return cardIds.find((_, k) => doc.card(k).id === id);
364
+ }
365
+ /** The host's list with each card a path names moved to where that card stands now: the card
366
+ * holding the item's `card`, else the one at the path's index when the list was set. */
327
367
  const reviewItems = $derived.by(() => {
328
368
  const was = cardsListed();
329
- if (!review?.length || was === cardIds) return review;
369
+ const now = cardIds;
370
+ if (!review?.length) return review;
371
+ if (was === now && !review.some((item) => 'card' in item && item.card !== undefined))
372
+ return review;
330
373
  return review.map((item) => {
331
- const field = cardMoved(item.field, was, cardIds);
374
+ if (byCard(item)) return item;
375
+ let field: DocPath;
376
+ if (item.card === undefined) field = cardMoved(item.field, was, now);
377
+ else {
378
+ const key = cardKeyFor(item.card);
379
+ field = pathOnCard(item.field, key === undefined ? now.length : now.indexOf(key));
380
+ }
332
381
  return field === item.field ? item : { ...item, field };
333
382
  });
334
383
  });
@@ -354,112 +403,48 @@
354
403
  key.card === undefined ? model.main : model.cards[cardIndexOf(key.card as CardId)];
355
404
  return card?.values[key.field];
356
405
  },
357
- leafFor(path) {
358
- const addr = addrForFieldPath(path);
359
- if (!addr) return undefined;
360
- const key =
361
- addr.field == null ? resolveCardKey({ card: addr.card }, cardIds) : reviewed(path);
362
- return key && fieldKeyToString(key);
363
- },
364
- chorded(id) {
365
- if (!reviewAdvance) return;
366
- const index = drewOrder.indexOf(id);
367
- void tick().then(() => {
368
- if (span.alive) void step(1, true, index < 0 ? undefined : { id, index });
369
- });
370
- },
371
- writing(on) {
372
- writing += on ? 1 : -1;
373
- },
374
- answer(id, item, action, key) {
406
+ leafFor: proseKeyFor,
407
+ layout: () => [cardLayout(model.main), ...model.cards.map(cardLayout)],
408
+ listedCards: () => cardsListed(),
409
+ liveCards: () => cardIds,
410
+ cardFor: cardKeyFor,
411
+ undo,
412
+ answered: (id, order) => advanceFrom(id, order ?? drewOrder),
413
+ answerProse: (key, id, action) => !!leaves.prose(key)?.answerReview(id, action),
414
+ answer(id, item, action, key, write) {
375
415
  let back: (() => void) | undefined;
376
- if (action === 'accept' && item && onField(item)) {
377
- back = takeField(item);
416
+ if (write && item && onField(item)) {
417
+ back = takeField(item, write);
418
+ if (!back) return false;
419
+ } else if (action === 'accept' && item && (onField(item) || byCard(item))) {
420
+ back = onField(item) ? takeField(item) : takeCard(item);
378
421
  if (!back) return false;
379
422
  }
380
423
  onReview?.({ id, action });
381
424
  if (action !== 'accept' && action !== 'dismiss') return true;
425
+ if (item && byCard(item)) return () => giveBack(id, '', back);
382
426
  const field = item && onField(item) ? reviewed(item.field) : undefined;
383
427
  const leaf = key ?? (field && fieldKeyToString(field));
384
428
  if (leaf === undefined) return true;
385
429
  const prose = key !== undefined && !field;
386
- record(
387
- id,
388
- prose
389
- ? action === 'accept'
390
- ? () => void leaves.prose(leaf)?.undoReview()
391
- : () => void leaves.prose(leaf)?.reopenReview(id)
392
- : () => giveBack(id, leaf, back),
393
- back && merged.reviewAccepted
394
- );
395
- return true;
430
+ return prose
431
+ ? action === 'accept'
432
+ ? () => void leaves.prose(leaf)?.undoReview()
433
+ : () => void leaves.prose(leaf)?.reopenReview(id)
434
+ : () => giveBack(id, leaf, back);
396
435
  }
397
436
  });
398
437
 
399
- // ── The answer journal: the review answers since the reader's last edit, each undone by
400
- // ⌘Z from anywhere in the editor, newest first, its item reopened with it. An edit that is
401
- // not an answer empties it: an inverse is good against the document it was recorded over. An answer's own writes, and an inverse's, go down the
402
- // lanes an edit does, so they are flagged while they are made.
403
- interface Answered {
404
- ids: string[];
405
- inverses: (() => void)[];
406
- /** The toast it stands on; none where the key alone takes it back. */
407
- notice?: string;
408
- }
409
- let journal: Answered[] = [];
410
- /** The entry a batch of answers records into. */
411
- let batching: Answered | undefined;
412
- let journalOffer: UndoOffer | undefined;
413
- let writing = 0;
414
- function settled(): void {
415
- if (writing) return;
416
- journal = [];
417
- journalOffer = undefined;
418
- undo.settle();
419
- }
420
- function offerJournal(): void {
421
- const top = journal.at(-1);
422
- journalOffer =
423
- top &&
424
- undo.offer(top.notice ?? '', unanswer, {
425
- standing: true,
426
- quiet: top.notice === undefined,
427
- answer: true
428
- });
429
- }
430
- function unanswer(): void {
431
- const top = journal.pop();
432
- if (!top) return;
433
- writing++;
434
- try {
435
- for (const inverse of [...top.inverses].reverse()) inverse();
436
- } finally {
437
- writing--;
438
- }
439
- offerJournal();
440
- }
441
- function record(id: string, inverse: () => void, notice?: string): void {
442
- if (batching) {
443
- batching.ids.push(id);
444
- batching.inverses.push(inverse);
445
- return;
446
- }
447
- // Another step took the key since: the answers before it are no longer the last thing
448
- // that happened.
449
- if (!journalOffer || !undo.holds(journalOffer)) journal = [];
450
- journal.push({ ids: [id], inverses: [inverse], notice });
451
- offerJournal();
452
- }
453
-
454
438
  /**
455
439
  * Take a field's proposal: its value down the lane the field's own control commits by, so
456
- * the writer checks it and `onChange` reports it. A text leaf re-reads what was written. A
457
- * place inside the field is written as the whole value with that place alone changed, down
458
- * the lane an edit of the place takes. Returns the write back to the value it replaced,
459
- * which the journal runs before any older answer's, or `undefined` where the writer refused
460
- * the value, which the field then says as it says any refused commit.
440
+ * the writer checks it and `onChange` reports it, or `edit`, the value a reader's own commit
441
+ * under it writes. A text leaf re-reads what was written. A place inside the field is written
442
+ * as the whole value with that place alone changed, down the lane an edit of the place takes.
443
+ * Returns the write back to the value it replaced, which the journal runs before any older
444
+ * answer's, or `undefined` where the writer refused the value, which the field then says as it
445
+ * says any refused commit.
461
446
  */
462
- function takeField(item: FieldProposal): (() => void) | undefined {
447
+ function takeField(item: FieldProposal, edit?: { value: unknown }): (() => void) | undefined {
463
448
  const key = reviewed(item.field);
464
449
  if (!key?.field || typeof key.card === 'number') return undefined;
465
450
  const isMain = key.card === undefined;
@@ -473,19 +458,21 @@
473
458
  leaves.prose(leaf)?.applyExternal();
474
459
  return true;
475
460
  };
476
- writing++;
461
+ reviewing.writing(true);
477
462
  try {
478
463
  const before = doc.getStored(addr);
479
- let after = item.after;
464
+ const to = (place: unknown): unknown => (edit ? edit.value : reviewing.writes(item, place));
465
+ let after: unknown;
480
466
  if (!addrForFieldPath(item.field)) {
481
467
  const steps = reviewing.at(leaf).nested?.find((e) => e.item.id === item.id)?.steps;
482
468
  if (!steps) return undefined;
483
- after = valueWith(current(), steps, item.after);
484
- }
469
+ const value = current();
470
+ after = valueWith(value, steps, to(valueIn(value, steps)));
471
+ } else after = to(current());
485
472
  if (!write(after)) return undefined;
486
473
  return () => void write(before);
487
474
  } finally {
488
- writing--;
475
+ reviewing.writing(false);
489
476
  }
490
477
 
491
478
  /** The field's value as its control is handed it, read anew. */
@@ -495,80 +482,125 @@
495
482
  return fieldValues((isMain ? doc.main : doc.card(at)).payloadItems)[name];
496
483
  }
497
484
  }
485
+ /**
486
+ * Take a card proposal: the card written or taken out as the editor's own card edit, which
487
+ * `onChange` reports with its op. A new card is written with its `$id` where no card holds
488
+ * that one, after the card it stands after as drawn. Returns the edit's inverse, which the
489
+ * journal runs before any older answer's: a removal puts the card back where it stood, and
490
+ * the list still names it. `undefined` where there is nothing to write.
491
+ */
492
+ function takeCard(item: CardProposal): (() => void) | undefined {
493
+ if ('remove' in item) {
494
+ const key = item.card === undefined ? cardsListed()[item.remove] : cardKeyFor(item.card);
495
+ const at = key === undefined ? -1 : cardIndexOf(key);
496
+ if (key === undefined || at < 0) return undefined;
497
+ const card = doc.card(at);
498
+ doc.removeCard(at);
499
+ undo.withdraw();
500
+ arm.arm();
501
+ setCards(cardIds.filter((_, k) => k !== at));
502
+ forget(key);
503
+ bump('structure', key, undefined, { op: 'remove', at });
504
+ return () => {
505
+ const i = Math.min(at, cardIds.length);
506
+ if (!placeCard(card, i)) return;
507
+ const back = seq.next();
508
+ relist(key, back);
509
+ arm.arm();
510
+ setCards([...cardIds.slice(0, i), back, ...cardIds.slice(i)]);
511
+ bump('structure', back, i, { op: 'insert', at: i });
512
+ };
513
+ }
514
+ const lead = [...reviewing.cards.adds].find(([, list]) =>
515
+ list.some((a) => a.id === item.id)
516
+ )?.[0];
517
+ if (lead === undefined) return undefined;
518
+ const at = lead === 'head' ? 0 : lead === 'end' ? cardIds.length : cardIndexOf(lead) + 1;
519
+ if (at < 0 || !placeCard(item.add, at)) return undefined;
520
+ const key = seq.next();
521
+ arm.arm();
522
+ setCards([...cardIds.slice(0, at), key, ...cardIds.slice(at)]);
523
+ reviewing.wrote(item.id, key);
524
+ bump('structure', key, at, { op: 'insert', at });
525
+ return () => {
526
+ const i = cardIndexOf(key);
527
+ reviewing.wrote(item.id, undefined);
528
+ if (i < 0) return;
529
+ doc.removeCard(i);
530
+ arm.arm();
531
+ setCards(cardIds.filter((_, k) => k !== i));
532
+ forget(key);
533
+ bump('structure', key, undefined, { op: 'remove', at: i });
534
+ };
535
+ }
536
+ /** Write `card` into the document at `at`, with its `$id` where no card holds that one. */
537
+ function placeCard(card: CardAdd['add'], at: number): boolean {
538
+ try {
539
+ placeCardInto(doc, card, at);
540
+ return true;
541
+ } catch (e) {
542
+ reportError(onError, {
543
+ code: 'card-op-failed',
544
+ severity: 'error',
545
+ message: `adding a ${card.kind} card failed: ${errorMessage(e)}`,
546
+ cause: e
547
+ });
548
+ return false;
549
+ }
550
+ }
551
+ /** What a new card's preview shows: the title its header would, and the start of its body,
552
+ * else its values as words. */
553
+ function previewOf(item: CardAdd): {
554
+ title: string;
555
+ fields: { label: string; value: string }[];
556
+ text: string;
557
+ } {
558
+ const { add } = item;
559
+ const schema = quill.schema.card_kinds?.[add.kind];
560
+ const values = fieldValues(add.payloadItems);
561
+ const named = (add.ext?.editor as { title?: unknown } | undefined)?.title;
562
+ const title = cardTitle(
563
+ schema,
564
+ add.kind,
565
+ values,
566
+ typeof named === 'string' ? named : undefined
567
+ );
568
+ const words = { on: merged.reviewOn, off: merged.reviewOff };
569
+ const fields = Object.entries(values).flatMap(([key, v]) => {
570
+ const value = reviewText(v, words);
571
+ const field = schema?.fields[key];
572
+ return value ? [{ label: field ? fieldTitle(key, field) : humanize(key), value }] : [];
573
+ });
574
+ return { title, fields, text: add.body?.text?.trim() ?? '' };
575
+ }
498
576
  setReview(reviewing);
499
- span.onEnd(reviewing.dispose);
500
- // The lit item, to a host lighting its own list: each change, and not the nothing a mount
501
- // starts from.
577
+ // The current change, to a host counting its place: each change, and not the nothing a
578
+ // mount starts from.
502
579
  let reported: string | undefined;
503
580
  $effect(() => {
504
581
  const id = reviewing.lit;
505
582
  if (id === reported) return;
506
583
  reported = id;
584
+ typing = false;
507
585
  onReviewFocus?.(id);
508
586
  });
509
- /** The open items drawn, in document order: each id's first element under the root, then
510
- * any drawn one not yet in the DOM, in list order. */
511
- function reviewOrder(): string[] {
512
- const fieldUndrawn = new Set(reviewing.fieldUndrawn.map((u) => u.id));
513
- const drawn = new Set<string>();
514
- for (const report of reviewing.reports.values()) for (const id of report.ids) drawn.add(id);
515
- for (const item of reviewing.items)
516
- if (onField(item) && !fieldUndrawn.has(item.id)) drawn.add(item.id);
517
- const order: string[] = [];
518
- const seen = new Set<string>();
519
- const take = (id: string | null): void => {
520
- if (id === null || !drawn.has(id) || seen.has(id)) return;
521
- seen.add(id);
522
- order.push(id);
523
- };
524
- for (const el of rootEl?.querySelectorAll('[data-qm-review]') ?? [])
525
- take(el.getAttribute('data-qm-review'));
526
- for (const item of reviewing.items) take(item.id);
527
- return order;
528
- }
529
- /** What the editor draws of the host's list, and why it draws what it does not. */
530
- function reviewReport(): ReviewDrawn {
531
- const reported = new Set<string>();
532
- const outdated = new Set(reviewing.fieldOutdated);
533
- const why = new Map<string, ReviewDrawn['undrawn'][number]['reason']>();
534
- for (const report of reviewing.reports.values()) {
535
- for (const id of report.ids) reported.add(id);
536
- for (const id of report.outdated) outdated.add(id);
537
- for (const { id, reason } of report.undrawn) {
538
- reported.add(id);
539
- why.set(id, reason);
540
- }
541
- }
542
- for (const { id, reason } of reviewing.fieldUndrawn) why.set(id, reason);
543
- for (const item of reviewing.items)
544
- if (!reported.has(item.id) && !why.has(item.id)) {
545
- if (byBlocks(item)) why.set(item.id, 'block');
546
- }
547
- const open = reviewOrder();
548
- return {
549
- open,
550
- outdated: open.filter((id) => outdated.has(id)),
551
- undrawn: reviewing.items.flatMap((item) => {
552
- const reason = why.get(item.id);
553
- return reason ? [{ id: item.id, reason }] : [];
554
- })
555
- };
556
- }
557
587
  // The report, to a host counting its own list: each change, read once the leaves the change
558
- // mounted have drawn, so a list just handed over is not reported as anchored nowhere.
588
+ // mounted have drawn, so a list just handed over is not reported as anchored nowhere. A
589
+ // review starts on its first change, and goes on to the first open one wherever the current
590
+ // one went without an answer moving it on.
559
591
  const NO_REPORT = JSON.stringify({ open: [], outdated: [], undrawn: [] } satisfies ReviewDrawn);
560
592
  let drewReport = NO_REPORT;
561
- let drewOrder: readonly string[] = [];
593
+ let drewOrder = $state.raw<readonly string[]>([]);
594
+ let drewOutdated = $state.raw<readonly string[]>([]);
562
595
  $effect(() => {
563
- void reviewing.items;
564
- void reviewing.fieldUndrawn;
565
- for (const id of reviewing.fieldOutdated) void id;
566
- for (const report of reviewing.reports.values()) void report;
596
+ void reviewing.report;
567
597
  let live = true;
568
598
  void tick().then(() => {
569
599
  if (!live || !span.alive) return;
570
- const report = reviewReport();
600
+ const report = reviewing.report;
571
601
  drewOrder = report.open;
602
+ drewOutdated = report.outdated;
603
+ if (reviewing.lit === undefined && report.open.length) reviewing.reveal(report.open[0]);
572
604
  const joined = JSON.stringify(report);
573
605
  if (joined === drewReport) return;
574
606
  drewReport = joined;
@@ -578,45 +610,158 @@
578
610
  live = false;
579
611
  };
580
612
  });
613
+ /**
614
+ * Make the next open change current after `id`'s answer, in `order` as it stood before the
615
+ * answer, round from the end. The pane scrolls only where that change is out of comfortable
616
+ * view, and neither the focus nor the caret moves.
617
+ */
618
+ function advanceFrom(id: string, order: readonly string[]): void {
619
+ const next = nextOpen(order, id, new Set(reviewing.items.map((item) => item.id)));
620
+ if (next === undefined) return;
621
+ typing = false;
622
+ reviewing.reveal(next);
623
+ void reveal(next, false, true);
624
+ }
581
625
  /** The item a step last went to, and where it stood in the order then, so a step from an
582
626
  * item since answered goes on from its place. */
583
627
  let stepped: { id: string; index: number } | undefined;
584
- async function step(
585
- dir: 1 | -1,
586
- focus: boolean,
587
- from?: { id: string; index: number }
588
- ): Promise<string | undefined> {
628
+ async function step(dir: 1 | -1, focus: boolean, group?: string): Promise<string | undefined> {
589
629
  if (!span.alive) return undefined;
590
- const order = reviewOrder();
591
- if (!order.length) return undefined;
592
- const at = from ? -1 : order.indexOf(reviewing.lit ?? stepped?.id ?? '');
593
- const past = from ?? stepped;
594
- const next =
595
- at >= 0 ? at + dir : past ? (dir > 0 ? past.index : past.index - 1) : dir > 0 ? 0 : -1;
596
- const index = ((next % order.length) + order.length) % order.length;
630
+ const order = reviewing.order;
631
+ const index = stepIn(
632
+ order,
633
+ dir,
634
+ reviewing.lit ?? stepped?.id,
635
+ stepped?.index,
636
+ group === undefined ? undefined : inGroup(group)
637
+ );
638
+ if (index === undefined) return undefined;
597
639
  const id = order[index];
598
640
  stepped = { id, index };
641
+ typing = false;
599
642
  await reveal(id, focus, true);
600
643
  return id;
601
644
  }
602
- const stepKeys = keydownHandler({
645
+
646
+ // ── The review keys: the editor's wherever the focus is while a review is open ──────
647
+ /** Answer the current change, as its card would. False with none open. */
648
+ function answerCurrent(action: 'accept' | 'dismiss'): boolean {
649
+ const id = reviewing.lit;
650
+ return id !== undefined && answerReview([id], action).length > 0;
651
+ }
652
+ /** An answer key: the card's, so it answers only a change the card stands on in view. A
653
+ * press while the reader types in the editor is the leaf's own key, and any other press
654
+ * with the change out of view or the card out of the way brings both back. */
655
+ function answerByKey(action: 'accept' | 'dismiss'): boolean {
656
+ const id = reviewing.lit;
657
+ if (id === undefined || (typing && inside)) return false;
658
+ if (!typing && inView(id)) return answerCurrent(action);
659
+ typing = false;
660
+ void reveal(id, false, true);
661
+ return true;
662
+ }
663
+ /** Whether a key at `target` is the review's: anywhere but a text control outside the editor,
664
+ * which keeps its own keys, or another editor. */
665
+ function reviewHears(target: EventTarget | null): boolean {
666
+ if (!(target instanceof Element) || !rootEl) return false;
667
+ if (rootEl.contains(target)) return true;
668
+ if (target.closest('.qm-editor')) return false;
669
+ return !target.closest('input, textarea, select, [contenteditable="true"]');
670
+ }
671
+ let answerCard = $state<ReviewCard | undefined>();
672
+ const reviewKeys = keydownHandler({
673
+ [REVIEW_KEYS.accept]: () => answerByKey('accept'),
674
+ [REVIEW_KEYS.dismiss]: () => answerByKey('dismiss'),
603
675
  [REVIEW_KEYS.next]: () => {
604
- void step(1, true);
676
+ void step(1, inside);
605
677
  return true;
606
678
  },
607
679
  [REVIEW_KEYS.previous]: () => {
608
- void step(-1, true);
680
+ void step(-1, inside);
681
+ return true;
682
+ },
683
+ 'Alt-F10': () => {
684
+ if (!answerCard || document.getSelection()?.isCollapsed === false) return false;
685
+ void answerCard.enter();
609
686
  return true;
610
687
  }
611
688
  });
612
- /** The step chords, from anywhere under the root, ahead of a leaf's own arrows. */
613
- function onStepKey(e: KeyboardEvent): void {
614
- if (e.isComposing || !reviewing.items.length) return;
689
+ /** Whether the key being matched was pressed inside the editor, where a step takes the caret
690
+ * with it. */
691
+ let inside = false;
692
+ /** The review keys, captured on the document ahead of every other binding of them: a task
693
+ * item's tick, a leaf's arrows, a host's own. */
694
+ function onReviewKey(e: KeyboardEvent): void {
695
+ if (e.isComposing || reviewing.lit === undefined || !reviewHears(e.target)) return;
696
+ inside = !!rootEl?.contains(e.target as Node);
615
697
  // The bindings read no view: this is `prosemirror-keymap`'s chord matcher alone.
616
- if (!stepKeys({} as never, e)) return;
698
+ if (!reviewKeys({} as never, e)) return;
617
699
  e.preventDefault();
618
700
  e.stopPropagation();
619
701
  }
702
+
703
+ /** The reader is typing: the card keeps out of the way until the pointer moves or the
704
+ * current change does. */
705
+ let typing = $state(false);
706
+ let pointerAt = { x: NaN, y: NaN };
707
+ function onTyped(e: KeyboardEvent): void {
708
+ if (reviewing.lit === undefined || e.metaKey || e.ctrlKey || e.altKey) return;
709
+ if (e.key.length === 1 || e.key === 'Backspace' || e.key === 'Delete' || e.key === 'Enter')
710
+ typing = true;
711
+ }
712
+ function onPointerMove(e: PointerEvent): void {
713
+ if (!typing) {
714
+ pointerAt = { x: e.clientX, y: e.clientY };
715
+ return;
716
+ }
717
+ const moved = Math.abs(e.clientX - pointerAt.x) + Math.abs(e.clientY - pointerAt.y);
718
+ pointerAt = { x: e.clientX, y: e.clientY };
719
+ if (moved >= MOVED_PX) typing = false;
720
+ }
721
+ /** How far, in px, the pointer moves before it means to: a hand resting on a trackpad
722
+ * jitters by less. */
723
+ const MOVED_PX = 3;
724
+ /** The items an element draws: one for a piece of a change, several for a control that
725
+ * marks a proposal for each place inside it. */
726
+ function reviewIds(el: Element | null | undefined): string[] {
727
+ return el?.getAttribute('data-qm-review')?.split(' ').filter(Boolean) ?? [];
728
+ }
729
+ /** A press on a change makes it current at once. */
730
+ function onPick(e: PointerEvent): void {
731
+ const ids = reviewIds((e.target as Element | null)?.closest?.('[data-qm-review]'));
732
+ const id = ids.includes(reviewing.lit ?? '') ? reviewing.lit : ids[0];
733
+ if (id && reviewing.items.some((item) => item.id === id)) {
734
+ typing = false;
735
+ reviewing.reveal(id);
736
+ }
737
+ }
738
+ /** What the change `id` is to: the field it is drawn in, the body, or the card it adds or
739
+ * takes out. */
740
+ function reviewName(id: string): string {
741
+ const item = reviewing.items.find((it) => it.id === id);
742
+ if (!item) return '';
743
+ if ('add' in item) return `${merged.reviewNewCard}, ${previewOf(item).title}`;
744
+ if ('remove' in item) {
745
+ const c = model.cards.find((c) => reviewing.cards.removes.get(c.id)?.id === id);
746
+ const t = c && titled(c);
747
+ return t ? `${merged.reviewRemoveCard}, ${t.titleOverride || t.titlePlaceholder}` : '';
748
+ }
749
+ if (addrForFieldPath(item.field)?.field == null && byBlocks(item)) return merged.bodyLabel;
750
+ const key = reviewed(item.field);
751
+ if (!key?.field) return '';
752
+ const isMain = key.card === undefined;
753
+ const card = isMain ? model.main : model.cards[cardIndexOf(key.card as CardId)];
754
+ const schema = isMain ? quill.schema.main : quill.schema.card_kinds?.[card?.kind ?? ''];
755
+ const sub = schema?.fields[key.field];
756
+ return sub ? fieldTitle(key.field, sub) : humanize(key.field);
757
+ }
758
+ /** Where the current change stands and what it is to, for a screen reader to hear on each
759
+ * step. */
760
+ const reviewPlace = $derived.by(() => {
761
+ const id = reviewing.lit;
762
+ const at = id === undefined ? -1 : drewOrder.indexOf(id);
763
+ return at < 0 ? '' : merged.reviewPosition(at + 1, drewOrder.length, reviewName(id!));
764
+ });
620
765
  // Card handles, for `setCaret`'s reveal hop: the one thing a leaf's own controller
621
766
  // cannot do, since which group is open is the card's state (Card §revealLeaf).
622
767
  type CardHandle = {
@@ -707,7 +852,7 @@
707
852
  const cardId = cardIdOf(plain);
708
853
  if (cardId == null) return;
709
854
  refreshTitle(plain, cardId);
710
- settled();
855
+ reviewing.settled();
711
856
  onChange?.({ source: 'prose', cardId, path: pathFor(plain) });
712
857
  }
713
858
 
@@ -961,10 +1106,7 @@
961
1106
  const { card } = gone;
962
1107
  const i = removed.place(gone, cardIds);
963
1108
  try {
964
- const taken = card.id !== undefined && cardIds.some((_, k) => doc.card(k).id === card.id);
965
- const back = { ...card };
966
- if (taken) delete back.id;
967
- doc.unchecked.insertCard(back, i);
1109
+ placeCardInto(doc, card, i);
968
1110
  } catch (e) {
969
1111
  reportError(onError, {
970
1112
  code: 'card-op-failed',
@@ -1210,6 +1352,38 @@
1210
1352
  cards: tree.cards.map((c) => patched[c.id] ?? c)
1211
1353
  });
1212
1354
 
1355
+ // ── What a screen reader hears of the diagnostics (INVARIANTS §Diagnostics) ──
1356
+ /** How long the drawn errors hold before they are spoken, so an edit's validation and
1357
+ * the diagnostics a host raises for it are one announcement, and a set that returns
1358
+ * to what was last said meanwhile says nothing. */
1359
+ const SPOKEN_MS = 500;
1360
+ /** Every error a leaf of the page draws, in the page's order, under its field's label. */
1361
+ const issues = $derived(
1362
+ [model.main, ...model.cards].flatMap((card) =>
1363
+ cardLayout(card).leaves.flatMap(({ key, name, schema }) => {
1364
+ const field = name !== undefined && schema ? fieldTitle(name, schema) : merged.bodyLabel;
1365
+ return (diagByKey.get(key) ?? []).map((d) => ({
1366
+ field,
1367
+ message: diagnosticText(d, formatDiagnostic, merged)
1368
+ }));
1369
+ })
1370
+ )
1371
+ );
1372
+ const issuesKey = $derived(JSON.stringify(issues));
1373
+ // What a mount starts from is not a change, so the first set is held as said.
1374
+ let spokenKey: string | undefined;
1375
+ let spoken = $state('');
1376
+ $effect(() => {
1377
+ const key = issuesKey;
1378
+ spokenKey ??= key;
1379
+ if (key === spokenKey) return;
1380
+ const timer = setTimeout(() => {
1381
+ spokenKey = issuesKey;
1382
+ spoken = merged.diagAnnounced(issues);
1383
+ }, SPOKEN_MS);
1384
+ return () => clearTimeout(timer);
1385
+ });
1386
+
1213
1387
  // ── Public entry points ─────────────────────────────────────────────────────
1214
1388
  /**
1215
1389
  * Resolve a preview {@link Landing} to a mounted leaf and land in it.
@@ -1326,6 +1500,16 @@
1326
1500
  const box = await land(found, undefined);
1327
1501
  if (span.alive) bloom(box);
1328
1502
  }
1503
+ /** Reveal the field at `field`, scroll it into the fold and wash it, taking no focus:
1504
+ * the landing a host makes on a touch screen, where a focus raises the keyboard. A
1505
+ * nested address reveals and washes its field, a row being something only a focus
1506
+ * opens. */
1507
+ export async function revealField(field: DocPath): Promise<void> {
1508
+ const found = await revealLeaf(field);
1509
+ if (!found) return missed(`no mounted field at ${field}`, field);
1510
+ found.control.el.scrollIntoView({ block: 'nearest', behavior: 'instant' });
1511
+ bloom(found.control.el);
1512
+ }
1329
1513
  /** Play the arrival wash over the field at `field` and touch nothing else: no focus,
1330
1514
  * no reveal, no scroll. A field in a closed panel is skipped, its box clipped to
1331
1515
  * nothing; a nested address washes its field's box, a row being something only a
@@ -1393,92 +1577,302 @@
1393
1577
  // ── Review ──────────────────────────────────────────────────────────────────
1394
1578
 
1395
1579
  /**
1396
- * Bring the review item `id` to the reader: open the panel holding it, scroll it to the
1397
- * middle of the view, and light it. The focus stays where it is, the reader having asked
1398
- * to look, unless `focus` asks for it: the caret then goes into the item, or the focus to
1399
- * its field, so the chords answer it. False for an item the editor does not draw.
1580
+ * Bring the review item `id` to the reader as the current change: open the panel holding
1581
+ * it and scroll it to the middle of the view. The focus stays where it is, the reader having
1582
+ * asked to look, unless `focus` asks for it: the caret then goes into the item, or the focus
1583
+ * to its field. False for an item the editor does not draw.
1400
1584
  */
1401
1585
  export function revealReview(id: string, opts: { focus?: boolean } = {}): Promise<boolean> {
1402
1586
  return reveal(id, opts.focus ?? false, false);
1403
1587
  }
1404
- /** {@link revealReview}; a step scrolls an item only as far as its scroller must to show it,
1405
- * so a walk down neighbouring items does not jump the page under each, and an item in a
1406
- * pane that scrolls on its own is shown by that pane. */
1588
+ /** {@link revealReview}; a step scrolls only where the item is out of comfortable view, room
1589
+ * for the answer card under it included, so a walk down neighbouring items moves the card
1590
+ * and not the page, and an item in a pane that scrolls on its own is shown by that pane. */
1407
1591
  async function reveal(id: string, focus: boolean, stepping: boolean): Promise<boolean> {
1408
1592
  if (!span.alive) return false;
1409
1593
  const key = reviewing.keyOf(id);
1410
- if (key === undefined) return false;
1411
- mainCard?.revealLeaf(key);
1412
- for (const card of cardRefs) card?.revealLeaf(key);
1594
+ const card = byCardId(id);
1595
+ if (key === undefined && !card) return false;
1596
+ if (key !== undefined) {
1597
+ mainCard?.revealLeaf(key);
1598
+ for (const ref of cardRefs) ref?.revealLeaf(key);
1599
+ }
1413
1600
  if (!(await span.resumes(tick()))) return false;
1414
1601
  reviewing.reveal(id);
1415
- if (focus && !leaves.prose(key)?.enterReview(id)) leaves.control(key)?.focus();
1416
- // The lit item is drawn again, so its element is read once it has been.
1602
+ if (focus && key !== undefined && !leaves.prose(key)?.enterReview(id))
1603
+ leaves.control(key)?.focus();
1604
+ // The current item is drawn again, so its element is read once it has been.
1417
1605
  if (!(await span.resumes(tick()))) return false;
1606
+ const els = reviewEls(id);
1418
1607
  const at =
1419
- leaves.prose(key)?.reviewElements(id)[0] ??
1420
- [...(rootEl?.querySelectorAll<HTMLElement>('[data-qm-review]') ?? [])].find(
1421
- (el) => el.getAttribute('data-qm-review') === id
1422
- ) ??
1423
- leaves.control(key)?.el;
1608
+ (key !== undefined ? leaves.prose(key)?.reviewElements(id)[0] : undefined) ??
1609
+ els[0] ??
1610
+ (key !== undefined ? leaves.control(key)?.el : undefined);
1611
+ if (!at || (stepping && comfortable(els.length ? els : [at]))) return true;
1424
1612
  const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
1425
- at?.scrollIntoView({
1426
- behavior: reduce ? 'auto' : 'smooth',
1427
- block: stepping ? 'nearest' : 'center'
1428
- });
1613
+ at.scrollIntoView({ behavior: reduce ? 'auto' : 'smooth', block: 'center' });
1429
1614
  return true;
1430
1615
  }
1616
+ /** Whether the open card item `id` is drawn. */
1617
+ function byCardId(id: string): boolean {
1618
+ for (const list of reviewing.cards.adds.values())
1619
+ if (list.some((a) => a.id === id)) return true;
1620
+ for (const item of reviewing.cards.removes.values()) if (item.id === id) return true;
1621
+ return false;
1622
+ }
1623
+ /** The elements that draw the item `id`. */
1624
+ function reviewEls(id: string): HTMLElement[] {
1625
+ return [...(rootEl?.querySelectorAll<HTMLElement>('[data-qm-review]') ?? [])].filter((el) =>
1626
+ reviewIds(el).includes(id)
1627
+ );
1628
+ }
1629
+ /** The band of the window the editor shows through: its nearest scroller's. */
1630
+ function pane(): { top: number; bottom: number } {
1631
+ for (let at = rootEl ?? null; at; at = at.parentElement) {
1632
+ const { overflowY } = getComputedStyle(at);
1633
+ if (overflowY !== 'auto' && overflowY !== 'scroll') continue;
1634
+ const box = at.getBoundingClientRect();
1635
+ return { top: Math.max(box.top, 0), bottom: Math.min(box.bottom, window.innerHeight) };
1636
+ }
1637
+ return { top: 0, bottom: window.innerHeight };
1638
+ }
1639
+ const boxes = (els: readonly HTMLElement[]): DOMRect[] =>
1640
+ els.map((el) => el.getBoundingClientRect()).filter((r) => r.width || r.height);
1641
+ /** Whether `els` stand in the view the editor scrolls in, clear of the host's chrome at its
1642
+ * foot, with the answer card's room under them. */
1643
+ function comfortable(els: readonly HTMLElement[]): boolean {
1644
+ const rects = boxes(els);
1645
+ if (!rects.length) return false;
1646
+ const { top, bottom } = pane();
1647
+ const room = (spacePx(rootEl, 1) ?? 0) * CARD_ROOM;
1648
+ return (
1649
+ Math.min(...rects.map((r) => r.top)) >= top &&
1650
+ Math.max(...rects.map((r) => r.bottom)) <= bottom - reviewInset - room
1651
+ );
1652
+ }
1653
+ /** Whether any of the item `id` shows in that view, which is where its answer card stands.
1654
+ * An editor with no box of its own measures nothing, and every item counts as shown. */
1655
+ function inView(id: string): boolean {
1656
+ if (!rootEl || !boxes([rootEl]).length) return true;
1657
+ const { top, bottom } = pane();
1658
+ return boxes(reviewEls(id)).some((r) => r.bottom > top && r.top < bottom - reviewInset);
1659
+ }
1660
+ /** The room the answer card takes under a change, in `--_qm-space` rungs. */
1661
+ const CARD_ROOM = 7;
1662
+
1663
+ /** Whether the item `id` is listed in `group`. */
1664
+ function inGroup(group: string): (id: string) => boolean {
1665
+ const ids = new Set(reviewing.items.filter((i) => i.group === group).map((i) => i.id));
1666
+ return (id) => ids.has(id);
1667
+ }
1431
1668
 
1432
1669
  /**
1433
- * Answer items as their buttons would, in document order: `'all'` is every item drawn. An
1670
+ * Answer items as the answer card would, in document order: `'all'` is every item drawn, and
1671
+ * `{ group }` every item drawn in that group, which as `'all'` does accepts none outdated. An
1434
1672
  * item that cannot be answered (a proposal that no longer writes, a value the field's writer
1435
- * refuses) stands. `onReview` hears each answer, and neither the focus nor the caret moves.
1436
- * The batch raises no toast, the host's to word if it wants one, and ⌘Z takes it back whole.
1437
- * Returns the ids answered.
1673
+ * refuses) stands. `onReview` hears each answer, and neither the focus nor the caret moves;
1674
+ * where the current change is answered, the next open one is current. ⌘Z takes the call
1675
+ * back whole. Returns the ids answered.
1438
1676
  */
1439
1677
  export function answerReview(
1440
- ids: readonly string[] | 'all',
1678
+ ids: readonly string[] | 'all' | { group: string },
1441
1679
  action: 'accept' | 'dismiss'
1442
1680
  ): string[] {
1443
1681
  if (!span.alive) return [];
1444
- const order = reviewOrder();
1445
- const asked = ids === 'all' ? order : order.filter((id) => ids.includes(id));
1446
- const out: string[] = [];
1447
- const entry: Answered = { ids: [], inverses: [] };
1448
- batching = entry;
1449
- writing++;
1450
- try {
1451
- for (const id of asked) {
1452
- const item = reviewing.items.find((it) => it.id === id);
1453
- if (!item) continue;
1454
- const key = reviewing.keyOf(id);
1455
- // Each one is planned against the document the one before it left.
1456
- const answered = !onField(item)
1457
- ? key !== undefined && !!leaves.prose(key)?.answerReview(id, action)
1458
- : reviewing.act(id, action);
1459
- if (answered) out.push(id);
1682
+ if (ids === 'all' || Array.isArray(ids)) return reviewing.answer(ids, action);
1683
+ const has = inGroup((ids as { group: string }).group);
1684
+ const stale = new Set(action === 'accept' ? drewOutdated : []);
1685
+ return reviewing.answer(
1686
+ reviewing.order.filter((id) => has(id) && !stale.has(id)),
1687
+ action
1688
+ );
1689
+ }
1690
+
1691
+ /**
1692
+ * Write every open item the editor draws into `target`, a copy of the document the host made,
1693
+ * as answering them all with Accept would: a field's value through the typed writer, a place
1694
+ * inside one as the field's whole value with that place changed, a card added or taken out,
1695
+ * and each prose leaf's proposals from the plans it draws them from. Nothing is written to the
1696
+ * document, and no hook, history or answer hears of it. Returns the way between places in the
1697
+ * document and places in `target`, which holds only while neither changes.
1698
+ */
1699
+ export function projectReview(target: Document): ReviewProjection {
1700
+ if (!span.alive) return NO_PROJECTION;
1701
+ const order = reviewing.order;
1702
+ if (!order.length) return NO_PROJECTION;
1703
+ const open = new Set(order);
1704
+ const byId = new Map(reviewing.items.map((item) => [item.id, item]));
1705
+ const written = new Set<string>();
1706
+
1707
+ const texts = new Map<string, LeafProjection>();
1708
+ for (const [key, report] of reviewing.reports) {
1709
+ if (!report.ids.some((id) => open.has(id))) continue;
1710
+ const projected = leaves.prose(key)?.projectReview(target);
1711
+ if (!projected) continue;
1712
+ texts.set(key, projected);
1713
+ for (const id of projected.ids) written.add(id);
1714
+ }
1715
+
1716
+ for (const [, field] of projectFields(order, byId)) {
1717
+ const at = field.isMain ? undefined : cardIndexOf(field.cardId);
1718
+ if (at !== undefined && at < 0) continue;
1719
+ try {
1720
+ if (field.value === undefined)
1721
+ target.removeField(at === undefined ? field.name : { card: at, field: field.name });
1722
+ else {
1723
+ const w = quill.writer(target);
1724
+ (at === undefined ? w : w.card(at)).set(field.name, field.value);
1725
+ }
1726
+ for (const id of field.ids) written.add(id);
1727
+ } catch {
1728
+ // A value the writer refuses is one its Accept could not write either.
1460
1729
  }
1461
- } finally {
1462
- writing--;
1463
- batching = undefined;
1464
1730
  }
1465
- if (entry.ids.length) {
1466
- if (!journalOffer || !undo.holds(journalOffer)) journal = [];
1467
- journal.push(entry);
1468
- offerJournal();
1731
+
1732
+ type Slot = { key: string } | { add: CardAdd };
1733
+ const adds = (lead: string): Slot[] =>
1734
+ (reviewing.cards.adds.get(lead) ?? []).filter((a) => open.has(a.id)).map((add) => ({ add }));
1735
+ const gone = new Set<string>();
1736
+ for (const [key, item] of reviewing.cards.removes)
1737
+ if (open.has(item.id)) {
1738
+ gone.add(key);
1739
+ written.add(item.id);
1740
+ }
1741
+ const wanted: Slot[] = [...adds('head')];
1742
+ for (const key of cardIds) {
1743
+ if (!gone.has(key)) wanted.push({ key });
1744
+ wanted.push(...adds(key));
1745
+ }
1746
+ wanted.push(...adds('end'));
1747
+ for (let i = cardIds.length - 1; i >= 0; i--) if (gone.has(cardIds[i])) target.removeCard(i);
1748
+ const slots: Slot[] = [];
1749
+ for (const slot of wanted) {
1750
+ if ('add' in slot && !placeCardIn(target, slot.add.add, slots.length)) continue;
1751
+ if ('add' in slot) written.add(slot.add.id);
1752
+ slots.push(slot);
1753
+ }
1754
+ const projected = new Map(slots.flatMap((slot, j) => ('key' in slot ? [[slot.key, j]] : [])));
1755
+
1756
+ const field = (at: DocPath | Landing): DocPath => (typeof at === 'string' ? at : at.field);
1757
+ const moved = <T extends DocPath | Landing>(at: T, path: DocPath, pos?: number): T =>
1758
+ (typeof at === 'string'
1759
+ ? path
1760
+ : { ...(at as Landing), field: path, ...(pos === undefined ? {} : { pos }) }) as T;
1761
+ const ids = order.filter((id) => written.has(id));
1762
+ return {
1763
+ ids,
1764
+ toProjection(at) {
1765
+ let path = field(at);
1766
+ const card = cardOfPath(path);
1767
+ if (card !== undefined && card < cardIds.length) {
1768
+ const j = projected.get(cardIds[card]);
1769
+ if (j === undefined) return undefined;
1770
+ path = pathOnCard(path, j);
1771
+ }
1772
+ const pos = typeof at === 'string' ? undefined : at.pos;
1773
+ const text = pos === undefined ? undefined : texts.get(proseKeyFor(field(at)) ?? '');
1774
+ return moved(at, path, text && pos !== undefined ? text.toProjection(pos) : pos);
1775
+ },
1776
+ toLive(at) {
1777
+ let path = field(at);
1778
+ const card = cardOfPath(path);
1779
+ if (card !== undefined) {
1780
+ const slot = slots[card];
1781
+ if (!slot) return undefined;
1782
+ if ('add' in slot) return { review: slot.add.id };
1783
+ path = pathOnCard(path, cardIndexOf(slot.key));
1784
+ }
1785
+ const pos = typeof at === 'string' ? undefined : at.pos;
1786
+ const text = pos === undefined ? undefined : texts.get(proseKeyFor(path) ?? '');
1787
+ const live = text && pos !== undefined ? text.toLive(pos) : pos;
1788
+ if (typeof live === 'object') return live;
1789
+ return moved(at, path, live);
1790
+ }
1791
+ };
1792
+ }
1793
+ /**
1794
+ * The value each field holds with every open field item on it taken, by leaf key, in the
1795
+ * page's order: a place inside a field found again in the value the items before it left, as
1796
+ * each accept finds it.
1797
+ */
1798
+ function projectFields(
1799
+ order: readonly string[],
1800
+ byId: ReadonlyMap<string, ReviewItem>
1801
+ ): Map<string, { cardId: string; isMain: boolean; name: string; value: unknown; ids: string[] }> {
1802
+ const out = new Map<
1803
+ string,
1804
+ { cardId: string; isMain: boolean; name: string; value: unknown; ids: string[] }
1805
+ >();
1806
+ const fieldUndrawn = new Set(reviewing.fieldUndrawn.map((u) => u.id));
1807
+ const nested = (item: ReviewItem): item is FieldProposal =>
1808
+ onField(item) && !fieldUndrawn.has(item.id) && !addrForFieldPath(item.field);
1809
+ const left = new Set(order);
1810
+ for (const id of order) {
1811
+ const item = byId.get(id);
1812
+ left.delete(id);
1813
+ if (!item || !onField(item)) continue;
1814
+ const key = reviewed(item.field);
1815
+ if (!key?.field || typeof key.card === 'number') continue;
1816
+ const leaf = fieldKeyToString(key);
1817
+ const isMain = key.card === undefined;
1818
+ const cardId = key.card ?? model.main.id;
1819
+ let held = out.get(leaf);
1820
+ if (!held) {
1821
+ const at = isMain ? 0 : cardIndexOf(cardId);
1822
+ if (at < 0) continue;
1823
+ const value = fieldValues((isMain ? doc.main : doc.card(at)).payloadItems)[key.field];
1824
+ out.set(leaf, (held = { cardId, isMain, name: key.field, value, ids: [] }));
1825
+ }
1826
+ if (addrForFieldPath(item.field)) held.value = reviewing.writes(item, held.value);
1827
+ else {
1828
+ const steps = leafTargetFor(item.field)?.steps;
1829
+ if (!steps) continue;
1830
+ // Each item before it on the field claims its member first, as the derive does.
1831
+ const claimed = new Set<string>();
1832
+ let found: readonly PathStep[] | undefined;
1833
+ for (const other of reviewing.items) {
1834
+ if (other !== item && !(left.has(other.id) && nested(other))) continue;
1835
+ const otherKey = reviewed((other as FieldProposal).field);
1836
+ const path =
1837
+ other === item ? steps : leafTargetFor((other as FieldProposal).field)?.steps;
1838
+ if (!otherKey || fieldKeyToString(otherKey) !== leaf || !path) continue;
1839
+ const located = locate(held.value, path, other as FieldProposal, claimed);
1840
+ if (other === item) {
1841
+ found = located.steps;
1842
+ break;
1843
+ }
1844
+ }
1845
+ if (!found) continue;
1846
+ held.value = valueWith(
1847
+ held.value,
1848
+ found,
1849
+ reviewing.writes(item, valueIn(held.value, found))
1850
+ );
1851
+ }
1852
+ held.ids.push(id);
1469
1853
  }
1470
1854
  return out;
1471
1855
  }
1856
+ /** Write `card` into `target` at `at`, with its `$id` where no card there holds that one,
1857
+ * as {@link placeCard} writes it into the document. */
1858
+ function placeCardIn(target: Document, card: CardAdd['add'], at: number): boolean {
1859
+ try {
1860
+ placeCardInto(target, card, at);
1861
+ return true;
1862
+ } catch {
1863
+ return false;
1864
+ }
1865
+ }
1472
1866
 
1473
- /** Bring the next or previous open item to the reader, in document order and round from
1474
- * either end, from the lit item or the one last stepped to: the caret in it, or the
1475
- * focus in its field, unless `focus` is false. Resolves its id, `undefined` when none is
1476
- * drawn. */
1867
+ /** Make the next or previous open item current, in document order and round from either
1868
+ * end, from the current item or the one last stepped to: the caret in it, or the focus in
1869
+ * its field, unless `focus` is false. With `group`, only that group's items are stepped to.
1870
+ * Resolves its id, `undefined` when none is drawn. */
1477
1871
  export function stepReview(
1478
1872
  dir: 1 | -1,
1479
- opts: { focus?: boolean } = {}
1873
+ opts: { focus?: boolean; group?: string } = {}
1480
1874
  ): Promise<string | undefined> {
1481
- return step(dir, opts.focus ?? true);
1875
+ return step(dir, opts.focus ?? true, opts.group);
1482
1876
  }
1483
1877
 
1484
1878
  function holds(cardId: CardId): boolean {
@@ -1548,7 +1942,13 @@
1548
1942
  }
1549
1943
  </script>
1550
1944
 
1551
- <svelte:document onkeydowncapture={onUndoKey} />
1945
+ <svelte:document
1946
+ onkeydowncapture={(e) => {
1947
+ onReviewKey(e);
1948
+ if (!e.defaultPrevented) onUndoKey(e);
1949
+ }}
1950
+ onpointermove={onPointerMove}
1951
+ />
1552
1952
 
1553
1953
  <!-- The keydown is a control's, bubbled: the root resolves which description it raises.
1554
1954
  A file dragged over or dropped is refused here, after any control has seen it. -->
@@ -1558,7 +1958,9 @@
1558
1958
  {style}
1559
1959
  data-qm-root
1560
1960
  bind:this={rootEl}
1561
- onkeydowncapture={onStepKey}
1961
+ {@attach tooltips}
1962
+ onkeydowncapture={onTyped}
1963
+ onpointerdowncapture={onPick}
1562
1964
  onkeydown={raiseGuidance}
1563
1965
  ondragover={refuseFiles}
1564
1966
  ondrop={refuseFiles}
@@ -1592,32 +1994,65 @@
1592
1994
  {/if}
1593
1995
  </div>
1594
1996
 
1997
+ {@render cardsAdded('head')}
1595
1998
  {@render addAffordance(0)}
1596
1999
  <!-- A card and the gap under it are one slot, which is what a reorder moves: the
1597
2000
  strip below a card is the same strip wherever the card lands, so it rides along
1598
2001
  rather than being slid across. It is also the shape `animate:` asks for, being the
1599
2002
  keyed block's only child. -->
1600
2003
  {#each model.cards as c, i (c.id)}
2004
+ {@const removal = reviewing.cards.removes.get(c.id)}
1601
2005
  <div class="qm-card-slot" bind:this={slotEls[i]} animate:reorder={arm.armed} in:slot out:slot>
1602
- <Card
1603
- bind:this={cardRefs[i]}
1604
- card={titled(c)}
1605
- {doc}
1606
- {quill}
1607
- isFirst={i === 0}
1608
- isLast={i === model.cards.length - 1}
1609
- {kinds}
1610
- ops={opsFor(c.id, false)}
1611
- {enumDisallowed}
1612
- onFocus={handleFocus}
1613
- onCaretMove={handleCaret}
1614
- onChange={proseChanged}
1615
- {onError}
1616
- {leaves}
1617
- />
2006
+ <!-- A removal's mark wraps the whole card it would take out, so the answer card
2007
+ stands under the card and not on it. -->
2008
+ <div
2009
+ class={[
2010
+ 'qm-review-card-remove',
2011
+ { 'qm-review-on': !!removal, 'qm-review-lit': !!removal && reviewing.lit === removal.id }
2012
+ ]}
2013
+ data-qm-review={removal?.id}
2014
+ role={removal ? 'group' : undefined}
2015
+ aria-label={removal ? merged.reviewRemoveCard : undefined}
2016
+ >
2017
+ <Card
2018
+ bind:this={cardRefs[i]}
2019
+ card={titled(c)}
2020
+ {doc}
2021
+ {quill}
2022
+ isFirst={i === 0}
2023
+ isLast={i === model.cards.length - 1}
2024
+ {kinds}
2025
+ ops={opsFor(c.id, false)}
2026
+ {enumDisallowed}
2027
+ onFocus={handleFocus}
2028
+ onCaretMove={handleCaret}
2029
+ onChange={proseChanged}
2030
+ {onError}
2031
+ {leaves}
2032
+ tag={removal ? merged.reviewRemoveCard : undefined}
2033
+ />
2034
+ </div>
2035
+ {@render cardsAdded(c.id)}
1618
2036
  {@render addAffordance(i + 1)}
1619
2037
  </div>
1620
2038
  {/each}
2039
+ {@render cardsAdded('end')}
2040
+ <ReviewCard
2041
+ bind:this={answerCard}
2042
+ id={reviewing.lit}
2043
+ root={rootEl}
2044
+ inset={reviewInset}
2045
+ hidden={typing}
2046
+ outdated={reviewing.lit !== undefined && drewOutdated.includes(reviewing.lit)}
2047
+ note={reviewing.lit === undefined
2048
+ ? undefined
2049
+ : reviewing.items.find((i) => i.id === reviewing.lit)?.note}
2050
+ onAnswer={answerCurrent}
2051
+ />
2052
+ <div class="qm-visually-hidden" role="status">{reviewPlace}</div>
2053
+ <!-- Beside the review's region rather than in it or in the toast's: a status is read whole,
2054
+ so a shared one would repeat what the other said. -->
2055
+ <div class="qm-visually-hidden qm-diag-live" role="status">{spoken}</div>
1621
2056
  <!-- The way back to a removed card once its toast has gone: the newest kept step, by
1622
2057
  name, at the stack's foot, where the control that adds a card is looked for. -->
1623
2058
  {#if undo.kept}
@@ -1645,7 +2080,7 @@
1645
2080
  <span class="qm-toast-notice">{undo.current.notice}</span>
1646
2081
  <button
1647
2082
  type="button"
1648
- class="qm-toast-action qm-focus-ring"
2083
+ class="qm-toast-action qm-chip qm-focus-ring"
1649
2084
  aria-keyshortcuts="Meta+Z Control+Z"
1650
2085
  onclick={() => undo.take()}>{merged.undoAction}</button
1651
2086
  >
@@ -1662,6 +2097,40 @@
1662
2097
  neither dropped nor trapped. The gate lives here rather than at each call site: the
1663
2098
  strip is one decision, and two copies of it drift into a stack with a gap at one
1664
2099
  end. -->
2100
+ <!-- The cards proposed new after the card at `lead`, each a preview where it would stand: its
2101
+ kind's title, its own title or the words that name it, and the start of its body. -->
2102
+ {#snippet cardsAdded(lead: string)}
2103
+ {@const adds = reviewing.cards.adds.get(lead)}
2104
+ {#if adds?.length}
2105
+ <div class="qm-review-head">
2106
+ {#each adds as item (item.id)}
2107
+ {@const preview = previewOf(item)}
2108
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
2109
+ <div
2110
+ class={['qm-review-card-add', { 'qm-review-lit': reviewing.lit === item.id }]}
2111
+ data-qm-review={item.id}
2112
+ role="group"
2113
+ aria-label={`${merged.reviewNewCard}, ${preview.title}`}
2114
+ >
2115
+ <div class="qm-review-card-add-head">
2116
+ <span class="qm-review-card-add-title">{preview.title}</span>
2117
+ <span class="qm-review-card-tag">{merged.reviewNewCard}</span>
2118
+ </div>
2119
+ {#if preview.fields.length}
2120
+ <dl class="qm-review-card-add-fields">
2121
+ {#each preview.fields as { label, value }, n (n)}
2122
+ <dt>{label}</dt>
2123
+ <dd>{value}</dd>
2124
+ {/each}
2125
+ </dl>
2126
+ {/if}
2127
+ {#if preview.text}<p class="qm-review-card-add-text">{preview.text}</p>{/if}
2128
+ </div>
2129
+ {/each}
2130
+ </div>
2131
+ {/if}
2132
+ {/snippet}
2133
+
1665
2134
  {#snippet addAffordance(atIndex: number)}
1666
2135
  {#if kinds.length}
1667
2136
  <!-- The strip past the last card is the append point, the one a reader looks for
@@ -1670,14 +2139,14 @@
1670
2139
  on hover is the space the new card takes. -->
1671
2140
  {@const marked = atIndex === model.cards.length}
1672
2141
  <div class={['qm-add-card', { 'qm-add-card-marked': marked }]}>
1673
- <!-- Marked, the words are the accessible name and no `aria-label` doubles
1674
- them; bare, the same words land as the label, the strip having no
1675
- content to carry them. -->
2142
+ <!-- The string is the name on every strip: marked, the strip draws a `+` ahead
2143
+ of the words, which is the template's glyph and no part of the name; bare,
2144
+ it has no content to carry them. -->
1676
2145
  {#if kinds.length === 1}
1677
2146
  <button
1678
2147
  type="button"
1679
2148
  class="qm-add-btn qm-add-affordance qm-tap-floor qm-focus-ring"
1680
- aria-label={marked ? undefined : merged.addCard}
2149
+ aria-label={merged.addCard}
1681
2150
  onclick={() => addCard(atIndex, kinds[0], true)}
1682
2151
  >{#if marked}{`+ ${merged.addCard}`}{/if}</button
1683
2152
  >
@@ -1690,12 +2159,13 @@
1690
2159
  <DropdownMenu.Root>
1691
2160
  <DropdownMenu.Trigger
1692
2161
  class="qm-add-btn qm-add-affordance qm-tap-floor qm-focus-ring"
1693
- aria-label={marked ? undefined : merged.addCard}
2162
+ aria-label={merged.addCard}
1694
2163
  >{#if marked}{`+ ${merged.addCard}`}{/if}</DropdownMenu.Trigger
1695
2164
  >
1696
2165
  <DropdownMenu.Portal to={rootEl}>
1697
2166
  <DropdownMenu.Content
1698
2167
  collisionBoundary={rootEl ?? []}
2168
+ strategy="absolute"
1699
2169
  sideOffset={spacePx(rootEl)}
1700
2170
  onCloseAutoFocus={(e) => {
1701
2171
  if (picked) e.preventDefault();
@@ -1750,19 +2220,14 @@
1750
2220
  color: var(--_qm-ink);
1751
2221
  pointer-events: auto;
1752
2222
  }
2223
+ /* A chip (controls.css), in the toast's own corner. It stands at the ink and the chrome's
2224
+ weight where a chip rests at the label rung: it is the one action here, and the notice
2225
+ beside it is at the ink, so a rung under that would set the action quieter than the
2226
+ sentence it acts on. */
1753
2227
  .qm-toast-action {
1754
- min-height: var(--_qm-tap-min);
1755
- padding-inline: var(--_qm-space-2);
1756
- border: 0;
1757
2228
  border-radius: var(--_qm-radius-pill);
1758
- background: transparent;
1759
- font: inherit;
1760
- font-weight: var(--_qm-weight-strong);
1761
- color: var(--_qm-accent);
1762
- cursor: pointer;
1763
- }
1764
- .qm-toast-action:hover {
1765
- background: var(--_qm-accent-tint);
2229
+ font-weight: var(--_qm-weight-mid);
2230
+ color: var(--_qm-ink);
1766
2231
  }
1767
2232
  /* Words at the label ink, unboxed: the stack's foot already holds one outlined pill, and
1768
2233
  a second would stand as its equal. */
@@ -1806,6 +2271,9 @@
1806
2271
  back to being one block clipped at its edges. That is the page form; a pane's
1807
2272
  frame is the host's, and it spends less (`.qm-pane` below). */
1808
2273
  :global(:where(.qm-editor)) {
2274
+ /* The frame every floating surface is placed in (INVARIANTS §Chrome), so a pane that
2275
+ scrolls carries them with the text. */
2276
+ position: relative;
1809
2277
  box-sizing: border-box;
1810
2278
  display: flex;
1811
2279
  flex-direction: column;
@@ -1877,6 +2345,175 @@
1877
2345
  flex-direction: column;
1878
2346
  gap: var(--_qm-space-2);
1879
2347
  }
2348
+ /* A card proposed new and a card proposed taken out, in the review's one hue: a preview
2349
+ where the new card would stand, the card's own ground under the tint, and a mark round
2350
+ the whole of a card that would go, its values struck as a removed row's are. The
2351
+ current one's mark is a step stronger, as a current proposal's words are. */
2352
+ .qm-review-card-remove {
2353
+ display: contents;
2354
+ }
2355
+ .qm-review-card-remove.qm-review-on {
2356
+ display: block;
2357
+ border-radius: var(--_qm-radius);
2358
+ box-shadow: 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
2359
+ }
2360
+ .qm-review-card-remove.qm-review-lit {
2361
+ box-shadow: 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
2362
+ }
2363
+ .qm-review-head {
2364
+ display: flex;
2365
+ flex-direction: column;
2366
+ gap: var(--_qm-space-2);
2367
+ }
2368
+ .qm-review-card-add {
2369
+ display: flex;
2370
+ flex-direction: column;
2371
+ gap: var(--_qm-space);
2372
+ padding: var(--_qm-space-3) var(--_qm-card-inset);
2373
+ border-radius: var(--_qm-radius);
2374
+ background: linear-gradient(var(--_qm-review-tint), var(--_qm-review-tint)) var(--_qm-surface);
2375
+ }
2376
+ /* A control showing a value a proposal would write, which it cannot draw as words: the review
2377
+ tint over the whole control and an edge in the review line, so the mark is not colour alone,
2378
+ laid over it so it takes no room and moves nothing. It takes
2379
+ the box's `::after` whole, over what the arrival wash or a tap floor set there. A member a
2380
+ proposal takes out is struck where it stands. */
2381
+ :global([data-qm-proposed]),
2382
+ :global(.qm-review-added-box :is(.qm-toggle, .qm-tick)) {
2383
+ position: relative;
2384
+ }
2385
+ :global([data-qm-proposed])::after,
2386
+ :global(.qm-review-added-box :is(.qm-toggle, .qm-tick))::after {
2387
+ content: '';
2388
+ position: absolute;
2389
+ inset: 0;
2390
+ width: auto;
2391
+ height: auto;
2392
+ transform: none;
2393
+ border-radius: var(--_qm-radius-inner);
2394
+ background: var(--_qm-review-tint);
2395
+ box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
2396
+ opacity: 1;
2397
+ pointer-events: none;
2398
+ transition: background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
2399
+ }
2400
+ /* A switch's track keeps its own shape under the mark. */
2401
+ :global(.qm-toggle[data-qm-proposed])::after,
2402
+ :global(.qm-review-added-box .qm-toggle)::after {
2403
+ border-radius: inherit;
2404
+ }
2405
+ /* The current one's edge is a step stronger, as a removed card's ring is. */
2406
+ :global([data-qm-proposed-lit])::after,
2407
+ :global(.qm-review-lit > .qm-review-added-box :is(.qm-toggle, .qm-tick))::after {
2408
+ background: var(--_qm-review-lit);
2409
+ box-shadow: inset 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
2410
+ }
2411
+ :global([data-qm-removes]) {
2412
+ text-decoration: line-through;
2413
+ text-decoration-color: var(--_qm-review-line);
2414
+ }
2415
+ /* A member a proposal would add, drawn as its own control holding the value: each box in it
2416
+ under the tint, which a box's own fill keeps beneath, and the current one ringed. A switch's
2417
+ track and a tick's square paint their state over any image, so they take the overlay a
2418
+ proposed switch does. */
2419
+ :global(.qm-review-added-box) {
2420
+ display: contents;
2421
+ pointer-events: none;
2422
+ }
2423
+ :global(.qm-review-added-box :is(.qm-control-box, .qm-input)) {
2424
+ background-image: linear-gradient(var(--_qm-review-tint), var(--_qm-review-tint));
2425
+ box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
2426
+ }
2427
+ :global(.qm-review-lit > .qm-review-added-box :is(.qm-control-box, .qm-input)) {
2428
+ background-image: linear-gradient(var(--_qm-review-lit), var(--_qm-review-lit));
2429
+ box-shadow: inset 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
2430
+ }
2431
+ /* A row a proposal would take out: no tint, which only ever means "would come", but a ring
2432
+ in the review line laid outside the row so it takes no room, its values struck and its
2433
+ labels left alone. The current one's ring is a step stronger, as a removed card's. */
2434
+ :global([data-qm-removed]) {
2435
+ border-radius: var(--_qm-radius-inner);
2436
+ box-shadow: 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
2437
+ }
2438
+ :global([data-qm-removed-lit]) {
2439
+ box-shadow: 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
2440
+ }
2441
+ /* What a removed row or card holds is what the reader reads to answer it, so its words
2442
+ step back to the label ink under the strike, as a struck word does in a paragraph
2443
+ (`codec/prose.css`), and no further: the ring, the strike and the tag say removed. A
2444
+ switch and a tick have no word to strike and keep their state as drawn. */
2445
+ :global(
2446
+ :is([data-qm-removed], .qm-review-card-remove.qm-review-on)
2447
+ :is(.qm-control-box:not(.qm-element-summary), .qm-input, .qm-prose, .qm-element-preview)
2448
+ ) {
2449
+ color: var(--_qm-ink-label);
2450
+ text-decoration: line-through;
2451
+ text-decoration-color: var(--_qm-review-line);
2452
+ }
2453
+ @media (forced-colors: active) {
2454
+ :global([data-qm-proposed])::after {
2455
+ border: var(--_qm-border-width) dashed Highlight;
2456
+ }
2457
+ :global([data-qm-proposed-lit])::after {
2458
+ border-style: solid;
2459
+ }
2460
+ :global([data-qm-removed]) {
2461
+ outline: var(--_qm-border-width) dashed Highlight;
2462
+ }
2463
+ :global([data-qm-removed-lit]) {
2464
+ outline-style: solid;
2465
+ }
2466
+ :global(.qm-review-added-box :is(.qm-control-box, .qm-toggle, .qm-tick, .qm-input)) {
2467
+ outline: var(--_qm-border-width) dashed Highlight;
2468
+ outline-offset: calc(-1 * var(--_qm-border-width));
2469
+ }
2470
+ }
2471
+ .qm-review-card-add.qm-review-lit {
2472
+ background: linear-gradient(var(--_qm-review-lit), var(--_qm-review-lit)) var(--_qm-surface);
2473
+ }
2474
+ .qm-review-card-add-head {
2475
+ display: flex;
2476
+ align-items: baseline;
2477
+ gap: var(--_qm-space-2);
2478
+ }
2479
+ .qm-review-card-add-title {
2480
+ font-size: var(--_qm-text-title);
2481
+ font-weight: var(--_qm-weight-mid);
2482
+ }
2483
+ .qm-review-card-tag {
2484
+ font-size: var(--_qm-text-label);
2485
+ font-weight: var(--_qm-weight-mid);
2486
+ color: var(--_qm-ink-label);
2487
+ }
2488
+ .qm-review-card-add-fields {
2489
+ display: grid;
2490
+ grid-template-columns: auto 1fr;
2491
+ gap: var(--_qm-space) var(--_qm-space-3);
2492
+ margin: 0;
2493
+ font-size: var(--_qm-text-label);
2494
+ }
2495
+ .qm-review-card-add-fields dt {
2496
+ color: var(--_qm-ink-label);
2497
+ }
2498
+ .qm-review-card-add-fields dd {
2499
+ margin: 0;
2500
+ overflow-wrap: anywhere;
2501
+ }
2502
+ .qm-review-card-add-text {
2503
+ margin: 0;
2504
+ color: var(--_qm-ink-label);
2505
+ white-space: pre-line;
2506
+ display: -webkit-box;
2507
+ -webkit-line-clamp: 3;
2508
+ line-clamp: 3;
2509
+ -webkit-box-orient: vertical;
2510
+ overflow: hidden;
2511
+ }
2512
+ @media (forced-colors: active) {
2513
+ .qm-review-card-add {
2514
+ outline: var(--_qm-border-width) solid CanvasText;
2515
+ }
2516
+ }
1880
2517
  /* The strip between two blocks, and the whole of it is the target: a gap is found by
1881
2518
  position, so reveal and hit region are the full-bleed row rather than a word to aim
1882
2519
  at in the middle of it. Taking the editor's gap back on both sides is what makes it