@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
@@ -5,7 +5,8 @@
5
5
  the whole of what this surface knows about the editor. The active leaf is a
6
6
  field's or a by-value one (an array's element, a subform's cell), reached through
7
7
  its views. A non-empty selection in the active leaf
8
- raises it over that leaf's selection rect; each button dispatches a PM `toggleMark`
8
+ raises it over that leaf's selection rect, or in a table cell under the cell's row,
9
+ which it would otherwise cover; each button dispatches a PM `toggleMark`
9
10
  command straight at the leaf's `EditorView`, whose own `dispatchTransaction` commits
10
11
  the result as it commits a keystroke: a field's lowers it to `markOps` through
11
12
  `apply` (field.ts), a by-value leaf's hands the re-encoded value to its parent
@@ -61,6 +62,15 @@
61
62
  trick): without it, the browser's default mousedown action focuses the
62
63
  button before `click` fires, blurring the editor and collapsing the
63
64
  selection the command is supposed to act on.
65
+
66
+ The keyboard's way in. Alt-F10 over a selection raises the surface at once and puts
67
+ the focus on its first control, which is the only route to the font picker a keyboard
68
+ has and one more to the buttons its chords already reach. Worked from there, the
69
+ surface keeps the focus: Tab and Shift-Tab walk its controls and wrap, the arrows step
70
+ between buttons, an action leaves the focus where it is so a second can follow, and
71
+ Escape hands the focus back to the selection with the surface still up. Entered by a
72
+ press instead, the surface is a pointer's and every action returns the focus to the
73
+ text, as before.
64
74
  -->
65
75
  <script lang="ts">
66
76
  import { onDestroy } from 'svelte';
@@ -84,6 +94,7 @@
84
94
  toggleList,
85
95
  type RangeAnchor
86
96
  } from '../core/codec/index.js';
97
+ import { across } from '../core/codec/anchor.js';
87
98
  import type { ActiveProse } from './leaves.js';
88
99
  import { clearLink, hrefInSelection, normalizeHref, setLink } from './links.js';
89
100
  import { familyInSelection, setFamily } from './fonts.js';
@@ -140,6 +151,9 @@
140
151
  let surfaceView: EditorView | undefined;
141
152
  /** A pointer is down outside this surface: the selection is still being made. */
142
153
  let pressed = false;
154
+ /** The surface is being worked from the keyboard: entered by its key, until the focus
155
+ * goes back to the text or anywhere else. */
156
+ let keyed = false;
143
157
  let linkPromptOpen = $state(false);
144
158
  /** Whether the selection carried a link when the prompt was raised. */
145
159
  let linkPresent = $state(false);
@@ -158,6 +172,9 @@
158
172
 
159
173
  /** The selection the surface hangs off, live rather than measured (`codec/anchor.ts`): floating-ui re-reads it through every scroll and reflow, so `sync` mints one only when the range moves. A new object each time it does, so bits-ui's `watch( => opts.customAnchor.current, …)` sees the change and repositions (a mutated-in-place object would not). */
160
174
  let anchor = $state<RangeAnchor | undefined>(undefined);
175
+ /** Below a table cell's row, where above it the surface covers the row above and
176
+ * takes the presses and drops meant for it. */
177
+ let side = $state<'top' | 'bottom'>('top');
161
178
 
