@quillmark/svelte 0.34.0 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  // Review, drawn in the leaf's own flow: what a writer other than the reader proposes to change
2
- // here, and what of it the reader took. An item names blocks by the ids the leaf's nodes carry, so
3
- // its place is the document's and rides every edit; nothing is measured from outside the view.
2
+ // here. An item names blocks by the ids the leaf's nodes carry, so its place is the document's and
3
+ // rides every edit; nothing is measured from outside the view.
4
4
  //
5
5
  // A proposal is the paragraph it would rewrite, read as an edit of itself: the words that would go
6
6
  // struck, the words that would come tinted in their place, and what it adds beyond the paragraph
7
7
  // set in flow under it. None of it enters the document while it is proposed: the struck words are
8
- // the leaf's own text under a decoration, and every added word is a widget. A proposal taken is a
9
- // mark over the text it wrote, or a wedge where it only took text out.
8
+ // the leaf's own text under a decoration, and every added word is a widget. A proposal taken is
9
+ // plain text, the leaf's like any other.
10
10
  //
11
11
  // A proposal is an edit of the paragraph as its writer read it, or as it stood when it arrived. What the reader
12
12
  // writes in the paragraph since is theirs: the proposal's stretches ride past it, and only the
@@ -16,7 +16,7 @@
16
16
  // words that land are the words that were drawn. It goes down the lane a keystroke takes: one
17
17
  // transaction, one undo step, one commit.
18
18
  import { closeHistory, isHistoryTransaction, undo } from 'prosemirror-history';
19
- import { DOMSerializer, Fragment, Mark, Slice } from 'prosemirror-model';
19
+ import { DOMSerializer, Fragment, Mark } from 'prosemirror-model';
20
20
  import { keydownHandler } from 'prosemirror-keymap';
21
21
  import { Plugin, PluginKey, Selection } from 'prosemirror-state';
22
22
  import { Step, StepResult } from 'prosemirror-transform';
@@ -31,23 +31,8 @@ export const DEFAULT_REVIEW_STRINGS = {
31
31
  reviewAcceptTitle: 'Accept',
32
32
  reviewDismissTitle: 'Dismiss',
33
33
  reviewProposal: 'Proposed change',
34
- reviewGone: 'Text removed here',
35
34
  reviewOutdated: 'Edited since'
36
35
  };
37
- /** Each stretch through `mapping`. Words typed at a stretch's edge stay outside it, and one inside
38
- * it grows it; `fresh` stretches were just written, so they reach over what the mapping wrote.
39
- * `undefined` where nothing the proposal wrote or took out is left. */
40
- function mapWritten(written, mapping, fresh = false) {
41
- const out = [];
42
- for (const w of written) {
43
- const a = mapping.mapResult(w.from, fresh ? -1 : 1);
44
- const b = mapping.mapResult(w.to, fresh ? 1 : -1);
45
- if (w.from === w.to ? a.deleted : b.pos <= a.pos)
46
- continue;
47
- out.push({ ...w, from: a.pos, to: Math.max(a.pos, b.pos) });
48
- }
49
- return out.length ? out : undefined;
50
- }
51
36
  const reviewKey = new PluginKey('quill-review');
52
37
  /** Tell the review layer the store took blocks under new ids, each `[was, now]`. */
