@quillmark/svelte 0.30.0 → 0.32.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 +5 -5
  2. package/dist/core/address.d.ts +1 -1
  3. package/dist/core/address.js +1 -1
  4. package/dist/core/codec/atoms.js +1 -1
  5. package/dist/core/codec/breaks.js +3 -2
  6. package/dist/core/codec/decode.d.ts +4 -3
  7. package/dist/core/codec/decode.js +17 -13
  8. package/dist/core/codec/field.d.ts +5 -4
  9. package/dist/core/codec/field.js +139 -49
  10. package/dist/core/codec/index.d.ts +2 -0
  11. package/dist/core/codec/index.js +5 -1
  12. package/dist/core/codec/inputrules.js +3 -3
  13. package/dist/core/codec/islands.d.ts +1 -1
  14. package/dist/core/codec/islands.js +3 -3
  15. package/dist/core/codec/keymap.d.ts +1 -1
  16. package/dist/core/codec/keymap.js +3 -2
  17. package/dist/core/codec/list-move.js +2 -1
  18. package/dist/core/codec/list-paste.js +1 -1
  19. package/dist/core/codec/lists.d.ts +1 -1
  20. package/dist/core/codec/lists.js +7 -6
  21. package/dist/core/codec/markdown-paste.js +2 -2
  22. package/dist/core/codec/positions.d.ts +12 -1
  23. package/dist/core/codec/prose.css +3 -11
  24. package/dist/core/codec/schema.d.ts +3 -3
  25. package/dist/core/codec/schema.js +6 -6
  26. package/dist/core/codec/shortcuts.d.ts +91 -0
  27. package/dist/core/codec/shortcuts.js +135 -0
  28. package/dist/core/codec/slash.d.ts +4 -2
  29. package/dist/core/codec/slash.js +11 -1
  30. package/dist/core/codec/table-paste.js +1 -1
  31. package/dist/core/codec/table-view.d.ts +1 -1
  32. package/dist/core/codec/table-view.js +27 -37
  33. package/dist/core/codec/tasks.js +1 -1
  34. package/dist/core/index.d.ts +1 -0
  35. package/dist/core/theme.css +16 -8
  36. package/dist/preset/scale.css +1 -1
  37. package/dist/preview/Preview.svelte +2 -3
  38. package/dist/preview/bridge.js +2 -2
  39. package/dist/preview/geometry.d.ts +2 -2
  40. package/dist/preview/geometry.js +2 -2
  41. package/dist/preview/paint.js +1 -1
  42. package/dist/visual/ArrayField.svelte +172 -87
  43. package/dist/visual/BooleanField.svelte +3 -3
  44. package/dist/visual/Card.svelte +68 -47
  45. package/dist/visual/CardControls.svelte +1 -1
  46. package/dist/visual/DateField.svelte +17 -2
  47. package/dist/visual/DiagnosticList.svelte +35 -3
  48. package/dist/visual/EnumField.svelte +59 -45
  49. package/dist/visual/Field.svelte +16 -6
  50. package/dist/visual/Field.svelte.d.ts +3 -1
  51. package/dist/visual/FieldHint.svelte +10 -3
  52. package/dist/visual/FormatPopover.svelte +9 -3
  53. package/dist/visual/MatrixAdd.svelte +4 -19
  54. package/dist/visual/MatrixField.svelte +21 -13
  55. package/dist/visual/NumberField.svelte +2 -3
  56. package/dist/visual/ObjectField.svelte +166 -147
  57. package/dist/visual/ProseField.svelte +8 -3
  58. package/dist/visual/SlashMenu.svelte +24 -12
  59. package/dist/visual/SlashMenu.svelte.d.ts +2 -0
  60. package/dist/visual/TextField.svelte +1 -1
  61. package/dist/visual/VariantField.svelte +1 -1
  62. package/dist/visual/VisualEditor.svelte +1 -1
  63. package/dist/visual/VisualEditor.svelte.d.ts +1 -1
  64. package/dist/visual/VisualEditorInner.svelte +159 -24
  65. package/dist/visual/VisualEditorInner.svelte.d.ts +1 -1
  66. package/dist/visual/controls.css +43 -5
  67. package/dist/visual/diagnostics.d.ts +2 -2
  68. package/dist/visual/diagnostics.js +2 -2
  69. package/dist/visual/index.d.ts +2 -0
  70. package/dist/visual/index.js +3 -0
  71. package/dist/visual/leaves.js +1 -1
  72. package/dist/visual/props.d.ts +2 -2
  73. package/dist/visual/strings.d.ts +33 -15
  74. package/dist/visual/strings.js +42 -7
  75. package/dist/visual/structure.d.ts +27 -18
  76. package/dist/visual/structure.js +32 -28
  77. package/dist/visual/tips.js +1 -1
  78. package/dist/visual/undo.svelte.d.ts +36 -0
  79. package/dist/visual/undo.svelte.js +119 -0
  80. package/package.json +2 -2
  81. package/dist/visual/hold.d.ts +0 -17
  82. package/dist/visual/hold.js +0 -39
@@ -30,8 +30,10 @@
30
30
  leaf: () => FieldController | undefined;
31
31
  /** The menu's accessible name. */
32
32
  label: string;