162
179
  /** The view the caret is actually in: the leaf's own, or the nested cell view of a
163
180
  * table island (`codec/table-view.ts`). The six marks are the inline schema's
@@ -208,7 +225,10 @@
208
225
  family = familyInSelection(view.state);
209
226
  surfaceView = view;
210
227
  const { from, to } = view.state.selection;
211
- anchor = rangeAnchor(view, from, to);
228
+ const cell = view.dom.closest('.qm-table-cell');
229
+ const row = cell?.closest('tr');
230
+ anchor = row ? across(rangeAnchor(view, from, to), [row, cell!]) : rangeAnchor(view, from, to);
231
+ side = row ? 'bottom' : 'top';
212
232
  open = true;
213
233
  }
214
234
 
@@ -274,9 +294,80 @@
274
294
  // focus: bits-ui flips `open` itself) must not leave a stale prompt for the
275
295
  // next open.
276
296
  $effect(() => {
277
- if (!open) linkPromptOpen = false;
297
+ if (!open) {
298
+ linkPromptOpen = false;
299
+ keyed = false;
300
+ entering = false;
301
+ }
278
302
  });
279
303
 
304
+ /** The surface's controls, in the order it draws them. */
305
+ const stops = (): HTMLElement[] => [
306
+ ...(contentEl?.querySelectorAll<HTMLElement>('button, select, input') ?? [])
307
+ ];
308
+ /** The view an action from the surface lands on: the one it rose over, a cell view
309
+ * without the focus being no longer the leaf's `focusedView`. */
310
+ const actedOn = (): EditorView | undefined =>
311
+ surfaceView && !surfaceView.isDestroyed ? surfaceView : activeLeafView();
312
+ /** After an action: back to the text, unless the surface is being worked from the
313
+ * keyboard, where the next action is one more key away. */
314
+ function settle(view: EditorView): void {
315
+ if (!keyed) view.focus();
316
+ sync();
317
+ }
318
+
319
+ /** The format bar's key: raise the surface over the selection without the wait a
320
+ * keyboard selection otherwise gets, and enter it. */
321
+ function enterBar(view: EditorView): boolean {
322
+ if (!view.hasFocus()) return false;
323
+ sync();
324
+ if (!open) return false;
325
+ keyed = true;
326
+ entering = true;
327
+ return true;
328
+ }
329
+ /** The key was pressed and the focus is owed to the surface's first control, which
330
+ * a surface raised by that same press has yet to mount. */
331
+ let entering = $state(false);
332
+ $effect(() => {
333
+ if (!entering || !contentEl) return;
334
+ entering = false;
335
+ stops()[0]?.focus();
336
+ });
337
+ /** Out of the surface by its own key: the focus to the selection, the surface up. */
338
+ function leaveBar(): void {
339
+ keyed = false;
340
+ const view = actedOn();
341
+ if (!view) return;
342
+ view.focus();
343
+ sync();
344
+ }
345
+ function onBarKeyDown(e: KeyboardEvent): void {
346
+ if (!keyed) return;
347
+ const all = stops();
348
+ const at = all.indexOf(e.target as HTMLElement);
349
+ if (at < 0) return;
350
+ const onButton = e.target instanceof HTMLButtonElement;
351
+ const step =
352
+ e.key === 'Tab'
353
+ ? e.shiftKey
354
+ ? -1
355
+ : 1
356
+ : onButton && e.key === 'ArrowRight'
357
+ ? 1
358
+ : onButton && e.key === 'ArrowLeft'
359
+ ? -1
360
+ : 0;
361
+ if (!step || e.ctrlKey || e.metaKey || e.altKey) return;
362
+ e.preventDefault();
363
+ all[(at + step + all.length) % all.length].focus();
364
+ }
365
+ /** The focus going anywhere but another of the surface's controls ends the keyboard's
366
+ * hold on it. */
367
+ function onBarFocusOut(e: FocusEvent): void {
368
+ if (!contentEl?.contains(e.relatedTarget as Node | null)) keyed = false;
369
+ }
370
+
280
371
  // The prompt takes its own focus. Nothing else moves it: open-auto-focus is
281
372
  // prevented (focus discipline above), and the prompt replaces the buttons on a
282
373
  // surface already open, so without this the URL is typed into the document.
@@ -298,7 +389,7 @@
298
389
  // prompt, not a second meaning for the button. The five value-less marks keep
299
390
  // the toggle.
300
391
  function toggle(name: string): void {
301
- const view = activeLeafView();
392
+ const view = actedOn();
302
393
  if (!view) return;
303
394
  const type: MarkType | undefined = view.state.schema.marks[name];
304
395
  if (!type) return;
@@ -310,30 +401,28 @@
310
401
  return;
311
402
  }
312
403
  toggleMark(type)(view.state, view.dispatch);
313
- view.focus();
314
- sync();
404
+ settle(view);
315
405
  }
316
406
 
317
407
  function pickFamily(name: string): void {
318
- const view = surfaceView && !surfaceView.isDestroyed ? surfaceView : activeLeafView();
408
+ const view = actedOn();
319
409
  if (!view) return;
320
410
  setFamily(name)(view.state, view.dispatch);
321
- view.focus();
322
- sync();
411
+ settle(view);
323
412
  }
324
413
 