53
38
  export function renameBlocks(tr, renamed) {
@@ -69,76 +54,47 @@ function nowOf(renamed, id) {
69
54
  class ReviewAnswer extends Step {
70
55
  id;
71
56
  to;
72
- written;
73
- /** `written` stands in the document as it is after the steps that write it: an accept's
74
- * stretches, and on an undo of an accept the stretches it puts back, which an undo of that
75
- * undo writes over again. */
76
- constructor(id, to, written = []) {
57
+ constructor(id, to) {
77
58
  super();
78
59
  this.id = id;
79
60
  this.to = to;
80
- this.written = written;
81
61
  }
82
62
  apply(doc) {
83
63
  return StepResult.ok(doc);
84
64
  }
85
65
  invert() {
86
- return new ReviewAnswer(this.id, this.to ? undefined : 'accept', this.written);
66
+ return new ReviewAnswer(this.id, this.to ? undefined : 'accept');
87
67
  }
88
- map(mapping) {
89
- return new ReviewAnswer(this.id, this.to, mapWritten(this.written, mapping) ?? []);
68
+ map() {
69
+ return this;
90
70
  }
91
71
  toJSON() {
92
- return {
93
- stepType: 'quillReviewAnswer',
94
- id: this.id,
95
- to: this.to ?? null,
96
- written: this.written.map((w) => ({ ...w, before: w.before.toJSON() }))
97
- };
72
+ return { stepType: 'quillReviewAnswer', id: this.id, to: this.to ?? null };
98
73
  }
99
- static fromJSON(schema, json) {
100
- return new ReviewAnswer(json.id, json.to ?? undefined, (json.written ?? []).map((w) => ({ ...w, before: Slice.fromJSON(schema, w.before) })));
74
+ static fromJSON(_schema, json) {
75
+ return new ReviewAnswer(json.id, json.to ?? undefined);
101
76
  }
102
77
  }
103
78
  Step.jsonID('quillReviewAnswer', ReviewAnswer);
104
- function answering(state, id, to, written) {
105
- let next = state;
106
- if (state.written.has(id) || written) {
107
- const all = new Map(state.written);
108
- if (written)
109
- all.set(id, written);
110
- else
111
- all.delete(id);
112
- next = { ...next, written: all };
113
- }
79
+ function answering(state, id, to) {
114
80
  if (state.answered.get(id) === to)
115
- return next;
81
+ return state;
116
82
  const answered = new Map(state.answered);
117
83
  if (to)
118
84
  answered.set(id, to);
119
85
  else
120
86
  answered.delete(id);
121
- return { ...next, answered };
87
+ return { ...state, answered };
122
88
  }
123
89
  function applyReview(tr, state) {
124
90
  let next = state.replayed.length ? { ...state, replayed: [] } : state;
125
91
  if (tr.docChanged && !tr.getMeta(remoteKey))
126
92
  next = { ...next, edits: next.edits + 1 };
127
- if (tr.docChanged && next.written.size) {
128
- const all = new Map();
129
- for (const [id, written] of next.written) {
130
- const moved = mapWritten(written, tr.mapping);
131
- if (moved)
132
- all.set(id, moved);
133
- }
134
- next = { ...next, written: all };
135
- }
136
93
  const history = isHistoryTransaction(tr);
137
- tr.steps.forEach((step, i) => {
94
+ tr.steps.forEach((step) => {
138
95
  if (!(step instanceof ReviewAnswer))
139
96
  return;
140
- const written = step.to && mapWritten(step.written, tr.mapping.slice(i + 1), true);
141
- next = answering(next, step.id, step.to, written || undefined);
97
+ next = answering(next, step.id, step.to);
142
98
  // Reported whether or not the answer is still held: the host's list may have dropped it.
143
99
  if (history)
144
100
  next = { ...next, replayed: [...next.replayed, { id: step.id, to: step.to }] };
@@ -221,14 +177,10 @@ function tail(doc, from) {
221
177
  });
222
178
  return out;
223
179
  }
224
- /**
225
- * The edit that takes a proposal: its pieces, last first, so each still stands where it was
226
- * read, and the stretches it wrote. `undefined` where the pieces no longer make a document the
227
- * schema holds.
228
- */
229
- function taking(state, plan, anchors) {
180
+ /** The edit that takes a proposal: its pieces, last first, so each still stands where it was
181
+ * read. `undefined` where the pieces no longer make a document the schema holds. */
182
+ function taking(state, plan) {
230
183
  const tr = state.tr;
231
- const made = [];
232
184
  try {
233
185
  for (const piece of [...plan].sort((a, b) => b.from - a.from)) {
234
186
  let { from, to } = piece;
@@ -240,12 +192,10 @@ function taking(state, plan, anchors) {
240
192
  }
241
193
  // A leaf holds a block at the least: its last one is emptied where it stands.
242
194
  if (from === 0 && to === tr.doc.content.size) {
243
- made.push({ from, to, before: tr.doc.slice(from, to), step: tr.steps.length });
244
195
  tr.replaceWith(from, to, tr.doc.type.createAndFill().content);
245
196
  continue;
246
197
  }
247
198
  }
248
- made.push({ from, to, before: tr.doc.slice(from, to), step: tr.steps.length });
249
199
  tr.replaceWith(from, to, arriving(tr.doc, piece.content));
250
200
  }
251
201
  tr.doc.check();
@@ -253,34 +203,7 @@ function taking(state, plan, anchors) {
253
203
  catch {
254
204
  return undefined;
255
205
  }
256
- if (!tr.docChanged)
257
- return undefined;
258
- const written = made.map(({ from, to, before, step }) => {
259
- const after = tr.mapping.slice(step);
260
- const swallowed = anchors
261
- .filter((a) => a.end > a.start && from <= a.start && a.end <= to)
262
- .map((a) => ({ id: a.id, start: a.start - from, end: a.end - from }));
263
- return { from: after.map(from, -1), to: after.map(to, 1), before, anchors: swallowed };
264
- });
265
- return { tr: closeHistory(tr), written };
266
- }
267
- /** The reader's edit that takes back what proposal `id` wrote, wherever the stretches have
268
- * moved to and whatever was typed inside them, so the proposal is open again. */
269
- function putBack(state, id, written, channel) {
270
- const tr = state.tr;
271
- const made = [];
272
- for (const w of [...written].sort((a, b) => b.from - a.from)) {
273
- made.push({ w, step: tr.steps.length });
274
- tr.replace(w.from, w.to, w.before);
275
- }
276
- const back = made.map(({ w, step }) => {
277
- const after = tr.mapping.slice(step);
278
- return { ...w, from: after.map(w.from, -1), to: after.map(w.to, 1) };
279
- });
280
- const anchors = back.flatMap((w) => (w.anchors ?? []).map((a) => ({ id: a.id, start: w.from + a.start, end: w.from + a.end })));
281
- if (anchors.length)
282
- channel.restore?.(tr, anchors);
283
- return closeHistory(tr.step(new ReviewAnswer(id, undefined, back)));
206
+ return tr.docChanged ? closeHistory(tr) : undefined;
284
207
  }
285
208
  /** The marks on each offset of a textblock's content. */
286
209
  function marksOf(block) {
@@ -518,7 +441,7 @@ function readOf(ids, before, channel) {
518
441
  return out;
519
442
  }
520
443
  function draw(state, channel, act, bases) {
521
- const { answered, written, renamed } = reviewKey.getState(state);
444
+ const { answered, renamed } = reviewKey.getState(state);
522
445
  const now = (id) => nowOf(renamed, id);
523
446
  const listed = channel.items();
524
447
  // A base outlives its item's answer and its leaving the list while a block it covered
@@ -534,17 +457,14 @@ function draw(state, channel, act, bases) {
534
457
  if (!ids.has(id) && !stands(base.place))
535
458
  bases.delete(id);
536
459
  }
537
- const items = answered.size
538
- ? listed.filter((item) => !answered.has(item.id) || written.has(item.id))
539
- : listed;
460
+ const items = answered.size ? listed.filter((item) => !answered.has(item.id)) : listed;
540
461
  const plans = new Map();
541
462
  const undrawn = [];
542
463
  const outdated = [];
543
- const accepted = [];
544
464
  const decos = [];
545
465
  const lighting = new Set();
546
466
  if (!items.length)
547
- return { decos, lighting, spans: [], plans, outdated, undrawn, accepted };
467
+ return { decos, lighting, spans: [], plans, outdated, undrawn };
548
468
  const { doc } = state;
549
469
  const strings = channel.strings();
550
470
  const serializer = DOMSerializer.fromSchema(state.schema);
@@ -558,56 +478,7 @@ function draw(state, channel, act, bases) {
558
478
  * a paragraph's end, or `-1` for the head of the leaf. */
559
479
  const taken = new Set();
560
480
  const adding = new Set();
561
- /** A taken proposal's mark over `[from, to)`, or its wedge where text was only taken out. */
562
- const changed = (id, from, to) => {
563
- if (to > from) {
564
- lights(id, (on) => Decoration.inline(from, to, {
565
- class: on ? 'qm-review-changed qm-review-lit' : 'qm-review-changed',
566
- 'data-qm-review': id
567
- }));
568
- return;
569
- }
570
- lights(id, (on) => Decoration.widget(from, () => {
571
- const el = document.createElement('span');
572
- el.className = on ? 'qm-review-gone qm-review-lit' : 'qm-review-gone';
573
- el.contentEditable = 'false';
574
- el.setAttribute('data-qm-review', id);
575
- el.setAttribute('role', 'img');
576
- el.setAttribute('aria-label', strings.reviewGone);
577
- return el;
578
- }, { side: -1, key: `gone:${id}:${on}` }));
579
- };
580
481
  for (const item of items) {
581
- // A proposal taken here is drawn as the change it made, while the host lists it.
582
- const wrote = written.get(item.id);
583
- if (wrote) {
584
- for (const w of wrote) {
585
- // A wedge stands in a line: one where whole blocks went stands at the end of the
586
- // line before, or the start of the one after.
587
- const $at = doc.resolve(w.from);
588
- if (w.to > w.from || $at.parent.inlineContent)
589
- changed(item.id, w.from, w.to);
590
- else {
591
- const at = Selection.findFrom($at, -1, true) ?? Selection.findFrom($at, 1, true);
592
- if (at)
593
- changed(item.id, at.from, at.from);
594
- }
595
- }
596
- spans.push({
597
- id: item.id,
598
- proposed: false,
599
- from: Math.min(...wrote.map((w) => w.from)),
600
- to: Math.max(...wrote.map((w) => w.to))
601
- });
602
- accepted.push({
603
- id: item.id,
604
- before: wrote
605
- .map((w) => w.before.content.textBetween(0, w.before.content.size, '\n'))
606
- .filter(Boolean)
607
- .join('\n')
608
- });
609
- continue;
610
- }
611
482
  const name = { 'data-qm-review': item.id };
612
483
  leaves ??= leavesOf(doc);
613
484
  const at = placeOf(item, leaves, now);
@@ -784,13 +655,12 @@ function draw(state, channel, act, bases) {
784
655
  // What a proposal only adds to has the caret anywhere in the block it adds from.
785
656
  spans.push({
786
657
  id: item.id,
787
- proposed: true,
788
658
  adds: !covered.length,
789
659
  from: reach(covered[0] ?? last)[0],
790
660
  to: reach(last)[1]
791
661
  });
792
662
  }
793
- return { decos, lighting, spans, plans, outdated, undrawn, accepted };
663
+ return { decos, lighting, spans, plans, outdated, undrawn };
794
664
  }
795
665
  /** Whether a block's last leaf is a textblock, so its last line can carry a run. */
796
666
  function endsInLine(node) {
@@ -800,13 +670,12 @@ function endsInLine(node) {
800
670
  return at.isTextblock;
801
671
  }
802
672
  /** The item the caret is in: the one it was put into by its id while it holds the caret, else
803
- * the one that holds it closest, so a change inside a paragraph a proposal covers is the change
804
- * while the caret is in its words, and of a proposal that rewrites a paragraph and one that adds
805
- * after it, the one that rewrites. `proposed` asks for a proposal alone. */
806
- function spanAt(spans, pos, entered, proposed = false) {
673
+ * the one that holds it closest, so of a proposal that rewrites a paragraph and one that adds
674
+ * after it, the one that rewrites. */
675
+ function spanAt(spans, pos, entered) {
807
676
  let best;
808
677
  for (const s of spans) {
809
- if (s.from > pos || pos > s.to || (proposed && !s.proposed))
678
+ if (s.from > pos || pos > s.to)
810
679
  continue;
811
680
  if (s.id === entered)
812
681
  return s;
@@ -818,20 +687,15 @@ function spanAt(spans, pos, entered, proposed = false) {
818
687
  return best;
819
688
  }
820
689
  /**
821
- * The leaf's review layer. The decorations are a function of the document, the anchors and the
822
- * channel's items, kept until one of them moves. The caret's report holds off while the reader
690
+ * The leaf's review layer. The decorations are a function of the document and the channel's
691
+ * items, kept until one of them moves. The caret's report holds off while the reader
823
692
  * types inside an item: an item is news on arriving in it, and noise under every keystroke.
824
693
  */
825
694
  export function reviewLayer(channel) {
826
695
  let memo;
827
696
  /** The decorations of what is drawn, with the lit item they were made for. */
828
697
  let shown;
829
- const NOTHING = JSON.stringify({
830
- ids: [],
831
- outdated: [],
832
- undrawn: [],
833
- accepted: []
834
- });
698
+ const NOTHING = JSON.stringify({ ids: [], outdated: [], undrawn: [] });
835
699
  let reported = NOTHING;
836
700
  let host;
837
701
  const bases = new Map();
@@ -842,20 +706,11 @@ export function reviewLayer(channel) {
842
706
  const view = host;
843
707
  if (!view || !drawn(view.state).spans.some((span) => span.id === id))
844
708
  return false;
845
- const wrote = reviewKey.getState(view.state).written.get(id);
846
- if (wrote) {
847
- if (action === 'accept' || action === 'dismiss')
848
- return false;
849
- view.dispatch(putBack(view.state, id, wrote, channel));
850
- channel.act(id, 'reopen', how.chord);
851
- return true;
852
- }
853
709
  if (action === 'accept') {
854
710
  const plan = drawn(view.state).plans.get(id);
855
- const took = plan && taking(view.state, plan, channel.anchors(view.state));
856
- if (!took || !plan)
711
+ const tr = plan && taking(view.state, plan);
712
+ if (!tr || !plan)
857
713
  return false;
858
- const { tr } = took;
859
714
  const away = !how.quiet && !view.hasFocus();
860
715
  if (away) {
861
716
  const end = tr.mapping.map(Math.max(...plan.map((piece) => piece.to)), 1);
@@ -863,7 +718,7 @@ export function reviewLayer(channel) {
863
718
  }
864
719
  channel.writing?.(true);
865
720
  try {
866
- view.dispatch(tr.step(new ReviewAnswer(id, 'accept', took.written)));
721
+ view.dispatch(tr.step(new ReviewAnswer(id, 'accept')));
867
722
  }
868
723
  finally {
869
724
  channel.writing?.(false);
@@ -881,18 +736,16 @@ export function reviewLayer(channel) {
881
736
  };
882
737
  const drawn = (state) => {
883
738
  const review = reviewKey.getState(state);
884
- const anchors = channel.anchors(state);
885
739
  const items = channel.items();
886
740
  const strings = channel.strings();
887
741
  if (memo &&
888
742
  memo.doc === state.doc &&
889
743
  memo.review === review &&
890
- memo.anchors === anchors &&
891
744
  memo.items === items &&
892
745
  memo.strings === strings)
893
746
  return memo.drawn;
894
747
  const next = draw(state, channel, act, bases);
895
- memo = { doc: state.doc, review, anchors, items, strings, drawn: next };
748
+ memo = { doc: state.doc, review, items, strings, drawn: next };
896
749
  return next;
897
750
  };
898
751
  /** Whether the lit item moving to `lit` changes how anything here reads. */
@@ -913,8 +766,8 @@ export function reviewLayer(channel) {
913
766
  };
914
767
  /** Tell the channel what the leaf draws, where that moved. */
915
768
  const report = (state) => {
916
- const { spans, outdated, undrawn, accepted } = drawn(state);
917
- const next = { ids: spans.map((s) => s.id), outdated, undrawn, accepted };
769
+ const { spans, outdated, undrawn } = drawn(state);
770
+ const next = { ids: spans.map((s) => s.id), outdated, undrawn };
918
771
  const joined = JSON.stringify(next);
919
772
  if (joined === reported)
920
773
  return;
@@ -949,18 +802,10 @@ export function reviewLayer(channel) {
949
802
  channel.point(next, 'caret');
950
803
  };
951
804
  const answer = (action) => (state) => {
952
- const span = spanAt(drawn(state).spans, state.selection.head, reviewKey.getState(state)?.entered, action === 'accept');
805
+ const span = spanAt(drawn(state).spans, state.selection.head, reviewKey.getState(state)?.entered);
953
806
  if (!span)
954
807
  return false;
955
- act(span.id, span.proposed ? action : 'reopen', { chord: true });
956
- return true;
957
- };
958
- /** Escape lowers the card over the item the caret is in, before it is anything else's. */
959
- const lower = (state) => {
960
- const id = channel.shown();
961
- if (id === undefined || !drawn(state).spans.some((span) => span.id === id))
962
- return false;
963
- channel.dismiss();
808
+ act(span.id, action, { chord: true });
964
809
  return true;
965
810
  };
966
811
  const plugin = new Plugin({
@@ -969,7 +814,6 @@ export function reviewLayer(channel) {
969
814
  init: () => ({
970
815
  edits: 0,
971
816
  answered: new Map(),
972
- written: new Map(),
973
817
  entered: undefined,
974
818
  replayed: [],
975
819
  renamed: new Map()
@@ -980,8 +824,7 @@ export function reviewLayer(channel) {
980
824
  decorations,
981
825
  handleKeyDown: keydownHandler({
982
826
  [REVIEW_KEYS.accept]: answer('accept'),
983
- [REVIEW_KEYS.dismiss]: answer('dismiss'),
984
- Escape: lower
827
+ [REVIEW_KEYS.dismiss]: answer('dismiss')
985
828
  }),
986
829
  handleDOMEvents: {
987
830
  mouseover: (_view, e) => {
@@ -1024,7 +867,7 @@ export function reviewLayer(channel) {
1024
867
  if (caret !== undefined)
1025
868
  channel.point(undefined, 'caret');
1026
869
  if (reported !== NOTHING)
1027
- channel.drew({ ids: [], outdated: [], undrawn: [], accepted: [] });
870
+ channel.drew({ ids: [], outdated: [], undrawn: [] });
1028
871
  host = undefined;
1029
872
  }
1030
873
  };
@@ -215,13 +215,11 @@
215
215
  ratio `default` steps the ink. What is drawn over it in the card's colour, the
216
216
  thumb and the check, holds 3:1 at both poles, at 3.3:1 and 4.2:1. */
217
217
  --_qm-accent-default: color-mix(in oklab, var(--_qm-accent), var(--_qm-bg) 20%);
218
- /* The review hue, three ways. `tint` is held under the words a proposal would add and
219
- over a field someone else set, at the strength the accent's own tint is held under
220
- body text plus what a state resting on a well has to clear. `lit` is that tint under
221
- attention: the pointer over the item, the caret in it, a host revealing it. `line` is
222
- the stroke: the line under changed words, the line through the words a proposal
223
- would take, and a changed field's edge, held back so it sits under a link's
224
- underline rather than beside it. */
218
+ /* The review hue, three ways. `tint` is held under the words a proposal would add, at
219
+ the strength the accent's own tint is held under body text plus what a state resting
220
+ on a well has to clear. `lit` is that tint under attention: the pointer over the
221
+ item, the caret in it, a host revealing it. `line` is the stroke through the words a
222
+ proposal would take, held back so it reads under the ink rather than as it. */
225
223
  --_qm-review-tint: color-mix(in oklab, var(--_qm-review) 20%, transparent);
226
224
  --_qm-review-lit: color-mix(in oklab, var(--_qm-review) 34%, transparent);
227
225
  --_qm-review-line: color-mix(in oklab, var(--_qm-review) 60%, transparent);
@@ -318,22 +318,16 @@
318
318
  * rather than counted twice.
319
319
  */
320
320
  // ── Review: this field's own items (`review.svelte.ts`) ──────────────────────
321
- // A change rests as a line on the control's edge and a proposal as a row under it. The
322
- // pointer over the control and the focus in it are the field's two ways of being attended
323
- // to, as the pointer and the caret are a mark's.
321
+ // A proposal rests as a row under the control. The focus in the control attends to it, as
322
+ // the caret in a leaf's words attends to theirs.
324
323
  const reviewing = review();
325
324
  const reviewed = $derived(reviewing.at(leafKey));
326
- const changed = $derived(reviewed.changed);
327
325
  const proposed = $derived(reviewed.proposed);
328
326
  /** The items naming a place inside this field: a record's and a list's own controls draw
329
327
  * them where they are, any other's under this one. */
330
328
  const nestedReview = $derived(reviewed.nested);
331
- const lit = $derived(changed !== undefined && reviewing.lit === changed.id);
332
- /** The item the focus in the field attends to: the change, whose card it raises, else the
333
- * proposal. */
334
- const attended = $derived(changed ?? proposed);
335
- /** The chords, with the focus anywhere in the field: a proposal's answers, else an accepted
336
- * one taken back. A prose leaf's own items answer first, in the leaf. */
329
+ /** The chords, with the focus anywhere in the field: the proposal's answers. A prose leaf's
330
+ * own items answer first, in the leaf. */
337
331
  const reviewKeys = keydownHandler({
338
332
  [REVIEW_KEYS.accept]: () => {
339
333
  if (!proposed) return false;
@@ -341,14 +335,13 @@
341
335
  return true;
342
336
  },
343
337
  [REVIEW_KEYS.dismiss]: () => {
344
- const item = proposed ?? changed;
345
- if (!item) return false;
346
- reviewing.act(item.id, proposed ? 'dismiss' : 'reopen', true);
338
+ if (!proposed) return false;
339
+ reviewing.act(proposed.id, 'dismiss', true);
347
340
  return true;
348
341
  }
349
342
  });
350
343
  function onReviewKey(e: KeyboardEvent): void {
351
- if (e.defaultPrevented || (!changed && !proposed)) return;
344
+ if (e.defaultPrevented || !proposed) return;
352
345
  // The bindings read no view: this is `prosemirror-keymap`'s chord matcher alone.
353
346
  if (reviewKeys({} as never, e)) e.preventDefault();
354
347
  }
@@ -385,17 +378,13 @@
385
378
  level and measures the same. -->
386
379
  <div class="qm-field-stack">
387
380
  <div
388
- class={['qm-field-control qm-wash', { 'qm-review-set': changed, 'qm-review-lit': lit }]}
389
- data-qm-review={changed?.id}
381
+ class="qm-field-control qm-wash"
390
382
  {@attach registerControl}
391
383
  onfocusin={(e) => {
392
384
  reportFocus?.(e);
393
- if (attended) reviewing.point(attended.id, 'caret', leafKey);
385
+ if (proposed) reviewing.point(proposed.id, 'caret', leafKey);
394
386
  }}
395
- onfocusout={() => attended && reviewing.point(undefined, 'caret', leafKey)}
396
- oninput={() => changed && reviewing.point(undefined, 'caret')}
397
- onpointerenter={() => changed && reviewing.point(changed.id, 'pointer')}
398
- onpointerleave={() => changed && reviewing.point(undefined, 'pointer')}
387
+ onfocusout={() => proposed && reviewing.point(undefined, 'caret', leafKey)}
399
388
  >
400
389
  {#if field.control === 'prose'}
401
390
  <ProseField
@@ -614,21 +603,4 @@
614
603
  .qm-field-control {
615
604
  border-radius: var(--_qm-radius-inner);
616
605
  }
617
- /* A value someone else set is underlined as a changed word is: the same stroke along the
618
- control's foot, and under attention the tint a lit word takes. A plane over the
619
- control, as the wash is, so it reads the same over a well, a switch and a subform, and
620
- lifted over the control's own positioned box. */
621
- .qm-field-control.qm-review-set::before {
622
- content: '';
623
- position: absolute;
624
- inset: 0;
625
- border-radius: inherit;
626
- box-shadow: inset 0 calc(-1 * var(--_qm-vertical-width)) 0 var(--_qm-review-line);
627
- z-index: 1;
628
- pointer-events: none;
629
- transition: background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
630
- }
631
- .qm-field-control.qm-review-set.qm-review-lit::before {
632
- background: var(--_qm-review-tint);
633
- }
634
606
  </style>
@@ -257,13 +257,13 @@
257
257
 
258
258
  It takes no fill either: the surface itself opens on hover.
259
259
 
260
- At rest it is absent, a card describing every field otherwise standing a mark
261
- beside each label before anything is touched. It arrives with the
262
- scope that owns its row (the field, the property, the array or matrix, the table
263
- its column heads, the section a lone field is named by), each reached by child
264
- steps so a nested field's marker stays at rest under its container's hover, and
265
- while its surface is open. The keyboard's `Mod-/` and the parked description do not
266
- depend on the lift. */
260
+ At rest it stands at the rung a live glyph control rests at, so a reader sees that
261
+ guidance exists before touching anything, and it comes up whole with the scope
262
+ that owns its row (the field, the property, the array or matrix, the table its
263
+ column heads, the section a lone field is named by), each reached by child steps so
264
+ a nested field's marker stays at rest under its container's hover, and while its
265
+ surface is open. The keyboard's `Mod-/` and the parked description do not depend on
266
+ the lift. */
267
267
  .qm-field-hint {
268
268
  /* The marker recedes to the label rung; the surface carries the text. */
269
269
  color: var(--_qm-ink-label);
@@ -271,7 +271,7 @@
271
271
  cursor: help;
272
272
  padding: 0;
273
273
  background: none;
274
- opacity: 0;
274
+ opacity: var(--_qm-opacity-rest);
275
275
  transition: opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
276
276
  }
277
277
  :global(:is(.qm-field, .qm-object-prop):is(:hover, :focus-within) > .qm-field-label-row)
@@ -286,13 +286,6 @@
286
286
  .qm-field-hint[aria-expanded='true'] {
287
287
  opacity: 1;
288
288
  }
289
- /* Without a hover there is no lift to wait for, and a tap is the glyph's only door, so
290
- it rests drawn at the rung a live glyph control rests at. */
291
- @media (hover: none) {
292
- .qm-field-hint {
293
- opacity: var(--_qm-opacity-rest);
294
- }
295
- }
296
289
  /* The lift, the translucency, the blur and the scale-in come from
297
290
  `.qm-popover-surface` (controls.css). This surface's own is a measure: guidance
298
291
  is prose, and prose past ~40 characters a line stops being scannable; plus the
@@ -153,8 +153,6 @@
153
153
  slash = next;
154
154
  },
155
155
  reviewStrings: () => t.strings,
156
- reviewShown: () => reviewing.shown?.item.id,
157
- onReviewDismiss: () => reviewing.dismiss(),
158
156
  onReview: (id, action, chord) => reviewing.heard(id, action, leafKey, chord),
159
157
  onReviewPoint: (id, via) => reviewing.point(id, via, leafKey),
160
158
  onReviewWriting: (on) => reviewing.writing(on),
@@ -126,6 +126,13 @@
126
126
  calc(-1 * var(--_qm-space-half)) 0 0 var(--_qm-review-lit),
127
127
  var(--_qm-space-half) 0 0 var(--_qm-review-lit);
128
128
  }
129
+ /* Forced colours drop the tint, so the proposed words take the line prose's take
130
+ (`codec/prose.css`). */
131
+ @media (forced-colors: active) {
132
+ .qm-review-ins {
133
+ text-decoration: underline;
134
+ }
135
+ }
129
136
  .qm-review-where {
130
137
  color: var(--_qm-ink-label);
131
138
  }