@quillmark/svelte 0.32.0 → 0.34.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 (99) hide show
  1. package/README.md +73 -1
  2. package/THEMING.md +11 -10
  3. package/dist/core/codec/anchor.d.ts +12 -0
  4. package/dist/core/codec/anchor.js +39 -0
  5. package/dist/core/codec/drag-move.d.ts +11 -0
  6. package/dist/core/codec/drag-move.js +143 -0
  7. package/dist/core/codec/encode.d.ts +2 -1
  8. package/dist/core/codec/encode.js +16 -6
  9. package/dist/core/codec/field.d.ts +47 -1
  10. package/dist/core/codec/field.js +201 -37
  11. package/dist/core/codec/index.d.ts +8 -2
  12. package/dist/core/codec/index.js +9 -2
  13. package/dist/core/codec/islands.d.ts +4 -1
  14. package/dist/core/codec/islands.js +6 -0
  15. package/dist/core/codec/keymap.d.ts +3 -0
  16. package/dist/core/codec/keymap.js +13 -12
  17. package/dist/core/codec/leave.d.ts +17 -0
  18. package/dist/core/codec/leave.js +78 -0
  19. package/dist/core/codec/prose.css +217 -0
  20. package/dist/core/codec/review-diff.d.ts +12 -0
  21. package/dist/core/codec/review-diff.js +131 -0
  22. package/dist/core/codec/review.d.ts +131 -0
  23. package/dist/core/codec/review.js +1077 -0
  24. package/dist/core/codec/shortcuts.d.ts +20 -4
  25. package/dist/core/codec/shortcuts.js +27 -7
  26. package/dist/core/codec/slash.d.ts +3 -0
  27. package/dist/core/codec/slash.js +2 -1
  28. package/dist/core/codec/table-view.js +163 -25
  29. package/dist/core/codec/undo.d.ts +6 -0
  30. package/dist/core/codec/undo.js +25 -2
  31. package/dist/core/dragfollow.d.ts +18 -0
  32. package/dist/core/dragfollow.js +63 -0
  33. package/dist/core/theme.css +36 -7
  34. package/dist/preview/controller.js +16 -0
  35. package/dist/preview/strings.d.ts +4 -0
  36. package/dist/preview/strings.js +3 -1
  37. package/dist/visual/ArrayField.svelte +363 -57
  38. package/dist/visual/ArrayField.svelte.d.ts +5 -0
  39. package/dist/visual/BooleanField.svelte +60 -5
  40. package/dist/visual/BooleanField.svelte.d.ts +2 -1
  41. package/dist/visual/Card.svelte +27 -17
  42. package/dist/visual/CardControls.svelte +17 -7
  43. package/dist/visual/CardControls.svelte.d.ts +2 -0
  44. package/dist/visual/DateField.svelte +90 -39
  45. package/dist/visual/DateField.svelte.d.ts +2 -2
  46. package/dist/visual/Field.svelte +126 -6
  47. package/dist/visual/FieldHint.svelte +24 -9
  48. package/dist/visual/FieldLabel.svelte +128 -22
  49. package/dist/visual/FieldLabel.svelte.d.ts +9 -0
  50. package/dist/visual/FormatPopover.svelte +125 -20
  51. package/dist/visual/MatrixAdd.svelte +13 -6
  52. package/dist/visual/MatrixAdd.svelte.d.ts +3 -2
  53. package/dist/visual/MatrixField.svelte +36 -8
  54. package/dist/visual/NumberField.svelte +27 -6
  55. package/dist/visual/NumberField.svelte.d.ts +3 -0
  56. package/dist/visual/ObjectField.svelte +25 -1
  57. package/dist/visual/ObjectField.svelte.d.ts +6 -0
  58. package/dist/visual/ProseField.svelte +23 -0
  59. package/dist/visual/ProseField.svelte.d.ts +3 -0
  60. package/dist/visual/ProseValue.svelte +107 -17
  61. package/dist/visual/ProseValue.svelte.d.ts +18 -4
  62. package/dist/visual/ReviewPopover.svelte +179 -0
  63. package/dist/visual/ReviewPopover.svelte.d.ts +16 -0
  64. package/dist/visual/ReviewProposal.svelte +149 -0
  65. package/dist/visual/ReviewProposal.svelte.d.ts +15 -0
  66. package/dist/visual/ReviewRows.svelte +68 -0
  67. package/dist/visual/ReviewRows.svelte.d.ts +11 -0
  68. package/dist/visual/SlashMenu.svelte +13 -1
  69. package/dist/visual/SlashMenu.svelte.d.ts +2 -0
  70. package/dist/visual/VisualEditor.svelte +23 -0
  71. package/dist/visual/VisualEditor.svelte.d.ts +7 -0
  72. package/dist/visual/VisualEditorInner.svelte +671 -22
  73. package/dist/visual/VisualEditorInner.svelte.d.ts +7 -0
  74. package/dist/visual/controls.css +17 -2
  75. package/dist/visual/guidance.d.ts +12 -0
  76. package/dist/visual/guidance.js +37 -2
  77. package/dist/visual/icons/nodes.d.ts +14 -2
  78. package/dist/visual/icons/nodes.js +12 -1
  79. package/dist/visual/index.d.ts +6 -0
  80. package/dist/visual/index.js +2 -0
  81. package/dist/visual/listhistory.d.ts +36 -0
  82. package/dist/visual/listhistory.js +53 -0
  83. package/dist/visual/proposals.d.ts +40 -0
  84. package/dist/visual/proposals.js +219 -0
  85. package/dist/visual/props.d.ts +35 -0
  86. package/dist/visual/removed.d.ts +20 -0
  87. package/dist/visual/removed.js +30 -0
  88. package/dist/visual/review.d.ts +170 -0
  89. package/dist/visual/review.js +269 -0
  90. package/dist/visual/review.svelte.d.ts +106 -0
  91. package/dist/visual/review.svelte.js +356 -0
  92. package/dist/visual/rowdrag.svelte.js +44 -55
  93. package/dist/visual/strings.d.ts +48 -7
  94. package/dist/visual/strings.js +32 -7
  95. package/dist/visual/structure.d.ts +5 -0
  96. package/dist/visual/structure.js +1 -1
  97. package/dist/visual/undo.svelte.d.ts +40 -7
  98. package/dist/visual/undo.svelte.js +98 -25
  99. package/package.json +1 -1