325
414
  function toggleLines(ordered: boolean): void {
326
- const view = activeLeafView();
415
+ const view = actedOn();
327
416
  if (!view) return;
328
417
  toggleList(ordered)(view.state, view.dispatch);
329
- view.focus();
330
- sync();
418
+ settle(view);
331
419
  }
332
420
 
333
421
  /** Every exit from the prompt: lower it, run `cmd` if there is one, and hand the
334
422
  * leaf back its focus and the surface its buttons. */
335
423
  function closePrompt(cmd?: Command): void {
336
424
  linkPromptOpen = false;
425
+ keyed = false;
337
426
  const view = promptView && !promptView.isDestroyed ? promptView : activeLeafView();
338
427
  promptView = undefined;
339
428
  if (view) {
@@ -364,14 +453,15 @@
364
453
  return true;
365
454
  }
366
455
 
367
- const linkKey = keydownHandler({
368
- [FIELD_KEYS.link]: (_state, _dispatch, view) => !!view && raiseLink(view)
456
+ const surfaceKeys = keydownHandler({
457
+ [FIELD_KEYS.link]: (_state, _dispatch, view) => !!view && raiseLink(view),
458
+ [FIELD_KEYS.formatBar]: (_state, _dispatch, view) => !!view && enterBar(view)
369
459
  });
370
460
 
371
461
  function onKeyDown(e: KeyboardEvent): void {
372
462
  if (e.defaultPrevented) return;
373
463
  const view = activeLeafView();
374
- if (view && linkKey(view, e)) e.preventDefault();
464
+ if (view && surfaceKeys(view, e)) e.preventDefault();
375
465
  }
376
466
 
377
467
  function removeLink(): void {
@@ -405,12 +495,19 @@
405
495
  <Popover.Content
406
496
  customAnchor={anchor ?? null}
407
497
  collisionBoundary={portalTarget ?? []}
408
- side="top"
498
+ {side}
409
499
  align="center"
410
500
  trapFocus={false}
411
501
  sideOffset={spacePx(portalTarget, 2)}
412
502
  onOpenAutoFocus={(e: Event) => e.preventDefault()}
413
503
  onCloseAutoFocus={(e: Event) => e.preventDefault()}
504
+ onEscapeKeydown={(e: KeyboardEvent) => {
505
+ // Worked from the keyboard, Escape is the way back to the text, not a
506
+ // dismissal that would leave the focus on a control going away.
507
+ if (!keyed || linkPromptOpen) return;
508
+ e.preventDefault();
509
+ leaveBar();
510
+ }}
414
511
  >
415
512
  <!-- The `child` snippet, so the surface is the primitive's content node
416
513
  rather than a pill inside it: the dismissal is a CSS animation and the
@@ -430,6 +527,8 @@
430
527
  class="qm-format-popover qm-popover-surface"
431
528
  data-qm-root
432
529
  inert={!raised}
530
+ onkeydown={onBarKeyDown}
531
+ onfocusout={onBarFocusOut}
433
532
  >
434
533
  {#if linkPromptOpen}
435
534
  <form
@@ -469,10 +568,16 @@
469
568
  >
470
569
  </form>
471
570
  {:else}
472
- <!-- `role="group"`, not `toolbar`: these buttons carry no roving-tabindex /
473
- arrow-key navigation, so the ARIA toolbar contract would be a lie;
474
- a labelled group is the honest description. -->
475
- <div class="qm-format-buttons" role="group" aria-label={t.strings.formatGroup}>
571
+ <!-- `role="group"`, not `toolbar`: every control here is a tab stop of its
572
+ own and the picker keeps its arrows, so the ARIA toolbar contract of one
573
+ stop and roving arrows would be a lie; a labelled group is the honest
574
+ description. -->
575
+ <div
576
+ class="qm-format-buttons"
577
+ role="group"
578
+ aria-label={t.strings.formatGroup}
579
+ aria-keyshortcuts={FIELD_KEYS.formatBar.replaceAll('-', '+')}
580
+ >
476
581
  {#each MARKS as m (m.name)}
477
582
  <button
478
583
  type="button"
@@ -1,6 +1,8 @@
1
1
  <!--
2
2
  An open matrix's add box (INVARIANTS §"The matrix"): a plain text input. Enter adds
3
- what was typed, trimmed, and clears the box; Escape clears it. It is drawn as the item
3
+ what was typed, trimmed, and clears the box, and so does the focus leaving it: words
4
+ typed there are an item, not a draft a click elsewhere discards. Escape clears it
5
+ unadded. It is drawn as the item
4
6
  it adds, unwritten: the plus in the tick's column and the words in the title's.
5
7
  -->
6
8
  <script lang="ts">
@@ -11,8 +13,9 @@
11
13
  id: string;
12
14
  /** The input's accessible name and its words at rest. */
13
15
  placeholder: string;
14
- /** Add an item titled `title`, never empty. */
15
- onAdd: (title: string) => void;
16
+ /** Add an item titled `title`, never empty. `land` is off where the focus has
17
+ * already gone elsewhere and stays there. */
18
+ onAdd: (title: string, land: boolean) => void;
16
19
  }
17
20
  let { id, placeholder, onAdd }: Props = $props();
18
21
 
@@ -23,13 +26,16 @@
23
26
  inputEl?.focus();
24
27
  }
25
28
 
29
+ function take(land: boolean): void {
30
+ const title = typed.trim();
31
+ typed = '';
32
+ if (title) onAdd(title, land);
33
+ }
26
34
  function onkeydown(e: KeyboardEvent): void {
27
35
  if (e.isComposing) return;
28
36
  if (e.key === 'Enter' && typed.trim()) {
29
37
  e.preventDefault();
30
- const title = typed.trim();
31
- typed = '';
32
- onAdd(title);
38
+ take(true);
33
39
  } else if (e.key === 'Escape' && typed) {
34
40
  e.preventDefault();
35
41
  e.stopPropagation();
@@ -51,6 +57,7 @@
51
57
  aria-label={placeholder}
52
58
  {placeholder}
53
59
  {onkeydown}
60
+ onblur={() => inputEl?.isConnected && take(false)}
54
61
  />
55
62
  </label>
56
63
  </div>
@@ -2,8 +2,9 @@ interface Props {
2
2
  id: string;
3
3
  /** The input's accessible name and its words at rest. */
4
4
  placeholder: string;
5
- /** Add an item titled `title`, never empty. */
6
- onAdd: (title: string) => void;
5
+ /** Add an item titled `title`, never empty. `land` is off where the focus has
6
+ * already gone elsewhere and stays there. */
7
+ onAdd: (title: string, land: boolean) => void;
7
8
  }
8
9
  declare const MatrixAdd: import("svelte").Component<Props, {
9
10
  focus: () => void;
@@ -12,7 +12,8 @@
12
12
  held by being present, so each draws a fixed tick, its `title` as an input, a remove,
13
13
  and the same columns. The add box closes the list ({@link MatrixAdd}): what is typed
14
14
  there is added under an id minted from it past every id the list holds, so a title the
15
- list already carries is a second item.
15
+ list already carries is a second item. A removed item is offered back on the editor's
16
+ toast (`undo.svelte.ts`), under its own id while the list has not taken it.
16
17
 
17
18
  The control owns its label row, as an array does: the count of held items sits
18
19
  where an array's add chip sits, so {@link Field} skips its own label for it.
@@ -25,12 +26,16 @@
25
26
  gesture writes it whole with the change in it.
26
27
  -->
27
28
  <script lang="ts">
28
- import { tick as flush } from 'svelte';
29
+ import { onDestroy, tick as flush } from 'svelte';
29
30
  import { wording } from './strings.js';
31
+ import { structuralUndo } from './undo.svelte.js';
30
32
 
31
33
  // The surface's words, ambient from the editor root; the package's English
32
34
  // off-tree, so this component renders standalone too.
33
35
  const t = wording();
36
+ const undo = structuralUndo();
37
+ let alive = true;
38
+ onDestroy(() => (alive = false));
34
39
  import type { Content, PathStep, QuillFieldSchema } from '@quillmark/wasm';
35
40
  import {
36
41
  MATRIX_TITLE,
@@ -191,19 +196,37 @@
191
196
  function retitle(id: string, title: string): void {
192
197
  commit(commitMember(map, id, memberWrite(matrixColumns(own(map, id)), title)));
193
198
  }
194
- async function removeItem(id: string): Promise<void> {
199
+ const taken = (id: string): boolean =>
200
+ onRoster(schema, id) || (map != null && Object.hasOwn(map, id));
201
+ async function removeItem(id: string, name: string): Promise<void> {
195
202
  const at = added.findIndex((item) => item.id === id);
203
+ const item = own(map, id);
196
204
  commit(commitMember(map, id, undefined));
205
+ undo.offer(t.strings.undoRemoved(name), () => restore(id, item));
197
206
  await flush();
198
207
  // The caret goes where the row was: the next added item, else the add box.
199
208
  const next = added[at] ?? added[at - 1];
200
209
  if (next) own(titleEls, next.id)?.focus();
201
210
  else addEl?.focus();
211
+ undo.hand(document.activeElement);
212
+ }
213
+ /** A removal's undo: the item back as it was stored, under its own id unless the list
214
+ * has since taken it. A no-op once this field is gone. */
215
+ async function restore(id: string, item: unknown): Promise<void> {
216
+ if (!alive) return;
217
+ const back = taken(id)
218
+ ? addedId(titleText((item as Record<string, unknown>)[MATRIX_TITLE]), taken)
219
+ : id;
220
+ commit(commitMember(map, back, item));
221
+ await flush();
222
+ own(titleEls, back)?.focus();
202
223
  }
203
224
 
204
225
  // ── The add box ────────────────────────────────────────────────────────────
205
- async function add(title: string): Promise<void> {
206
- const taken = (id: string) => onRoster(schema, id) || (map != null && Object.hasOwn(map, id));
226
+ /** Add an item titled `title`. `land` off leaves the focus where it is: the add a
227
+ * blur made, the focus having gone where the user sent it. */
228
+ async function add(title: string, land = true): Promise<void> {
229
+ undo.withdraw();
207
230
  const id = addedId(title, taken);
208
231
  commit(commitMember(map, id, memberWrite({}, title)));
209
232
  await flush();
@@ -211,7 +234,7 @@
211
234
  // The item's columns are what the author came to fill; a checklist has none, and
212
235
  // the box stays where the next item is typed.
213
236
  const first = Object.keys(schema.properties ?? {})[0];
214
- if (first !== undefined) own(colEls, id)?.focusPath([first]);
237
+ if (land && first !== undefined) own(colEls, id)?.focusPath([first]);
215
238
  if (box) bloom(box);
216
239
  }
217
240
 
@@ -334,7 +357,7 @@
334
357
  class="qm-icon-btn qm-focus-ring qm-member-remove"
335
358
  title={t.strings.matrixRemove(name)}
336
359
  aria-label={t.strings.matrixRemove(name)}
337
- onclick={() => removeItem(item.id)}><Icon name="minus" /></button
360
+ onclick={() => removeItem(item.id, name)}><Icon name="x" /></button
338
361
  >
339
362
  </div>
340
363
  {@render columns(item.id, name, true)}
@@ -391,6 +414,11 @@
391
414
  justify-content: space-between;
392
415
  gap: var(--_qm-space-2);
393
416
  }
417
+ /* Under a label that carries its description in flow, the count keeps the label's
418
+ line rather than centring on the two. */
419
+ .qm-matrix-header:has(> :global(.qm-field-label-row.briefed)) {
420
+ align-items: baseline;
421
+ }
394
422
  /* The count reads at the label rung: a fact about the field, never a value. */
395
423
  .qm-matrix-count {
396
424
  font-size: var(--_qm-text-label);
@@ -525,7 +553,7 @@
525
553
  .qm-member-title-input:focus {
526
554
  background: var(--_qm-surface-well);
527
555
  }
528
- /* The remove is an array row's, the minus to the add box's plus: offered by the row
556
+ /* The remove is an array row's cross: offered by the row
529
557
  the pointer or the focus is in, and destructive under the pointer. */
530
558
  .qm-member-remove {
531
559
  flex-shrink: 0;
@@ -4,8 +4,10 @@
4
4
  (`-`, `1.`) is never a document state worth a boundary round-trip, and
5
5
  committing it live flashes a coercion diagnostic + `console.error` on every
6
6
  intermediate prefix, announced by `DiagnosticList`'s `role="status"` live
7
- region. Escape takes a pending entry back to what the field holds, as it takes a
8
- card rename back, and the focus stays; with nothing pending the key is not claimed.
7
+ region. Where the parent moves on at Enter (`onEnter`), Enter commits at once and
8
+ the move follows a number, never a blank or a refused entry. Escape takes a pending
9
+ entry back to what the field holds, as it takes a card rename back, and the focus
10
+ stays; with nothing pending the key is not claimed.
9
11
 
10
12
  An unset field holds its resolved `default:` as its text, at the default rung
11
13
  (theme.css), and an edit that settles writes it as authored, as `TextField` takes
@@ -49,8 +51,12 @@
49
51
  /** The parked `description` (FieldLabel): announced after the name. */
50
52
  describedBy?: string;
51
53
  onCommit: (v: number | string | undefined) => void;
54
+ /** Enter settled the entry as a number: a list's row moves on from it. Enter
55
+ * claimed here commits at once rather than at the browser's own `change`. */
56
+ onEnter?: () => void;
52
57
  }
53
- let { value, integer, fallback, placeholder, label, id, describedBy, onCommit }: Props = $props();
58
+ let { value, integer, fallback, placeholder, label, id, describedBy, onCommit, onEnter }: Props =
59
+ $props();
54
60
 
55
61
  const resting = $derived(value != null ? String(value) : (fallback ?? ''));
56
62
  let local = $derived(resting);
@@ -83,8 +89,19 @@
83
89
  // which clears the refusal drawn on the field.
84
90
  let reverted = false;
85
91
  let offered = false;
92
+ // The text Enter last settled, which the browser's `change` on leaving would settle again.
93
+ let settled: string | undefined;
94
+ function onKey(e: KeyboardEvent): void {
95
+ if (e.key === 'Escape') return revert(e);
96
+ if (e.key !== 'Enter' || !onEnter || e.isComposing) return;
97
+ const el = e.currentTarget as HTMLInputElement;
98
+ e.preventDefault();
99
+ if (el.value !== settled && el.value !== resting) commit(el);
100
+ settled = el.value;
101
+ if (!offered && el.value.trim() !== '') onEnter();
102
+ }
86
103
  function revert(e: KeyboardEvent): void {
87
- if (e.key !== 'Escape' || e.isComposing) return;
104
+ if (e.isComposing) return;
88
105
  const el = e.currentTarget as HTMLInputElement;
89
106
  if (el.value === resting) return;
90
107
  e.preventDefault();
@@ -134,9 +151,13 @@
134
151
  oninput={(e) => {
135
152
  local = (e.currentTarget as HTMLInputElement).value;
136
153
  reverted = false;
154
+ settled = undefined;
155
+ }}
156
+ onkeydown={onKey}
157
+ onchange={(e) => {
158
+ const el = e.currentTarget as HTMLInputElement;
159
+ if (el.value !== settled) commit(el);
137
160
  }}
138
- onkeydown={revert}
139
- onchange={(e) => commit(e.currentTarget as HTMLInputElement)}
140
161
  />
141
162
 
142
163
  <style>
@@ -16,6 +16,9 @@ interface Props {
16
16
  /** The parked `description` (FieldLabel): announced after the name. */
17
17
  describedBy?: string;
18
18
  onCommit: (v: number | string | undefined) => void;
19
+ /** Enter settled the entry as a number: a list's row moves on from it. Enter
20
+ * claimed here commits at once rather than at the browser's own `change`. */
21
+ onEnter?: () => void;
19
22
  }
20
23
  declare const NumberField: import("svelte").Component<Props, {}, "">;
21
24
  type NumberField = ReturnType<typeof NumberField>;
@@ -54,6 +54,8 @@
54
54
  textCap
55
55
  } from './structure.js';
56
56
  import { splitDeep, unrouted, type DeepDiagnostic } from './diagnostics.js';
57
+ import { splitReview, type DeepReview } from './review.js';
58
+ import ReviewRows from './ReviewRows.svelte';
57
59
  import type { LandingBox } from './leaves.js';
58
60
  import { isEmptyContent } from '../core/codec/index.js';
59
61
  import { wording } from './strings.js';
@@ -118,6 +120,11 @@
118
120
  * one naming a property draws under that property's control, and one naming
119
121
  * nothing this subform holds draws at its foot (`diagnostics.ts`). */
120
122
  diagnostics?: readonly DeepDiagnostic[];
123
+ /** The review items naming a place inside this subform, each with its steps still to
124
+ * walk: one naming a cell draws under the cell's control, one naming a place inside a
125
+ * record or a list cell is handed to it, and the rest draw under the cell they are in
126
+ * or at the subform's foot (`ReviewRows`). */
127
+ review?: readonly DeepReview[];
121
128
  }
122
129
  let {
123
130
  value,
@@ -132,7 +139,8 @@
132
139
  flat = false,
133
140
  placed = false,
134
141
  onCellKey,
135
- diagnostics
142
+ diagnostics,
143
+ review
136
144
  }: Props = $props();
137
145
 
138
146
  const t = wording();
@@ -150,6 +158,14 @@
150
158
  );
151
159
  const routed = $derived(splitDeep(diagnostics));
152
160
  const foot = $derived(unrouted(routed, (step) => typeof step === 'string' && has(step)));
161
+ const reviewed = $derived(splitReview(review));
162
+ /** The items naming no cell this subform holds, drawn at its foot with where they are. */
163
+ const reviewFoot = $derived([
164
+ ...reviewed.here,
165
+ ...[...reviewed.below]
166
+ .filter(([step]) => typeof step !== 'string' || !has(step))
167
+ .flatMap(([step, list]) => list.map((e) => ({ steps: [step, ...e.steps], item: e.item })))
168
+ ]);
153
169
 
154
170
  /** What an unset optional cell ghosts, which is what it prints: `none`. An answered
155
171
  * cell ghosts nothing, an empty answer printing empty. */
@@ -281,6 +297,8 @@
281
297
  {@const describes =
282
298
  sub.description && idBase ? propertyDomIds(idBase, key).description : undefined}
283
299
  {@const deep = routed.below.get(key)}
300
+ {@const reviewHere = reviewed.below.get(key)}
301
+ {@const handsDown = kind === 'object' || kind === 'array'}
284
302
  {@const own = isContainer(kind) ? undefined : deep?.map((d) => d.diagnostic)}
285
303
  <!-- `for` reaches the labelable controls, a variant through its discriminant; the
286
304
  date field's focus lives on a segment and a prose cell is a `contenteditable`,
@@ -420,6 +438,7 @@
420
438
  contentAt={(path) => contentAt([key, ...path])}
421
439
  onCommit={(v) => commitProp(key, v)}
422
440
  diagnostics={deep}
441
+ review={reviewHere}
423
442
  />
424
443
  {:else if kind === 'object'}
425
444
  <ObjectField
@@ -434,6 +453,7 @@
434
453
  contentAt={(path) => contentAt([key, ...path])}
435
454
  onCommit={(v) => commitProp(key, v)}
436
455
  diagnostics={deep}
456
+ review={reviewHere}
437
457
  />
438
458
  {:else if kind === 'matrix'}
439
459
  <MatrixField
@@ -473,11 +493,15 @@
473
493
  />
474
494
  {/if}
475
495
  <DiagnosticList diagnostics={own} />
496
+ {#if !handsDown}
497
+ <ReviewRows entries={reviewHere} value={obj[key]} />
498
+ {/if}
476
499
  </div>
477
500
  </div>
478
501
  {/each}
479
502
  </div>
480
503
  <DiagnosticList diagnostics={foot} />
504
+ <ReviewRows entries={reviewFoot} {value} />
481
505
  </div>
482
506
 
483
507
  <style>
@@ -1,5 +1,6 @@
1
1
  import type { Content, PathStep, QuillFieldSchema } from '@quillmark/wasm';
2
2
  import { type DeepDiagnostic } from './diagnostics.js';
3
+ import { type DeepReview } from './review.js';
3
4
  import type { LandingBox } from './leaves.js';
4
5
  import ObjectField from './ObjectField.svelte';
5
6
  interface Props {
@@ -48,6 +49,11 @@ interface Props {
48
49
  * one naming a property draws under that property's control, and one naming
49
50
  * nothing this subform holds draws at its foot (`diagnostics.ts`). */
50
51
  diagnostics?: readonly DeepDiagnostic[];
52
+ /** The review items naming a place inside this subform, each with its steps still to
53
+ * walk: one naming a cell draws under the cell's control, one naming a place inside a
54
+ * record or a list cell is handed to it, and the rest draw under the cell they are in
55
+ * or at the subform's foot (`ReviewRows`). */
56
+ review?: readonly DeepReview[];
51
57
  }
52
58
  declare const ObjectField: import("svelte").Component<Props, {
53
59
  focus: () => void;