33
+ /** A command's row name, by its token. */
34
+ name: (command: string) => string;
33
35
  }
34
- let { menu, leaf, label }: Props = $props();
36
+ let { menu, leaf, label, name: nameOf }: Props = $props();
35
37
 
36
38
  let open = $derived(!!menu && menu.items.length > 0);
37
39
 
@@ -95,9 +97,10 @@
95
97
  aria-label={label}
96
98
  inert={!raised}
97
99
  >
98
- <!-- The row is the command as typed, leading `/` and all: the menu is a
99
- completion of the run in the text, so the row and the run read the
100
- same. -->
100
+ <!-- The row is the command's name, and at its end the command as typed,
101
+ leading `/` and all: the menu is a completion of the run in the text,
102
+ so the token is what the run reads as, and the name is what a reader
103
+ who has not learned the tokens picks by. -->
101
104
  {#each menu?.items ?? [] as name, i (name)}
102
105
  <button
103
106
  type="button"
@@ -107,7 +110,8 @@
107
110
  onclick={() => leaf()?.slashPick(name)}
108
111
  onpointerenter={() => leaf()?.slashFocus(name)}
109
112
  >
110
- /{name}
113
+ <span class="qm-slash-name">{nameOf(name)}</span>
114
+ <span class="qm-slash-token" aria-hidden="true">/{name}</span>
111
115
  </button>
112
116
  {/each}
113
117
  </div>
@@ -122,15 +126,11 @@
122
126
  `.qm-menu-surface` / `.qm-menu-item` (controls.css): the same recipe the enum
123
127
  listbox and the card stack's kind menu draw, because all three are lists picked
124
128
  from. What is here is this menu's own: a measure, so a long label does not stretch
125
- the surface across the card, a scroll for a filtered list that stays long, and the
126
- face. Monospace, where the sibling menus are not: they offer values of the document
127
- and read as the prose around them, where these are commands, and the surface
128
- already spells a literal in that face (the `code` mark, `codec/prose.css`). */
129
+ the surface across the card, and a scroll for a filtered list that stays long. */
129
130
  .qm-slash-menu {
130
- min-width: 12rem;
131
+ min-width: 14rem;
131
132
  max-height: 16rem;
132
133
  overflow-y: auto;
133
- font-family: var(--_qm-font-mono);
134
134
  }
135
135
  /* An item is a row of text, not a glyph: the whole row is the target, and the label
136
136
  is the accessible name with nothing beside it. A button is a button, so the UA's
@@ -138,7 +138,10 @@
138
138
  taken back here: a scoped block is unlayered, so a reset would outrank the recipe's
139
139
  highlight; the resting transparent is the recipe's own (controls.css). */
140
140
  .qm-slash-item {
141
- display: block;
141
+ display: flex;
142
+ align-items: baseline;
143
+ justify-content: space-between;
144
+ gap: var(--_qm-space-3);
142
145
  width: 100%;
143
146
  border: none;
144
147
  font: inherit;
@@ -146,4 +149,13 @@
146
149
  text-align: left;
147
150
  white-space: nowrap;
148
151
  }
152
+ /* The token in the face the surface spells a literal in (the `code` mark,
153
+ `codec/prose.css`), at the label ink and rung: the name is the row, and the token is
154
+ the shortcut a menu row carries at its end. Hidden from the accessible name, which
155
+ would read the command twice. */
156
+ .qm-slash-token {
157
+ font-family: var(--_qm-font-mono);
158
+ font-size: var(--_qm-text-label);
159
+ color: var(--_qm-ink-label);
160
+ }
149
161
  </style>
@@ -7,6 +7,8 @@ interface Props {
7
7
  leaf: () => FieldController | undefined;
8
8
  /** The menu's accessible name. */
9
9
  label: string;
10
+ /** A command's row name, by its token. */
11
+ name: (command: string) => string;
10
12
  }
11
13
  declare const SlashMenu: import("svelte").Component<Props, {}, "">;
12
14
  type SlashMenu = ReturnType<typeof SlashMenu>;
@@ -9,7 +9,7 @@
9
9
  default taken, whatever the edit left of it. Tabbing through writes nothing; a
10
10
  keystroke typed and removed pins the default.
11
11
 
12
- An emptied input writes what empty means for this field (VISUAL_EDITOR §"The
12
+ An emptied input writes what empty means for this field (INVARIANTS §"The
13
13
  commitment ladder"): `""` over a default that prints, the only answer that prints empty there;
14
14
  the unset rung elsewhere, where unset already prints nothing and the field stays
15
15
  unanswered, and an optional cell returns to `none`.
@@ -1,6 +1,6 @@
1
1
  <!--
2
2
  An `enum` declaring `variants:` → the discriminant's select, and under it the cells
3
- the chosen world brings into play (VISUAL_EDITOR §"Enum variants"). The field rests as
3
+ the chosen world brings into play (INVARIANTS §Enums). The field rests as
4
4
  a container, `{value: <member>, …that member's fields}`, and commits whole: it is one
5
5
  cell to `Addr`, so there is no per-cell write address.
6
6
 
@@ -26,7 +26,7 @@
26
26
  import { untrack } from 'svelte';
27
27
  import { reportRebindIgnored } from '../core/rebind.svelte.js';
28
28
  import type { DocPath, Landing } from '../core/address.js';
29
- import type { Delta } from '@quillmark/wasm';
29
+ import type { Delta } from '../core/codec/positions.js';
30
30
  import type { CardId, CardOp } from './signals.js';
31
31
  import type { VisualEditorProps } from './props.js';
32
32
  import VisualEditorInner from './VisualEditorInner.svelte';
@@ -1,5 +1,5 @@
1
1
  import type { DocPath, Landing } from '../core/address.js';
2
- import type { Delta } from '@quillmark/wasm';
2
+ import type { Delta } from '../core/codec/positions.js';
3
3
  import type { CardId, CardOp } from './signals.js';
4
4
  import type { VisualEditorProps } from './props.js';
5
5
  declare const VisualEditor: import("svelte").Component<VisualEditorProps, {
@@ -1,6 +1,6 @@
1
1
  <!--
2
- The federated WYSIWYG surface (VISUAL_EDITOR). A thin composition over many
3
- small editors; not one PM document spanning the page.
2
+ The federated WYSIWYG surface (INVARIANTS §"Federated, not monolithic"). A thin
3
+ composition over many small editors; not one PM document spanning the page.
4
4
 
5
5
  Mounted once per document. `VisualEditor` keys this component on `doc`, so
6
6
  everything below seeds from a handle that cannot change under it: `cardIds`, the
@@ -37,7 +37,6 @@
37
37
  import type {
38
38
  Addr,
39
39
  CardAddr,
40
- Delta,
41
40
  Diagnostic,
42
41
  PathStep,
43
42
  PayloadItem,
@@ -46,7 +45,9 @@
46
45
  ResolvedField
47
46
  } from '@quillmark/wasm';
48
47
  import type { VisualEditorProps } from './props.js';
48
+ import type { Delta } from '../core/codec/positions.js';
49
49
  import { mergeStrings, setWording } from './strings.js';
50
+ import { createStructuralUndo, setStructuralUndo } from './undo.svelte.js';
50
51
  import type { CardId, CardOp, ChangeSource } from './signals.js';
51
52
  import type { FieldController, LeafViews } from '../core/codec/index.js';
52
53
  import {
@@ -140,7 +141,7 @@
140
141
  // svelte-ignore state_referenced_locally
141
142
  let cardIds = $state<string[]>(seq.take(doc.cardCount));
142
143
 
143
- // Local commit-error diagnostics (VISUAL_EDITOR §Diagnostics, producer #2),
144
+ // Local commit-error diagnostics (INVARIANTS §Diagnostics, producer #2),
144
145
  // id-keyed rather than positional so an error stays pinned to its field across a
145
146
  // card reorder.
146
147
  const commitErrors = new SvelteMap<string, RoutedDiagnostic>();
@@ -167,7 +168,7 @@
167
168
  revision++;
168
169
  liveTitles = {};
169
170
  }
170
- /** Read at the mutation boundary, never cached (VISUAL_EDITOR §"The address is the
171
+ /** Read at the mutation boundary, never cached (INVARIANTS §"The address is the
171
172
  * spine"). */
172
173
  function cardIndexOf(id: string): number {
173
174
  return cardIds.indexOf(id);
@@ -200,6 +201,23 @@
200
201
  // going away as a whole, where a leaf's cleanup order relative to the parent's
201
202
  // is Svelte's business and not something to depend on.
202
203
  span.onEnd(() => leaves.clear());
204
+
205
+ // The removal's one step back (`undo.svelte.ts`), published so an array's row removal
206
+ // offers on the same toast a card's does.
207
+ const undo = createStructuralUndo();
208
+ setStructuralUndo(undo);
209
+ span.onEnd(undo.dispose);
210
+ /** ⌘Z/Ctrl+Z takes the standing offer where the offer accepts it (`undo.accepts`).
211
+ * On the document, since a removal under the pointer leaves the focus on the body, and
212
+ * captured, so a leaf the removal handed the focus to hears the key after the offer. */
213
+ function onUndoKey(e: KeyboardEvent): void {
214
+ if (e.defaultPrevented || e.isComposing || e.shiftKey || e.altKey) return;
215
+ if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== 'z') return;
216
+ if (!undo.accepts(e.target, rootEl)) return;
217
+ e.preventDefault();
218
+ e.stopPropagation();
219
+ undo.take();
220
+ }
203
221
  // Card handles, for `setCaret`'s reveal hop: the one thing a leaf's own controller
204
222
  // cannot do, since which group is open is the card's state (Card §revealLeaf).
205
223
  type CardHandle = {
@@ -271,7 +289,7 @@
271
289
  // the one it already followed is the one its recompile re-locates.
272
290
  //
273
291
  // A focus clears it, and must: a focus into a leaf with no caret to report ends a
274
- // consumer's follow (PREVIEW §"Follow-the-caret scroll"), and the return to the
292
+ // consumer's follow (INVARIANTS §"Follow-the-caret scroll"), and the return to the
275
293
  // offset the memo still names is the only thing that would restart it.
276
294
  let lastCaretField: DocPath | undefined;
277
295
  let lastCaretPos: number | undefined;
@@ -333,11 +351,11 @@
333
351
  const keyStr = fieldKeyToString(key);
334
352
  try {
335
353
  if (value === undefined) {
336
- // The unset rung (VISUAL_EDITOR §"The commitment ladder"): removing the field
354
+ // The unset rung (INVARIANTS §"The commitment ladder"): removing the field
337
355
  // leaves Quillmark's authored › `default:` › blank-fill resolve to render the
338
- // default, where writing one bakes a snapshot the schema cannot track (canon
339
- // SCHEMAS.md: Quillmark never writes a default; the editor writes one only
340
- // as the edit that takes it). Removal writes no value, so there is
356
+ // default, where writing one bakes a snapshot the schema cannot track
357
+ // (quillmark/INVARIANTS §"The commitment ladder": Quillmark never writes a
358
+ // default; the editor writes one only as the edit that takes it). Removal writes no value, so there is
341
359
  // nothing for a schema to conform and the lane is the quill-free one.
342
360
  if (isMain) {
343
361
  doc.removeField(name);
@@ -420,7 +438,8 @@
420
438
  const card = quill.seedCard(kind, overlay);
421
439
  if (!card) return undefined;
422
440
  const from = document.activeElement;
423
- doc.insertCard(card, atIndex);
441
+ doc.unchecked.insertCard(card, atIndex);
442
+ undo.withdraw();
424
443
  const id = seq.next();
425
444
  arm.arm();
426
445
  cardIds = [...cardIds.slice(0, atIndex), id, ...cardIds.slice(atIndex)];
@@ -483,6 +502,7 @@
483
502
  if (to < 0 || to >= doc.cardCount) return;
484
503
  arm.arm();
485
504
  doc.moveCard(from, to);
505
+ undo.withdraw();
486
506
  const w = cardIds.slice();
487
507
  const [x] = w.splice(from, 1);
488
508
  w.splice(to, 0, x);
@@ -499,6 +519,12 @@
499
519
  // pressed button, and the hand-on is the keyboard's.
500
520
  const focused = document.activeElement;
501
521
  const held = !!focused && !!slotEls[i]?.contains(focused) && focused.matches(':focus-visible');
522
+ const card = doc.card(i);
523
+ const shown = model.cards[i];
524
+ const name =
525
+ shown?.titleOverride ||
526
+ shown?.titlePlaceholder ||
527
+ kindTitle(quill.schema.card_kinds?.[card.kind], card.kind);
502
528
  doc.removeCard(i);
503
529
  arm.arm();
504
530
  cardIds = cardIds.filter((_, k) => k !== i);
@@ -506,8 +532,35 @@
506
532
  // No addr: the removed card has none left and every survivor's shifted. The
507
533
  // stack changed, not a leaf, and the id is the only handle the removal leaves.
508
534
  bump('structure', id, undefined, { op: 'remove', at: i });
535
+ undo.offer(merged.undoRemoved(name), () => restoreCard(card, i));
509
536
  if (held) void focusAfterRemove(i);
510
537
  }
538
+ /** The removal's undo: the card back at the index it left, under a fresh session key
539
+ * (ids are never reused), with the focus on its title. The document holds what it held
540
+ * before the removal, so the insert is the removal's exact inverse. */
541
+ function restoreCard(card: ReturnType<typeof doc.card>, at: number): void {
542
+ if (!span.alive) return;
543
+ const i = Math.min(at, cardIds.length);
544
+ try {
545
+ doc.unchecked.insertCard(card, i);
546
+ } catch (e) {
547
+ reportError(onError, {
548
+ code: 'card-op-failed',
549
+ severity: 'error',
550
+ message: `restoring the ${card.kind} card failed: ${errorMessage(e)}`,
551
+ cause: e
552
+ });
553
+ return;
554
+ }
555
+ const id = seq.next();
556
+ arm.arm();
557
+ cardIds = [...cardIds.slice(0, i), id, ...cardIds.slice(i)];
558
+ bump('structure', id, i, { op: 'insert', at: i });
559
+ void (async () => {
560
+ if (!(await scrollCardIntoView(id, 'nearest'))) return;
561
+ cardRefs[cardIndexOf(id)]?.focusHeader();
562
+ })();
563
+ }
511
564
  /** Drop what the surface holds for a removed card. Ids are never reused, so an entry
512
565
  * keyed to the gone card is unreachable rather than mis-attributed to whichever card
513
566
  * takes this position: it needs dropping because nothing else will ever clear it. */
@@ -527,6 +580,7 @@
527
580
  if (!(await span.resumes(tick()))) return;
528
581
  if (cardIds.length) cardRefs[Math.max(at - 1, 0)]?.focusHeader();
529
582
  else rootEl?.querySelector<HTMLElement>('.qm-add-btn')?.focus();
583
+ undo.hand(document.activeElement);
530
584
  }
531
585
  function retypeCardById(id: string, kind: string): void {
532
586
  const i = cardIndexOf(id);
@@ -537,10 +591,11 @@
537
591
  // it validates the whole card before it mutates, so the document is as it was.
538
592
  const card = doc.card(i);
539
593
  doc.removeCard(i);
594
+ undo.withdraw();
540
595
  try {
541
- doc.insertCard({ ...card, kind }, i);
596
+ doc.unchecked.insertCard({ ...card, kind }, i);
542
597
  } catch (e) {
543
- doc.insertCard(card, i);
598
+ doc.unchecked.insertCard(card, i);
544
599
  throw e;
545
600
  }
546
601
  bump('structure', id, i);
@@ -593,10 +648,10 @@
593
648
  return cardAddr(id, field);
594
649
  }
595
650
 
596
- // ── Diagnostics routing (VISUAL_EDITOR §Diagnostics) ────────────────────────
651
+ // ── Diagnostics routing (INVARIANTS §Diagnostics) ────────────────────────
597
652
  // Producer #1: quill.validate(doc), re-run every revision.
598
653
  const validation = $derived.by(() => {
599
- revision; // re-run on every mutation, per VISUAL_EDITOR §Diagnostics
654
+ revision; // re-run on every mutation, per INVARIANTS §Diagnostics
600
655
  try {
601
656
  return quill.validate(doc);
602
657
  } catch (e) {
@@ -895,6 +950,7 @@
895
950
  * order it applied them, so every card that stays keeps its leaves. */
896
951
  export function applyCardOps(ops: readonly CardOp[]): void {
897
952
  if (!span.alive) return;
953
+ undo.withdraw();
898
954
  const ids = cardIds.slice();
899
955
  for (const op of ops) {
900
956
  if (op.op === 'insert') ids.splice(op.at, 0, seq.next());
@@ -932,7 +988,7 @@
932
988
  * row's cell as `main.vectors[0].tours[2].title`. The second rung reads the steps
933
989
  * past the field against the schema, rung by rung — an index under a declared
934
990
  * array, a key under a declared object, variant or matrix — which is why the ladder
935
- * is the editor's (VISUAL_EDITOR.md §Surface): the preview carries no schema, and
991
+ * is the editor's (INVARIANTS §Surface): the preview carries no schema, and
936
992
  * truncating the address there is worse than guessing, since `pos` is an offset
937
993
  * into the leaf's own content.
938
994
  */
@@ -964,6 +1020,8 @@
964
1020
  }
965
1021
  </script>
966
1022
 
1023
+ <svelte:document onkeydowncapture={onUndoKey} />
1024
+
967
1025
  <!-- The keydown is a control's, bubbled: the root resolves which description it raises. -->
968
1026
  <!-- svelte-ignore a11y_no_static_element_interactions -->
969
1027
  <div
@@ -996,7 +1054,7 @@
996
1054
 
997
1055
  <!-- A fixed slot after `main`, ahead of the cards, so document-level guidance
998
1056
  reads as document-level and never displaces a field. Dismissal empties the
999
- channel, so the card leaves for good (VISUAL_EDITOR §"Card operations"). -->
1057
+ channel, so the card leaves for good (INVARIANTS §"Card operations"). -->
1000
1058
  {#if model.tips.length}
1001
1059
  <TipsCard tips={model.tips} onDismiss={dismissTips} {onError} />
1002
1060
  {/if}
@@ -1028,6 +1086,29 @@
1028
1086
  {@render addAffordance(i + 1)}
1029
1087
  </div>
1030
1088
  {/each}
1089
+ <!-- The removal's undo. The region stands empty between offers so the notice it takes is
1090
+ announced: a live region inserted along with its text is one a reader may not hear. -->
1091
+ <div class="qm-toast-slot" role="status">
1092
+ {#if undo.current}
1093
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
1094
+ <!-- The handlers hold the lapse while the toast is in use and add no interaction. -->
1095
+ <div
1096
+ class="qm-toast"
1097
+ onpointerenter={() => undo.pause()}
1098
+ onpointerleave={() => undo.resume()}
1099
+ onfocusin={() => undo.pause()}
1100
+ onfocusout={() => undo.resume()}
1101
+ >
1102
+ <span class="qm-toast-notice">{undo.current.notice}</span>
1103
+ <button
1104
+ type="button"
1105
+ class="qm-toast-action qm-focus-ring"
1106
+ aria-keyshortcuts="Meta+Z Control+Z"
1107
+ onclick={() => undo.take()}>{merged.undoAction}</button
1108
+ >
1109
+ </div>
1110
+ {/if}
1111
+ </div>
1031
1112
  </div>
1032
1113
 
1033
1114
  <FormatPopover {getActiveLeaf} families={fontFamilies} {fontLabels} />
@@ -1099,6 +1180,47 @@
1099
1180
  {/snippet}
1100
1181
 
1101
1182
  <style>
1183
+ /* Pinned to the foot of whatever scrolls the surface, and taking no room in the stack:
1184
+ zero tall, its gap handed back, so an offer raises a toast over the cards without
1185
+ moving one. */
1186
+ .qm-toast-slot {
1187
+ position: sticky;
1188
+ bottom: var(--toast-foot, var(--_qm-space-3));
1189
+ z-index: 1;
1190
+ display: flex;
1191
+ justify-content: center;
1192
+ align-items: flex-end;
1193
+ height: 0;
1194
+ margin-top: calc(-1 * var(--_qm-space-2));
1195
+ pointer-events: none;
1196
+ }
1197
+ .qm-toast {
1198
+ display: flex;
1199
+ align-items: center;
1200
+ gap: var(--_qm-space-3);
1201
+ padding: var(--_qm-space) var(--_qm-space) var(--_qm-space) var(--_qm-space-3);
1202
+ border: var(--_qm-border-width) solid var(--_qm-border);
1203
+ border-radius: var(--_qm-radius-pill);
1204
+ background: var(--_qm-surface-raised);
1205
+ box-shadow: var(--_qm-lift);
1206
+ font-size: var(--_qm-text-label);
1207
+ color: var(--_qm-ink);
1208
+ pointer-events: auto;
1209
+ }
1210
+ .qm-toast-action {
1211
+ min-height: var(--_qm-tap-min);
1212
+ padding-inline: var(--_qm-space-2);
1213
+ border: 0;
1214
+ border-radius: var(--_qm-radius-pill);
1215
+ background: transparent;
1216
+ font: inherit;
1217
+ font-weight: var(--_qm-weight-strong);
1218
+ color: var(--_qm-accent);
1219
+ cursor: pointer;
1220
+ }
1221
+ .qm-toast-action:hover {
1222
+ background: var(--_qm-accent-tint);
1223
+ }
1102
1224
  /* A detached root, carrying `data-qm-root` for the derivation core/theme.css applies
1103
1225
  to one — the baseline font and colour included, so nothing here restates them.
1104
1226
 
@@ -1109,12 +1231,12 @@
1109
1231
 
1110
1232
  `:global(:where(…))` puts a promised class at zero rank, and both halves are
1111
1233
  load-bearing: `:global` drops the scoping class, `:where` drops the rest
1112
- (ARCHITECTURE §Styling). The class is the surface's root wherever it mounts, so
1234
+ (INVARIANTS §Styling). The class is the surface's root wherever it mounts, so
1113
1235
  leaving the component's scope costs nothing.
1114
1236
 
1115
1237
  The sunken rung, which is what makes a card an island: the cards are the base
1116
1238
  plane and this is the one they float on, so the gutter reads as ground rather
1117
- than as more card (ARCHITECTURE §Styling). The inset is the widest rung on the
1239
+ than as more card (INVARIANTS §Styling). The inset is the widest rung on the
1118
1240
  ramp, which is what gives the ground enough of itself to read as ground: at a
1119
1241
  narrower one the stack meets whatever frames the surface and the islands are
1120
1242
  back to being one block clipped at its edges. That is the page form; a pane's
@@ -1164,6 +1286,10 @@
1164
1286
  overscroll-behavior: contain;
1165
1287
  padding: var(--_qm-space-4);
1166
1288
  padding-block-end: var(--_qm-tail);
1289
+ /* The pane is the toast's scroller, and a sticky box stops at its scroller's
1290
+ padding: the tail would hold the toast a tail's height off the pane's foot. On a
1291
+ page the viewport scrolls, and the surface's padding is no bar. */
1292
+ --toast-foot: calc(var(--_qm-space-3) - var(--_qm-tail));
1167
1293
  }
1168
1294
  /* The stack's one gapless seam, which `TipsCard` draws and this holds the two
1169
1295
  blocks to. `main` has to paint over the tip: a later sibling paints over an earlier
@@ -1214,8 +1340,8 @@
1214
1340
  `.qm-tap-floor`'s (controls.css); what it overhangs is the card's own inset above and
1215
1341
  below, which holds no target, so the floor costs a neighbour nothing.
1216
1342
 
1217
- Ink is pinned to the label tone in every state, taking back the family's hover step:
1218
- the trigger arrives and leaves on opacity, and a tone moving under an opacity already
1343
+ A gap's ink is pinned to the label tone in every state, taking back the family's hover
1344
+ step: the trigger arrives and leaves on opacity, and a tone moving under an opacity already
1219
1345
  moving reads as two trips at different speeds.
1220
1346
 
1221
1347
  `:global`, because the multi-kind trigger is bits-ui's own element and a `class`
@@ -1233,13 +1359,22 @@
1233
1359
  opacity var(--_qm-duration-fast) var(--_qm-ease-reverse),
1234
1360
  background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
1235
1361
  }
1236
- /* The strip that holds words at rest takes the height that centres them, and rests dim
1237
- rather than absent, having something to be seen. */
1362
+ /* The append point is the one strip read at rest, so it is a pill sized to its words
1363
+ at the ink, outlined by the well's hairline rather than dashed: the document's main
1364
+ structural action stands as plainly as the controls inside a card. */
1365
+ .qm-add-card-marked {
1366
+ justify-content: center;
1367
+ }
1238
1368
  .qm-add-card-marked :global(.qm-add-btn) {
1369
+ width: auto;
1239
1370
  height: var(--_qm-tap-min);
1371
+ padding-inline: var(--_qm-space-3);
1240
1372
  font-size: var(--_qm-text-label);
1241
1373
  font-weight: var(--_qm-weight-mid);
1242
- opacity: var(--_qm-opacity-idle);
1374
+ color: var(--_qm-ink);
1375
+ background: var(--_qm-surface);
1376
+ box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-well-edge);
1377
+ opacity: 1;
1243
1378
  }
1244
1379
  /* One arrival, three ways in. Keyboard focus, because the fill is the only thing that
1245
1380
  reads as the trigger on a bare strip; and an open menu, because it portals out of
@@ -1,6 +1,6 @@
1
1
  import { type DocPath, type Landing } from '../core/address.js';
2
- import type { Delta } from '@quillmark/wasm';
3
2
  import type { VisualEditorProps } from './props.js';
3
+ import type { Delta } from '../core/codec/positions.js';
4
4
  import type { CardId, CardOp } from './signals.js';
5
5
  import { type ActiveProse } from './leaves.js';
6
6
  declare const VisualEditorInner: import("svelte").Component<VisualEditorProps, {
@@ -90,15 +90,25 @@
90
90
  color: var(--_qm-ink);
91
91
  caret-color: currentColor;
92
92
  }
93
- /* The box is a fill and not an edge (ARCHITECTURE §Styling), and the fill is the
94
- well rung: a field is a hole cut into the card rather than a plane of its own,
95
- and with no edge to carry it the step is the whole of what says so. */
93
+ /* The box is the well rung with a hairline inside it (INVARIANTS §Styling): a
94
+ field is a hole cut into the card, and the edge is what finds it at a glance, the
95
+ fill alone standing too close to the card to. Inset, so the edge costs no layout
96
+ and a focus ring draws outside it. */
96
97
  :where(.qm-control-box),
97
98
  :where(.qm-input) {
98
99
  padding: var(--_qm-inset-control);
99
100
  border: none;
100
101
  border-radius: var(--_qm-radius-inner);
101
102
  background: var(--_qm-surface-well);
103
+ box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-well-edge);
104
+ }
105
+ /* A control with an error drawn under it takes the danger hue on its edge and in its
106
+ fill, so the field the message is about is the one that changed. The message stays
107
+ beside it: colour is never the whole of the state. */
108
+ :where(.qm-field-stack:has(> .qm-diag-list) .qm-control-box),
109
+ :where(.qm-prop-stack:has(> .qm-diag-list) .qm-control-box) {
110
+ box-shadow: inset 0 0 0 var(--_qm-ring-width) var(--_qm-danger);
111
+ background-image: linear-gradient(var(--_qm-danger-tint), var(--_qm-danger-tint));
102
112
  }
103
113
  /* What a form control adds over the box: it does not fill its row on its own. */
104
114
  :where(.qm-input) {
@@ -296,21 +306,30 @@
296
306
  of one takes (`--cols-half`) land on a track boundary. A field ends on its track's
297
307
  own edge, so a rung is `n * 220px + gaps`. A subform three rungs in stands three
298
308
  `--_qm-nest` and three verticals narrower than its section, and steps down where the
299
- section does not: the count is the width the tracks actually get. */
309
+ section does not: the count is the width the tracks actually get.
310
+
311
+ The two tails are where a run's last cell takes the row (`RunTail`, `placeFields`): the
312
+ placement a capacity leaves it alone in, so it spans there and shares a row elsewhere. */
300
313
  :where(.qm-tracks) {
301
314
  --cols: 1;
302
315
  --cols-half: 1;
316
+ --tail-odd: span 1;
317
+ --tail-lone: span 1;
303
318
  }
304
319
  @container (min-width: 28rem) {
305
320
  :where(.qm-tracks) {
306
321
  --cols: 2;
307
322
  --cols-half: 1;
323
+ --tail-odd: 1 / -1;
324
+ --tail-lone: 1 / -1;
308
325
  }
309
326
  }
310
327
  @container (min-width: 57rem) {
311
328
  :where(.qm-tracks) {
312
329
  --cols: 4;
313
330
  --cols-half: 2;
331
+ --tail-odd: span 1;
332
+ --tail-lone: 1 / -1;
314
333
  }
315
334
  }
316
335
 
@@ -337,7 +356,7 @@
337
356
 
338
357
  A floating surface is the one place a hairline is still load-bearing: it hangs
339
358
  over content the surface did not choose, so there is no plane under it for a
340
- tone to step off (ARCHITECTURE §Styling). The edge and `--_qm-lift` carry it
359
+ tone to step off (INVARIANTS §Styling). The edge and `--_qm-lift` carry it
341
360
  there, and the raised rung joins them in dark, where a tone still has somewhere
342
361
  to go.
343
362
 
@@ -420,3 +439,22 @@
420
439
  transform: scale(0.94);
421
440
  }
422
441
  }
442
+
443
+ /* Forced colours drop every fill and shadow, which is every edge a field and a chip
444
+ draw here, and keep opacity, which would leave a resting control a ghost against a
445
+ system palette. The system's own strokes stand in for both. */
446
+ @media (forced-colors: active) {
447
+ :where(.qm-control-box),
448
+ :where(.qm-input) {
449
+ border: var(--_qm-border-width) solid CanvasText;
450
+ }
451
+ :where(.qm-chip),
452
+ :where(.qm-add-affordance) {
453
+ border: var(--_qm-border-width) solid ButtonText;
454
+ }
455
+ :where(.qm-icon-btn),
456
+ :where(.qm-add-affordance),
457
+ :where(.qm-chip) {
458
+ opacity: 1;
459
+ }
460
+ }
@@ -16,7 +16,7 @@ export declare function fieldKeyToString(k: FieldKey): string;
16
16
  * Resolve a positional `FieldKey` (an absolute document-array index, straight off
17
17
  * `addrForFieldPath`) to the editor's stable-id keying using the live `cardIds`
18
18
  * array: re-resolved fresh on every call (never cached), the same "resolve only
19
- * at the point of use" discipline `cardIndexOf` applies to writes (VISUAL_EDITOR
19
+ * at the point of use" discipline `cardIndexOf` applies to writes (INVARIANTS
20
20
  * §"The address is the spine"). A key already id-keyed (`card` a string) or main
21
21
  * (`card` undefined) passes through unchanged. `undefined` when the index is out
22
22
  * of the current card array: the diagnostic is dropped rather than mis-routed.
@@ -31,7 +31,7 @@ export interface RoutedDiagnostic {
31
31
  * Route a path-keyed producer's raw `Diagnostic[]` (validate / external) to the
32
32
  * editor's stable-id keying: the one door producers #1/#3 take,
33
33
  * `nearestAddrForFieldPath` and `resolveCardKey` in a single pass. Warnings do not
34
- * draw (VISUAL_EDITOR §Diagnostics): obligation, completeness, a render note — none
34
+ * draw (INVARIANTS §Diagnostics): obligation, completeness, a render note — none
35
35
  * of them is a value the field cannot hold. An anchor deeper than a commit address
36
36
  * (`main.contact.email`, `main.keywords[0]`) draws at the nearest field holding it,
37
37
  * whose subform or repeater draws that leaf. An entry drops rather than mis-routes
@@ -7,7 +7,7 @@ export function fieldKeyToString(k) {
7
7
  * Resolve a positional `FieldKey` (an absolute document-array index, straight off
8
8
  * `addrForFieldPath`) to the editor's stable-id keying using the live `cardIds`
9
9
  * array: re-resolved fresh on every call (never cached), the same "resolve only
10
- * at the point of use" discipline `cardIndexOf` applies to writes (VISUAL_EDITOR
10
+ * at the point of use" discipline `cardIndexOf` applies to writes (INVARIANTS
11
11
  * §"The address is the spine"). A key already id-keyed (`card` a string) or main
12
12
  * (`card` undefined) passes through unchanged. `undefined` when the index is out
13
13
  * of the current card array: the diagnostic is dropped rather than mis-routed.
@@ -22,7 +22,7 @@ export function resolveCardKey(key, cardIds) {
22
22
  * Route a path-keyed producer's raw `Diagnostic[]` (validate / external) to the
23
23
  * editor's stable-id keying: the one door producers #1/#3 take,
24
24
  * `nearestAddrForFieldPath` and `resolveCardKey` in a single pass. Warnings do not
25
- * draw (VISUAL_EDITOR §Diagnostics): obligation, completeness, a render note — none
25
+ * draw (INVARIANTS §Diagnostics): obligation, completeness, a render note — none
26
26
  * of them is a value the field cannot hold. An anchor deeper than a commit address
27
27
  * (`main.contact.email`, `main.keywords[0]`) draws at the nearest field holding it,
28
28
  * whose subform or repeater draws that leaf. An entry drops rather than mis-routes
@@ -5,5 +5,7 @@ export type { CreateFieldOpts, FieldController } from '../core/codec/index.js';
5
5
  export { DEFAULT_VISUAL_STRINGS } from './strings.js';
6
6
  export type { VisualStrings, VisualStringsInput, FormatDiagnostic } from './strings.js';
7
7
  export type { BodyPlaceholder, BodyPlaceholderContext } from './structure.js';
8
+ export { editorShortcuts } from '../core/codec/index.js';
9
+ export type { EditorShortcut, ShortcutScope } from '../core/codec/index.js';
8
10
  export { patchEditorExt } from './ext.js';
9
11
  export type { ActiveLeaf, CardId, CardOp, ChangeSource, EditorChange } from './signals.js';
@@ -22,6 +22,9 @@ export { createField } from '../core/codec/index.js';
22
22
  // that English, exported so a consumer can compose against it rather than restate
23
23
  // it. The empty body's per-card hook is the `bodyPlaceholder` key inside it.
24
24
  export { DEFAULT_VISUAL_STRINGS } from './strings.js';
25
+ // The prose leaf's shortcuts, for a host's shortcut list: read off the keymaps' own tables and
26
+ // worded by the same `strings` (pass the editor's, or none for the package's English).
27
+ export { editorShortcuts } from '../core/codec/index.js';
25
28
  // The `$ext.editor` write unit. A consumer seeding editor-side chrome
26
29
  // state (a card title, the tips channel) goes through this rather than `storeExt`,
27
30
  // which replaces the whole map and takes every sibling with it.
@@ -1,5 +1,5 @@
1
1
  // The leaf registry: what a landing verb resolves a `DocPath` to, and the seam the
2
- // mounted tree registers itself into (VISUAL_EDITOR §"Focus and the preview bridge").
2
+ // mounted tree registers itself into (INVARIANTS §"Focus and the preview bridge").
3
3
  //
4
4
  // Two lanes behind one lookup. Every mounted field registers a {@link FieldControl} —
5
5
  // take the caret, and a box to bloom — which is the whole of what a reveal and a