@@ -0,0 +1,356 @@
1
+ // The editor's review state: the host's list split by where each item draws, and the one item
2
+ // under attention.
3
+ //
4
+ // Attention has three sources and one answer. The pointer over an item, the caret in one and a
5
+ // host's reveal each name an item; the lit one is the card's where a card is up, else the
6
+ // revealed, the caret's, the pointer's, in that order. A card is the before-and-undo surface of an
7
+ // accepted proposal: it rises at once for a reveal, and after a beat for the pointer and the caret,
8
+ // so neither raises one on its way across a paragraph, and it waits a beat on the pointer's
9
+ // leaving so the pointer can travel into it.
10
+ //
11
+ // A dismissed item is drawn no more, from the answer and not from the host's next list: the
12
+ // reader's press shows at once however long the host takes to hand over a list without it.
13
+ import { getContext, setContext } from 'svelte';
14
+ import { SvelteMap } from 'svelte/reactivity';
15
+ import { byBlocks, locate, isChange, onField, sameValue } from './review.js';
16
+ /** How long the pointer or the caret rests on a change before its card rises, in ms. */
17
+ export const HOVER_MS = 350;
18
+ /** How long a card outlasts the pointer's leaving, in ms: the trip from the mark into the card. */
19
+ export const LEAVE_MS = 200;
20
+ /** How long a revealed item with no card stays lit, in ms. */
21
+ export const REVEAL_MS = 2400;
22
+ export function createReview(source) {
23
+ /** The ids answered, each until a list arrives without it. */
24
+ const answered = new Set();
25
+ /** The field proposals accepted here, drawn while the field still holds what was written. */
26
+ const took = new Set();
27
+ let answers = $state(0);
28
+ const items = $derived.by(() => {
29
+ const listed = source.items() ?? [];
30
+ if (!answers)
31
+ return listed;
32
+ const ids = new Set(listed.map((item) => item.id));
33
+ for (const id of answered)
34
+ if (!ids.has(id))
35
+ answered.delete(id);
36
+ for (const id of took)
37
+ if (!ids.has(id))
38
+ took.delete(id);
39
+ const taken = source.taken?.();
40
+ const gone = (id) => answered.has(id) || (took.has(id) && !taken?.has(id));
41
+ return answered.size || took.size ? listed.filter((item) => !gone(item.id)) : listed;
42
+ });
43
+ const drawn = new SvelteMap();
44
+ /** Each accepted proposal still listed, as the change the card and the field draw. */
45
+ const accepted = $derived.by(() => {
46
+ const out = new Map();
47
+ const listed = new Map((source.items() ?? []).map((item) => [item.id, item]));
48
+ for (const [id, change] of source.taken?.() ?? [])
49
+ if (listed.has(id))
50
+ out.set(id, change);
51
+ for (const report of drawn.values())
52
+ for (const { id, before } of report.accepted ?? []) {
53
+ const item = listed.get(id);
54
+ if (item && byBlocks(item))
55
+ out.set(id, { id, state: 'changed', before });
56
+ }
57
+ return out;
58
+ });
59
+ const byId = $derived(new Map(items.map((item) => [item.id, accepted.get(item.id) ?? item])));
60
+ /** The items each prose leaf draws, by leaf key. */
61
+ const text = $derived.by(() => {
62
+ const own = new Map();
63
+ for (const item of items) {
64
+ if (!byBlocks(item))
65
+ continue;
66
+ const key = source.leafFor(item.field);
67
+ if (key === undefined)
68
+ continue;
69
+ let list = own.get(key);
70
+ if (!list)
71
+ own.set(key, (list = []));
72
+ list.push(item);
73
+ }
74
+ return own;
75
+ });
76
+ const placed = $derived.by(() => {
77
+ const out = new Map();
78
+ const undrawn = [];
79
+ /** The nested proposals whose `before` the field no longer holds. */
80
+ const moved = new Set();
81
+ const claims = new Map();
82
+ for (const listed of items) {
83
+ if (byBlocks(listed)) {
84
+ if (source.leafFor(listed.field) === undefined)
85
+ undrawn.push({ id: listed.id, reason: 'field' });
86
+ continue;
87
+ }
88
+ const item = accepted.get(listed.id) ?? listed;
89
+ if (!onField(item))
90
+ continue;
91
+ if (!source.exact(item.field)) {
92
+ const deep = source.nested(item.field);
93
+ if (!deep) {
94
+ undrawn.push({ id: item.id, reason: 'field' });
95
+ continue;
96
+ }
97
+ const claimed = claims.get(deep.key) ?? new Set();
98
+ claims.set(deep.key, claimed);
99
+ const held = out.get(deep.key) ?? {};
100
+ const { steps, found } = locate(deep.value, deep.steps, item, claimed);
101
+ const same = (held.nested ?? []).some((e) => isChange(e.item) === isChange(item) && sameValue(e.steps, steps));
102
+ if (same) {
103
+ undrawn.push({ id: item.id, reason: 'taken' });
104
+ continue;
105
+ }
106
+ if (!found && !isChange(item))
107
+ moved.add(item.id);
108
+ held.nested = [...(held.nested ?? []), { steps, item }];
109
+ out.set(deep.key, held);
110
+ continue;
111
+ }
112
+ const key = source.keyFor(item.field);
113
+ if (key === undefined) {
114
+ undrawn.push({ id: item.id, reason: 'field' });
115
+ continue;
116
+ }
117
+ const held = out.get(key) ?? {};
118
+ if ((isChange(item) ? held.changed : held.proposed) !== undefined) {
119
+ undrawn.push({ id: item.id, reason: 'taken' });
120
+ continue;
121
+ }
122
+ if (isChange(item))
123
+ held.changed = item;
124
+ else
125
+ held.proposed = item;
126
+ out.set(key, held);
127
+ }
128
+ return { fields: out, undrawn, moved };
129
+ });
130
+ const fields = $derived(placed.fields);
131
+ // A proposal made from a value the field no longer holds would write over the reader's.
132
+ const outdated = $derived.by(() => {
133
+ const out = new Set(placed.moved);
134
+ for (const { proposed } of fields.values())
135
+ if (proposed &&
136
+ 'before' in proposed &&
137
+ !sameValue(source.valueAt(proposed.field), proposed.before))
138
+ out.add(proposed.id);
139
+ return out;
140
+ });
141
+ let pointer = $state();
142
+ let caret = $state();
143
+ let caretFrom;
144
+ let revealed = $state();
145
+ let card = $state();
146
+ let held = false;
147
+ let timer;
148
+ /** The caret's rest on a change, its own so the pointer's passing does not restart it. */
149
+ let rest;
150
+ let fade;
151
+ const wait = (ms, then) => {
152
+ clearTimeout(timer);
153
+ timer = setTimeout(then, ms);
154
+ };
155
+ const changed = (id) => id !== undefined && !!byId.get(id) && isChange(byId.get(id));
156
+ const shown = $derived.by(() => {
157
+ const item = card && byId.get(card.id);
158
+ return item && isChange(item) && card ? { item, via: card.via } : undefined;
159
+ });
160
+ const lit = $derived([shown?.item.id, revealed, caret, pointer].find((id) => id !== undefined && byId.has(id)));
161
+ const answering = (id, action, chord) => {
162
+ if (action === 'reopen') {
163
+ answered.delete(id);
164
+ took.delete(id);
165
+ }
166
+ else {
167
+ if (card?.id === id)
168
+ card = undefined;
169
+ // An accepted proposal stays, drawn as its change, while the list holds it.
170
+ if (action !== 'accept')
171
+ answered.add(id);
172
+ else if (byId.get(id) && onField(byId.get(id)))
173
+ took.add(id);
174
+ }
175
+ answers++;
176
+ if (chord)
177
+ source.chorded?.(id);
178
+ };
179
+ const self = {
180
+ get items() {
181
+ return items;
182
+ },
183
+ get accepted() {
184
+ return accepted;
185
+ },
186
+ textAt: (key) => text.get(key) ?? NO_ITEMS,
187
+ get reports() {
188
+ return drawn;
189
+ },
190
+ get fieldUndrawn() {
191
+ return placed.undrawn;
192
+ },
193
+ get fieldOutdated() {
194
+ return outdated;
195
+ },
196
+ get lit() {
197
+ return lit;
198
+ },
199
+ get shown() {
200
+ return shown;
201
+ },
202
+ at: (key) => fields.get(key) ?? {},
203
+ marks: (key) => fields.has(key) || !!drawn.get(key)?.ids.length,
204
+ keyOf(id) {
205
+ const item = byId.get(id);
206
+ if (!item)
207
+ return undefined;
208
+ if (byBlocks(item)) {
209
+ const key = source.leafFor(item.field);
210
+ return key !== undefined && drawn.get(key)?.ids.includes(id) ? key : undefined;
211
+ }
212
+ if ('field' in item)
213
+ return source.keyFor(item.field);
214
+ for (const [key, report] of drawn)
215
+ if (report.ids.includes(id))
216
+ return key;
217
+ return undefined;
218
+ },
219
+ drew(key, report) {
220
+ if (report.ids.length || report.undrawn.length)
221
+ drawn.set(key, report);
222
+ else
223
+ drawn.delete(key);
224
+ },
225
+ point(id, via, from) {
226
+ if (via === 'caret') {
227
+ if (id === undefined && from !== undefined && caretFrom !== from)
228
+ return;
229
+ caretFrom = from;
230
+ caret = id;
231
+ clearTimeout(rest);
232
+ if (changed(id)) {
233
+ // A card already up for the item is the caret's from here: it stays while
234
+ // the caret does. The caret's card takes the pointer's place.
235
+ const raise = () => {
236
+ clearTimeout(timer);
237
+ card = { id, via };
238
+ };
239
+ if (card?.id === id)
240
+ raise();
241
+ else
242
+ rest = setTimeout(() => {
243
+ if (caret === id)
244
+ raise();
245
+ }, HOVER_MS);
246
+ }
247
+ else if (card?.via === 'caret' || (id !== undefined && card))
248
+ card = undefined;
249
+ if (id !== undefined)
250
+ revealed = undefined;
251
+ return;
252
+ }
253
+ pointer = id;
254
+ if (changed(id)) {
255
+ if (card?.id === id)
256
+ return clearTimeout(timer);
257
+ if (card && card.via !== 'pointer')
258
+ return;
259
+ if (card)
260
+ card = { id, via };
261
+ else
262
+ wait(HOVER_MS, () => {
263
+ if (pointer === id && (!card || card.via === 'pointer'))
264
+ card = { id, via };
265
+ });
266
+ }
267
+ else if (card?.via === 'pointer' && !held)
268
+ wait(LEAVE_MS, () => {
269
+ if (card?.via === 'pointer' && card.id !== pointer && !held)
270
+ card = undefined;
271
+ });
272
+ else
273
+ clearTimeout(timer);
274
+ },
275
+ act(id, action, chord) {
276
+ if (accepted.has(id) && action === 'reopen')
277
+ return source.putBack?.(id) ?? false;
278
+ const item = byId.get(id);
279
+ if (!item || !source.answer(id, item, action))
280
+ return false;
281
+ answering(id, action, chord);
282
+ return true;
283
+ },
284
+ writing: (on) => source.writing?.(on),
285
+ heard(id, action, key, chord) {
286
+ if (source.answer(id, byId.get(id), action, key))
287
+ answering(id, action, chord);
288
+ },
289
+ hold() {
290
+ held = true;
291
+ clearTimeout(timer);
292
+ },
293
+ release() {
294
+ held = false;
295
+ if (card?.via === 'pointer' && card.id !== pointer)
296
+ wait(LEAVE_MS, () => {
297
+ if (!held && card?.via === 'pointer' && card.id !== pointer)
298
+ card = undefined;
299
+ });
300
+ },
301
+ dismiss() {
302
+ clearTimeout(timer);
303
+ clearTimeout(rest);
304
+ card = undefined;
305
+ },
306
+ reveal(id) {
307
+ clearTimeout(timer);
308
+ clearTimeout(rest);
309
+ clearTimeout(fade);
310
+ card = changed(id) ? { id, via: 'reveal' } : undefined;
311
+ revealed = id;
312
+ fade = setTimeout(() => {
313
+ if (revealed === id)
314
+ revealed = undefined;
315
+ }, REVEAL_MS);
316
+ },
317
+ dispose() {
318
+ clearTimeout(timer);
319
+ clearTimeout(rest);
320
+ clearTimeout(fade);
321
+ }
322
+ };
323
+ return self;
324
+ }
325
+ const KEY = Symbol('qm.review');
326
+ export function setReview(review) {
327
+ setContext(KEY, review);
328
+ }
329
+ const NO_ITEMS = [];
330
+ /** What a component rendered outside the editor gets: nothing to draw. */
331
+ const NO_REVIEW = {
332
+ items: [],
333
+ accepted: new Map(),
334
+ textAt: () => NO_ITEMS,
335
+ reports: new Map(),
336
+ fieldUndrawn: [],
337
+ fieldOutdated: new Set(),
338
+ lit: undefined,
339
+ shown: undefined,
340
+ at: () => ({}),
341
+ marks: () => false,
342
+ keyOf: () => undefined,
343
+ drew() { },
344
+ point() { },
345
+ act: () => false,
346
+ heard() { },
347
+ writing() { },
348
+ hold() { },
349
+ release() { },
350
+ dismiss() { },
351
+ reveal() { }
352
+ };
353
+ /** The editor's review state, or {@link NO_REVIEW} off-tree. */
354
+ export function review() {
355
+ return getContext(KEY) ?? NO_REVIEW;
356
+ }
@@ -1,33 +1,24 @@
1
1
  // A record list's drag handle. Press-and-drag the handle moves its row; a press that does
2
2
  // not travel past the dead zone does nothing. The drop is the row under the pointer, read
3
- // off the rows where they stand, so a scroll by any hand re-picks it. Held in an edge band
4
- // of its scrollport, the drag scrolls it toward the rows out of view, once the pointer has
5
- // been outside the band: a press on a row already in the band does not scroll. Nothing
6
- // reflows until the release (the lift is a tone and the drop rule is out of flow), and the
7
- // release is the one splice `move` makes. A handle that loses the pointer, or leaves the
8
- // DOM, ends the drag with no move.
3
+ // off the rows where they stand, so a scroll by any hand re-picks it, and held at an edge
4
+ // of its scrollport the drag scrolls toward the rows out of view (`core/dragfollow.ts`).
5
+ // A pointer more than a row's height past either end of the list is out of it: the drop
6
+ // rule goes, and a release there moves nothing.
7
+ // Nothing reflows until the release (the lift is a tone and the drop rule is out of flow),
8
+ // and the release is the one splice `move` makes. Escape, a handle that loses the pointer,
9
+ // or one that leaves the DOM ends the drag with no move.
10
+ import { followDrag } from '../core/dragfollow.js';
9
11
  const DEAD_ZONE = 3;
10
- /** The band at a scrollport's top and bottom edges that scrolls it under a held drag, and
11
- * the most one frame scrolls, reached at the edge itself. */
12
- const EDGE = 48;
13
- const STEP = 16;
14
- const page = () => document.scrollingElement ?? document.documentElement;
15
- /** The nearest ancestor that scrolls vertically, else the page. */
16
- function scrollport(from) {
17
- for (let el = from.parentElement; el; el = el.parentElement) {
18
- const { overflowY } = getComputedStyle(el);
19
- if (/auto|scroll/.test(overflowY) && el.scrollHeight > el.clientHeight)
20
- return el;
21
- }
22
- return page();
23
- }
24
12
  export function rowDrag(rows) {
25
13
  let drag = $state();
26
- let follow;
27
- /** The row the pointer is over, or the nearest one past either end. */
14
+ let grip;
15
+ let unfollow;
16
+ /** The row the pointer is over, or the nearest one within its own height past either
17
+ * end; `k`, the drag's own row and so no move, further out than that. */
28
18
  function dropIndex(k, y) {
29
19
  let best = k;
30
20
  let nearest = Infinity;
21
+ let reach = 0;
31
22
  for (let i = 0; i < rows.count(); i++) {
32
23
  const box = rows.box(i);
33
24
  if (!box)
@@ -36,42 +27,31 @@ export function rowDrag(rows) {
36
27
  if (gap < nearest) {
37
28
  nearest = gap;
38
29
  best = i;
30
+ reach = box.bottom - box.top;
39
31
  }
40
32
  }
41
- return best;
33
+ return nearest > reach ? k : best;
42
34
  }
43
35
  function repick() {
44
36
  if (drag?.engaged)
45
37
  drag.drop = dropIndex(drag.k, drag.y);
46
38
  }
47
- function edgeScroll() {
48
- if (!follow || !drag?.engaged)
49
- return;
50
- if (!follow.grip.isConnected) {
51
- drag = undefined;
52
- release();
39
+ function end() {
40
+ drag = undefined;
41
+ release();
42
+ }
43
+ function cancel(e) {
44
+ if (e.key !== 'Escape' || !drag?.engaged)
53
45
  return;
54
- }
55
- const { port } = follow;
56
- const box = port === page() ? undefined : port.getBoundingClientRect();
57
- const top = Math.max(box?.top ?? 0, 0);
58
- const bottom = Math.min(box?.bottom ?? innerHeight, innerHeight);
59
- const into = Math.min(drag.y - top - EDGE, 0) + Math.max(drag.y - bottom + EDGE, 0);
60
- if (!into)
61
- follow.armed = true;
62
- // Only toward rows still out of view: past the list's end there is nothing to reach.
63
- const beyond = into < 0
64
- ? (rows.box(0)?.top ?? top) < top
65
- : (rows.box(rows.count() - 1)?.bottom ?? 0) > bottom;
66
- if (into && follow.armed && beyond)
67
- port.scrollBy({ top: STEP * Math.max(-1, Math.min(1, into / EDGE)), behavior: 'instant' });
68
- follow.frame = requestAnimationFrame(edgeScroll);
46
+ e.preventDefault();
47
+ e.stopPropagation();
48
+ end();
69
49
  }
70
50
  function release() {
71
- if (follow)
72
- cancelAnimationFrame(follow.frame);
73
- follow = undefined;
74
- removeEventListener('scroll', repick, { capture: true });
51
+ unfollow?.();
52
+ unfollow = undefined;
53
+ grip = undefined;
54
+ removeEventListener('keydown', cancel, { capture: true });
75
55
  }
76
56
  return {
77
57
  held: () => drag !== undefined,
@@ -86,10 +66,9 @@ export function rowDrag(rows) {
86
66
  return;
87
67
  e.preventDefault();
88
68
  release();
89
- const grip = e.currentTarget;
69
+ grip = e.currentTarget;
90
70
  grip.setPointerCapture?.(e.pointerId);
91
71
  drag = { k, origin: e.clientY, y: e.clientY, engaged: false, drop: k };
92
- follow = { grip, port: scrollport(grip), armed: false, frame: 0 };
93
72
  },
94
73
  move(e) {
95
74
  if (!drag)
@@ -99,16 +78,26 @@ export function rowDrag(rows) {
99
78
  if (Math.abs(e.clientY - drag.origin) < DEAD_ZONE)
100
79
  return;
101
80
  drag.engaged = true;
102
- addEventListener('scroll', repick, { capture: true, passive: true });
103
- if (follow)
104
- follow.frame = requestAnimationFrame(edgeScroll);
81
+ addEventListener('keydown', cancel, { capture: true });
82
+ if (grip)
83
+ unfollow = followDrag({
84
+ grip,
85
+ axis: 'y',
86
+ at: () => drag?.y ?? 0,
87
+ extent() {
88
+ const first = rows.box(0);
89
+ const last = rows.box(rows.count() - 1);
90
+ return first && last ? { start: first.top, end: last.bottom } : undefined;
91
+ },
92
+ moved: repick,
93
+ lost: end
94
+ });
105
95
  }
106
96
  repick();
107
97
  },
108
98
  up(e) {
109
99
  const done = drag;
110
- drag = undefined;
111
- release();
100
+ end();
112
101
  if (!done?.engaged || e.type !== 'pointerup')
113
102
  return;
114
103
  rows.move(done.k, done.drop);
@@ -1,27 +1,56 @@
1
1
  import type { Diagnostic } from '@quillmark/wasm';
2
- import { type ShortcutStrings, type SlashStrings, type TableChromeStrings } from '../core/codec/index.js';
2
+ import { type LeaveStrings, type ReviewStrings, type ShortcutStrings, type SlashStrings, type TableChromeStrings } from '../core/codec/index.js';
3
3
  import type { BodyPlaceholder } from './structure.js';
4
4
  /**
5
- * The island, the insert menu and the shortcut list's keys come from the codec, which owns
6
- * all three models (a NodeView inside the leaf, the trigger the leaf's keymap drives, and
7
- * the keymaps' own tables). Extending
5
+ * The island, the insert menu, the shortcut list and the review layer's keys come from the
6
+ * codec, which owns all four models (a NodeView inside the leaf, the trigger the leaf's keymap
7
+ * drives, the keymaps' own tables, and the decorations a leaf draws its review with). Extending
8
8
  * rather than restating them is what keeps one English list: a consumer overrides an
9
9
  * island handle's name beside the card controls' and the codec still has a default
10
10
  * for a leaf mounted directly.
11
11
  */
12
- export interface VisualStrings extends TableChromeStrings, SlashStrings, ShortcutStrings {
12
+ export interface VisualStrings extends TableChromeStrings, SlashStrings, ShortcutStrings, LeaveStrings, ReviewStrings {
13
13
  cardMoveUp: string;
14
14
  cardMoveDown: string;
15
15
  cardDelete: string;
16
16
  /** The card-title input's accessible name. */
17
17
  cardTitle: string;
18
+ /**
19
+ * A card control's accessible name, the action and the card it acts on, by the title
20
+ * the header shows: `Delete card, Findings`. The action alone stays the tooltip.
21
+ * Parametric, so word order stays the translator's.
22
+ */
23
+ cardAction: (action: string, card: string) => string;
18
24
  /** A closed panel's header, spoken after its name (`Layout, has an issue`) when a field
19
25
  * inside holds a diagnostic: the leading separator is part of the wording. */
20
26
  groupFlagged: string;
27
+ /** The same header where a field inside holds an item of review. */
28
+ groupReviewed: string;
29
+ /** The card's button, and the row's: takes the change back. */
30
+ reviewUndo: string;
31
+ /** Its tooltip, which names the chord. */
32
+ reviewUndoTitle: string;
33
+ /** The card's accessible name. */
34
+ reviewChange: string;
35
+ /** The toast over a field's proposal taken, beside its way back. */
36
+ reviewAccepted: string;
37
+ /** Before what a change replaced: `Was the old words`. */
38
+ reviewWas: string;
39
+ /** The whole of the card over text that replaced nothing. */
40
+ reviewAdded: string;
41
+ /** Before the text a change took out, or the whole of the card where the host kept none. */
42
+ reviewRemoved: string;
43
+ /** A value that was, or would be, nothing: `Was Empty`. */
44
+ reviewEmpty: string;
45
+ /** A switch's two values, as a card and a row word them. */
46
+ reviewOn: string;
47
+ reviewOff: string;
21
48
  /** The toast's notice, named for what went: `Authors 2 removed`. */
22
49
  undoRemoved: (what: string) => string;
23
50
  /** The toast's button, which puts it back. */
24
51
  undoAction: string;
52
+ /** The standing control that puts a removed card back, named for it: `Restore Findings`. */
53
+ undoRestore: (what: string) => string;
25
54
  /** The trailing strip's visible words, drawn after a `+`, and every
26
55
  * strip's accessible name. One string over
27
56
  * one kind and many: the trigger seeds a card, and which kind is the menu's word
@@ -29,8 +58,12 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
29
58
  addCard: string;
30
59
  arrayAdd: string;
31
60
  arrayRemove: string;
32
- /** The drag handle on an `object` row: its tooltip. */
61
+ /** The drag handle on an `object` row: its tooltip, which names the keys that move
62
+ * the row too. */
33
63
  arrayDrag: string;
64
+ /** What a list's standing row ghosts, the row that is not an element yet: the words
65
+ * say what typing there does. */
66
+ arrayStanding: string;
34
67
  /**
35
68
  * A row control's accessible name, the action and the row it acts on: `Remove
36
69
  * Authors 2`. The action alone stays the tooltip. Parametric, so word order stays
@@ -63,13 +96,18 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
63
96
  diagTypeMismatch: (expected: string) => string;
64
97
  /** `validation::format_violation`: the value misses a string format (`args.format`). */
65
98
  diagFormatViolation: (format: string) => string;
99
+ /** The tag on a field whose `default:` is what prints. */
100
+ fieldDefault: string;
101
+ /** The button that unsets a field written over its `default:`; its accessible name
102
+ * is this word and then the field's label. */
103
+ fieldReset: string;
66
104
  /** The tag on the `default:` member's row ({@link EnumField}). */
67
105
  enumUnsetTag: string;
68
106
  /** The row under a stored value that clears it back to the `default:`. */
69
107
  enumReset: string;
70
108
  /** The same row where no `default:` prints: no `default:`, a blank one, or an `enum?`. */
71
109
  enumClear: string;
72
- /** The count in the matrix's label row: how many of its items are held. */
110
+ /** The count in the matrix's label row: how many of its items are ticked. */
73
111
  matrixHeld: (held: number, total: number) => string;
74
112
  /** An open matrix's add box at rest, naming the list it adds to: `Add to Staff…`. The box
75
113
  * draws its own `+`. `list` is empty for a matrix mounted with no label. */
@@ -175,6 +213,9 @@ export type FormatDiagnostic = (d: Diagnostic) => string | undefined;
175
213
  * `prosemirror-keymap` resolves `Mod` by, so a tooltip names the chord the keymap binds.
176
214
  */
177
215
  export declare function chord(key: string, platform?: string): string;
216
+ /** An `Alt` chord as the writer's platform prints it: `⌥↑` on Apple's, `Alt+↑` elsewhere,
217
+ * on the test {@link chord} reads. */
218
+ export declare function alt(key: string, platform?: string): string;
178
219
  /** The package's English. Every key, so the merge below is total. */
179
220
  export declare const DEFAULT_VISUAL_STRINGS: VisualStrings;
180
221
  /** A consumer's wording: any subset, the rest the package's. */