@quillmark/svelte 0.27.0 → 0.29.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 (105) hide show
  1. package/NOTICE +4 -4
  2. package/README.md +26 -8
  3. package/THEMING.md +10 -8
  4. package/dist/core/address.d.ts +35 -64
  5. package/dist/core/address.js +35 -55
  6. package/dist/core/bloom.d.ts +4 -10
  7. package/dist/core/bloom.js +14 -27
  8. package/dist/core/codec/blocks.d.ts +41 -43
  9. package/dist/core/codec/blocks.js +97 -130
  10. package/dist/core/codec/cap.js +2 -1
  11. package/dist/core/codec/code.d.ts +7 -10
  12. package/dist/core/codec/code.js +37 -46
  13. package/dist/core/codec/decode.d.ts +19 -23
  14. package/dist/core/codec/decode.js +76 -111
  15. package/dist/core/codec/encode.d.ts +11 -15
  16. package/dist/core/codec/encode.js +60 -67
  17. package/dist/core/codec/field.d.ts +70 -99
  18. package/dist/core/codec/field.js +159 -180
  19. package/dist/core/codec/islands.d.ts +33 -41
  20. package/dist/core/codec/islands.js +76 -86
  21. package/dist/core/codec/lists.d.ts +17 -26
  22. package/dist/core/codec/lists.js +117 -157
  23. package/dist/core/codec/marks.d.ts +4 -3
  24. package/dist/core/codec/marks.js +8 -3
  25. package/dist/core/codec/nesting.js +2 -1
  26. package/dist/core/codec/prose.css +84 -46
  27. package/dist/core/codec/remote.d.ts +3 -0
  28. package/dist/core/codec/remote.js +7 -0
  29. package/dist/core/codec/schema.d.ts +18 -23
  30. package/dist/core/codec/schema.js +84 -76
  31. package/dist/core/codec/slash.d.ts +42 -48
  32. package/dist/core/codec/slash.js +0 -0
  33. package/dist/core/codec/table-copy.d.ts +4 -3
  34. package/dist/core/codec/table-copy.js +25 -7
  35. package/dist/core/codec/table-view.d.ts +12 -12
  36. package/dist/core/codec/table-view.js +460 -383
  37. package/dist/core/codec/table.d.ts +94 -61
  38. package/dist/core/codec/table.js +331 -83
  39. package/dist/core/codec/tasks.d.ts +6 -0
  40. package/dist/core/codec/tasks.js +30 -3
  41. package/dist/core/codec/undo.js +5 -1
  42. package/dist/core/errors.d.ts +15 -30
  43. package/dist/core/errors.js +2 -6
  44. package/dist/core/index.js +7 -12
  45. package/dist/core/lifecycle.d.ts +7 -16
  46. package/dist/core/lifecycle.js +10 -21
  47. package/dist/core/rebind.svelte.d.ts +10 -20
  48. package/dist/core/rebind.svelte.js +15 -27
  49. package/dist/core/rungs.d.ts +14 -11
  50. package/dist/core/rungs.js +17 -19
  51. package/dist/core/teardown.d.ts +4 -6
  52. package/dist/core/teardown.js +7 -10
  53. package/dist/core/theme.css +74 -54
  54. package/dist/index.js +3 -8
  55. package/dist/preset/app.css +3 -1
  56. package/dist/preset/index.css +6 -8
  57. package/dist/preset/recipes.css +12 -15
  58. package/dist/preset/scale.css +18 -17
  59. package/dist/preset/shell.css +10 -0
  60. package/dist/preview/bridge.d.ts +18 -22
  61. package/dist/preview/bridge.js +29 -58
  62. package/dist/preview/controller.d.ts +21 -29
  63. package/dist/preview/controller.js +14 -39
  64. package/dist/preview/geometry.d.ts +13 -34
  65. package/dist/preview/geometry.js +13 -34
  66. package/dist/preview/index.js +4 -16
  67. package/dist/preview/paint.d.ts +3 -3
  68. package/dist/preview/paint.js +28 -68
  69. package/dist/preview/strings.d.ts +1 -1
  70. package/dist/preview/strings.js +2 -14
  71. package/dist/preview/zoom.d.ts +18 -23
  72. package/dist/preview/zoom.js +28 -27
  73. package/dist/visual/ArrayField.svelte +77 -16
  74. package/dist/visual/BooleanField.svelte +27 -14
  75. package/dist/visual/Card.svelte +61 -48
  76. package/dist/visual/CardControls.svelte +5 -11
  77. package/dist/visual/DateField.svelte +20 -4
  78. package/dist/visual/EnumField.svelte +3 -0
  79. package/dist/visual/FieldHint.svelte +2 -1
  80. package/dist/visual/FormatPopover.svelte +82 -15
  81. package/dist/visual/FormatPopover.svelte.d.ts +4 -0
  82. package/dist/visual/MatrixAdd.svelte +30 -12
  83. package/dist/visual/MatrixField.svelte +24 -16
  84. package/dist/visual/NumberField.svelte +7 -0
  85. package/dist/visual/ObjectField.svelte +4 -4
  86. package/dist/visual/ProseField.svelte +0 -5
  87. package/dist/visual/TipsCard.svelte +11 -10
  88. package/dist/visual/VariantField.svelte +3 -1
  89. package/dist/visual/VisualEditor.svelte +15 -1
  90. package/dist/visual/VisualEditor.svelte.d.ts +5 -1
  91. package/dist/visual/VisualEditorInner.svelte +72 -17
  92. package/dist/visual/VisualEditorInner.svelte.d.ts +5 -1
  93. package/dist/visual/controls.css +7 -2
  94. package/dist/visual/fonts.d.ts +18 -0
  95. package/dist/visual/fonts.js +59 -0
  96. package/dist/visual/icons/nodes.d.ts +0 -5
  97. package/dist/visual/icons/nodes.js +0 -4
  98. package/dist/visual/index.d.ts +1 -1
  99. package/dist/visual/props.d.ts +14 -1
  100. package/dist/visual/signals.d.ts +19 -5
  101. package/dist/visual/strings.d.ts +7 -0
  102. package/dist/visual/strings.js +5 -2
  103. package/dist/visual/structure.d.ts +43 -87
  104. package/dist/visual/structure.js +42 -83
  105. package/package.json +2 -2
@@ -37,6 +37,7 @@
37
37
  import type {
38
38
  Addr,
39
39
  CardAddr,
40
+ Delta,
40
41
  Diagnostic,
41
42
  PathStep,
42
43
  PayloadItem,
@@ -46,7 +47,7 @@
46
47
  } from '@quillmark/wasm';
47
48
  import type { VisualEditorProps } from './props.js';
48
49
  import { mergeStrings, setWording } from './strings.js';
49
- import type { CardId, ChangeSource } from './signals.js';
50
+ import type { CardId, CardOp, ChangeSource } from './signals.js';
50
51
  import type { FieldController, LeafViews } from '../core/codec/index.js';
51
52
  import {
52
53
  IdSeq,
@@ -82,6 +83,7 @@
82
83
  import { tipsChannel } from './tips.js';
83
84
  import { patchEditorExt } from './ext.js';
84
85
  import { raiseGuidance } from './guidance.js';
86
+ import { familiesOf, registerFaces } from './fonts.js';
85
87
  import Card from './Card.svelte';
86
88
  import Icon from './icons/Icon.svelte';
87
89
  import TipsCard from './TipsCard.svelte';
@@ -100,6 +102,8 @@
100
102
  diagnostics,
101
103
  enumOptionAllowed,
102
104
  enumDisallowed = 'disable',
105
+ fonts,
106
+ fontLabels,
103
107
  strings,
104
108
  formatDiagnostic,
105
109
  class: className,
@@ -119,6 +123,11 @@
119
123
  }
120
124
  });
121
125
 
126
+ // The host's font library: registered with the page while mounted, so a run draws in
127
+ // the face the preview sets it in, and offered family by family to the popover.
128
+ const fontFamilies = $derived(familiesOf(fonts ?? []));
129
+ $effect(() => registerFaces(fonts ?? []));
130
+
122
131
  // ── Reactivity + session identity ───────────────────────────────────────────
123
132
  let revision = $state(0);
124
133
  // This editor's own id, prefixed onto every field's DOM ids (`domid.ts`). The
@@ -149,12 +158,15 @@
149
158
  * addressable against the tree the bump re-derived: an insert's card does not exist
150
159
  * in the previous one, and a retype's kind is the previous kind.
151
160
  */
152
- function bump(source: ChangeSource, cardId?: CardId, at?: Addr | number): void {
153
- revision++;
154
- liveTitles = {};
161
+ function bump(source: ChangeSource, cardId?: CardId, at?: Addr | number, op?: CardOp): void {
162
+ rederive();
155
163
  const path =
156
164
  at == null ? undefined : typeof at === 'number' ? cardPath(at, liveKinds()) : pathFor(at);
157
- onChange?.({ source, cardId, path });
165
+ onChange?.({ source, cardId, path, ...(op ? { op } : {}) });
166
+ }
167
+ function rederive(): void {
168
+ revision++;
169
+ liveTitles = {};
158
170
  }
159
171
  /** Read at the mutation boundary, never cached (VISUAL_EDITOR §"The address is the
160
172
  * spine"). */
@@ -412,7 +424,7 @@
412
424
  const id = seq.next();
413
425
  arm.arm();
414
426
  cardIds = [...cardIds.slice(0, atIndex), id, ...cardIds.slice(atIndex)];
415
- bump('structure', id, atIndex);
427
+ bump('structure', id, atIndex, { op: 'insert', at: atIndex });
416
428
  // Centred: the new card is the subject, and the neighbours it landed between
417
429
  // are what say where it went.
418
430
  const scrolled = scrollCardIntoView(id, 'center');
@@ -475,7 +487,7 @@
475
487
  const [x] = w.splice(from, 1);
476
488
  w.splice(to, 0, x);
477
489
  cardIds = w;
478
- bump('structure', id, to);
490
+ bump('structure', id, to, { op: 'move', from, to });
479
491
  // `nearest`: the card was already in view and only needs to stay there, so one
480
492
  // that never left the viewport moves it not at all.
481
493
  void scrollCardIntoView(id, 'nearest');
@@ -490,20 +502,23 @@
490
502
  doc.removeCard(i);
491
503
  arm.arm();
492
504
  cardIds = cardIds.filter((_, k) => k !== i);
505
+ forget(id);
506
+ // No addr: the removed card has none left and every survivor's shifted. The
507
+ // stack changed, not a leaf, and the id is the only handle the removal leaves.
508
+ bump('structure', id, undefined, { op: 'remove', at: i });
509
+ if (held) void focusAfterRemove(i);
510
+ }
511
+ /** Drop what the surface holds for a removed card. Ids are never reused, so an entry
512
+ * keyed to the gone card is unreachable rather than mis-attributed to whichever card
513
+ * takes this position: it needs dropping because nothing else will ever clear it. */
514
+ function forget(id: CardId): void {
493
515
  if (activeCardId === id) {
494
516
  activeCardId = undefined;
495
517
  activeAddr = undefined;
496
518
  }
497
- // Ids are never reused, so an entry keyed to the gone card is unreachable rather
498
- // than mis-attributed to whichever card takes this position: it needs dropping
499
- // because nothing else will ever clear it.
500
519
  const prefix = `${id}:`;
501
520
  const stale = [...commitErrors.keys()].filter((k) => k.startsWith(prefix));
502
521
  for (const k of stale) commitErrors.delete(k);
503
- // No addr: the removed card has none left and every survivor's shifted. The
504
- // stack changed, not a leaf, and the id is the only handle the removal leaves.
505
- bump('structure', id);
506
- if (held) void focusAfterRemove(i);
507
522
  }
508
523
  /** Hand the focus a removed card held to the title of the card before it, else the
509
524
  * one that took its place, else the strip that adds one: a focused node the flush
@@ -841,6 +856,38 @@
841
856
  retypeCardById(cardId, kind);
842
857
  }
843
858
 
859
+ // ── Changes the host made ───────────────────────────────────────────────────
860
+ // A live session writes another client's edits into the document itself and then
861
+ // says what it moved. The surface re-reads, keeps every mounted leaf and caret it can,
862
+ // and reports none of it through `onChange`: the edit is not this surface's.
863
+
864
+ /** Re-read the prose leaf at `field` from the document, landing the difference as one
865
+ * step outside its undo history; `delta`, the change's text delta over what the leaf
866
+ * held, carries the caret. */
867
+ export function applyExternal(field: DocPath, delta?: Delta): void {
868
+ if (!span.alive) return;
869
+ const target = leafTargetFor(field);
870
+ if (target && !target.steps) leaves.prose(target.key)?.applyExternal(delta);
871
+ rederive();
872
+ }
873
+ /** Re-read the cards' kinds, titles and form fields from the document. */
874
+ export function refresh(): void {
875
+ if (span.alive) rederive();
876
+ }
877
+ /** Move the card keys in step with card-list changes the document already holds, in the
878
+ * order it applied them, so every card that stays keeps its leaves. */
879
+ export function applyCardOps(ops: readonly CardOp[]): void {
880
+ if (!span.alive) return;
881
+ const ids = cardIds.slice();
882
+ for (const op of ops) {
883
+ if (op.op === 'insert') ids.splice(op.at, 0, seq.next());
884
+ else if (op.op === 'remove') forget(ids.splice(op.at, 1)[0]);
885
+ else ids.splice(op.to, 0, ...ids.splice(op.from, 1));
886
+ }
887
+ cardIds = ids;
888
+ rederive();
889
+ }
890
+
844
891
  function holds(cardId: CardId): boolean {
845
892
  if (cardIndexOf(cardId) >= 0) return true;
846
893
  missed(`no card ${cardId} in this session`);
@@ -966,7 +1013,7 @@
966
1013
  {/each}
967
1014
  </div>
968
1015
 
969
- <FormatPopover {getActiveLeaf} />
1016
+ <FormatPopover {getActiveLeaf} families={fontFamilies} {fontLabels} />
970
1017
 
971
1018
  <!-- The add affordance is gated on the schema declaring `card_kinds`, there being
972
1019
  nothing to seed otherwise. Cards render regardless: a kind with no schema degrades to
@@ -1057,7 +1104,8 @@
1057
1104
  than as more card (ARCHITECTURE §Styling). The inset is the widest rung on the
1058
1105
  ramp, which is what gives the ground enough of itself to read as ground: at a
1059
1106
  narrower one the stack meets whatever frames the surface and the islands are
1060
- back to being one block clipped at its edges. */
1107
+ back to being one block clipped at its edges. That is the page form; a pane's
1108
+ frame is the host's, and it spends less (`.qm-pane` below). */
1061
1109
  :global(:where(.qm-editor)) {
1062
1110
  box-sizing: border-box;
1063
1111
  display: flex;
@@ -1090,11 +1138,18 @@
1090
1138
  `.qm-pane` claims (THEMING §"Drop it in"), and it resolves to `auto` on a mounting
1091
1139
  site with no height of its own, which is the page form kept. The cards do not
1092
1140
  shrink to fit: a flex item's automatic minimum floors each at its own height, so
1093
- the stack overflows and scrolls rather than squashing. */
1141
+ the stack overflows and scrolls rather than squashing.
1142
+
1143
+ A pane is where the host has already framed the surface, so the ground needs less
1144
+ of itself to read as ground: the frame is what the stack would otherwise meet. So
1145
+ the gutter steps in to the seam the add strip holds between cards, the ground
1146
+ being one width all round the stack, and the width it gives back goes to what is
1147
+ written. */
1094
1148
  :global(:where(.qm-editor.qm-pane)) {
1095
1149
  height: 100%;
1096
1150
  overflow: auto;
1097
1151
  overscroll-behavior: contain;
1152
+ padding: var(--_qm-space-4);
1098
1153
  padding-block-end: var(--_qm-tail);
1099
1154
  }
1100
1155
  /* The stack's one gapless seam, which `TipsCard` draws and this holds the two
@@ -1,6 +1,7 @@
1
1
  import { type DocPath, type Landing } from '../core/address.js';
2
+ import type { Delta } from '@quillmark/wasm';
2
3
  import type { VisualEditorProps } from './props.js';
3
- import type { CardId } from './signals.js';
4
+ import type { CardId, CardOp } from './signals.js';
4
5
  import { type ActiveProse } from './leaves.js';
5
6
  declare const VisualEditorInner: import("svelte").Component<VisualEditorProps, {
6
7
  setCaret: (at: Landing) => Promise<void>;
@@ -10,6 +11,9 @@ declare const VisualEditorInner: import("svelte").Component<VisualEditorProps, {
10
11
  removeCard: (cardId: CardId) => void;
11
12
  moveCard: (cardId: CardId, dir: -1 | 1) => void;
12
13
  setKind: (cardId: CardId, kind: string) => void;
14
+ applyExternal: (field: DocPath, delta?: Delta) => void;
15
+ refresh: () => void;
16
+ applyCardOps: (ops: readonly CardOp[]) => void;
13
17
  }, "">;
14
18
  type VisualEditorInner = ReturnType<typeof VisualEditorInner>;
15
19
  export default VisualEditorInner;
@@ -339,9 +339,14 @@
339
339
  over content the surface did not choose, so there is no plane under it for a
340
340
  tone to step off (ARCHITECTURE §Styling). The edge and `--_qm-lift` carry it
341
341
  there, and the raised rung joins them in dark, where a tone still has somewhere
342
- to go. */
342
+ to go.
343
+
344
+ The inset is the difference between the two radii, `--_qm-space` between the
345
+ surface's `--_qm-radius` and the item's `--_qm-radius-inner`, so a highlighted
346
+ item's corners run concentric with the surface's. It is the format popover's inset
347
+ too: every floating surface holds its contents one rung in. */
343
348
  :where(.qm-menu-surface) {
344
- padding: var(--_qm-space-half);
349
+ padding: var(--_qm-space);
345
350
  border: var(--_qm-border-width) solid var(--_qm-border);
346
351
  border-radius: var(--_qm-radius);
347
352
  background: var(--_qm-surface-raised);
@@ -0,0 +1,18 @@
1
+ import type { FontFace as LibraryFace } from '@quillmark/wasm';
2
+ import type { Command, EditorState } from 'prosemirror-state';
3
+ /** The families `faces` offer, each once, in the library's order. */
4
+ export declare function familiesOf(faces: readonly LibraryFace[]): string[];
5
+ /**
6
+ * Register `faces` with `set` and return what takes them back out. A face past the
7
+ * first in a collection is left out, a CSS face drawing a collection's first alone, so
8
+ * its family draws in the root face here while the preview sets it. A face the browser
9
+ * refuses draws the same way, and a page with no Font Loading API registers nothing.
10
+ */
11
+ export declare function registerFaces(faces: readonly LibraryFace[], set?: FontFaceSet | undefined): () => void;
12
+ /**
13
+ * The family the selection's text is set in: its name, `''` where it sets none, `null`
14
+ * where it sets more than one or holds no text.
15
+ */
16
+ export declare function familyInSelection(state: EditorState): string | null;
17
+ /** Set the selection in `name`, or in the surrounding face where `name` is `''`. */
18
+ export declare function setFamily(name: string): Command;
@@ -0,0 +1,59 @@
1
+ /** The families `faces` offer, each once, in the library's order. */
2
+ export function familiesOf(faces) {
3
+ return [...new Set(faces.map((face) => face.family))];
4
+ }
5
+ /**
6
+ * Register `faces` with `set` and return what takes them back out. A face past the
7
+ * first in a collection is left out, a CSS face drawing a collection's first alone, so
8
+ * its family draws in the root face here while the preview sets it. A face the browser
9
+ * refuses draws the same way, and a page with no Font Loading API registers nothing.
10
+ */
11
+ export function registerFaces(faces, set = globalThis.document?.fonts) {
12
+ if (!set || typeof FontFace === 'undefined')
13
+ return () => { };
14
+ const added = [];
15
+ for (const face of faces) {
16
+ if (face.index !== 0)
17
+ continue;
18
+ const css = new FontFace(face.family, face.data, {
19
+ weight: String(face.weight),
20
+ style: face.style
21
+ });
22
+ css.loaded.catch(() => set.delete(css));
23
+ set.add(css);
24
+ added.push(css);
25
+ }
26
+ return () => {
27
+ for (const css of added)
28
+ set.delete(css);
29
+ };
30
+ }
31
+ /**
32
+ * The family the selection's text is set in: its name, `''` where it sets none, `null`
33
+ * where it sets more than one or holds no text.
34
+ */
35
+ export function familyInSelection(state) {
36
+ const type = state.schema.marks.font_family;
37
+ const { from, to } = state.selection;
38
+ const seen = new Set();
39
+ state.doc.nodesBetween(from, to, (node) => {
40
+ if (!node.isText)
41
+ return;
42
+ seen.add(type ? String(type.isInSet(node.marks)?.attrs.name ?? '') : '');
43
+ });
44
+ return seen.size === 1 ? [...seen][0] : null;
45
+ }
46
+ /** Set the selection in `name`, or in the surrounding face where `name` is `''`. */
47
+ export function setFamily(name) {
48
+ return (state, dispatch) => {
49
+ const type = state.schema.marks.font_family;
50
+ const { from, to, empty } = state.selection;
51
+ if (!type || empty)
52
+ return false;
53
+ if (dispatch) {
54
+ const tr = state.tr.removeMark(from, to, type);
55
+ dispatch(name ? tr.addMark(from, to, type.create({ name })) : tr);
56
+ }
57
+ return true;
58
+ };
59
+ }
@@ -127,11 +127,6 @@ export declare const ICONS: {
127
127
  }], readonly ["path", {
128
128
  readonly d: "M12 5v14";
129
129
  }]];
130
- readonly x: readonly [readonly ["path", {
131
- readonly d: "M18 6 6 18";
132
- }], readonly ["path", {
133
- readonly d: "m6 6 12 12";
134
- }]];
135
130
  readonly 'trash-2': readonly [readonly ["path", {
136
131
  readonly d: "M10 11v6";
137
132
  }], readonly ["path", {
@@ -70,10 +70,6 @@ export const ICONS = {
70
70
  ['path', { d: 'M5 12h14' }],
71
71
  ['path', { d: 'M12 5v14' }]
72
72
  ],
73
- x: [
74
- ['path', { d: 'M18 6 6 18' }],
75
- ['path', { d: 'm6 6 12 12' }]
76
- ],
77
73
  'trash-2': [
78
74
  ['path', { d: 'M10 11v6' }],
79
75
  ['path', { d: 'M14 11v6' }],
@@ -6,4 +6,4 @@ 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
8
  export { patchEditorExt } from './ext.js';
9
- export type { ActiveLeaf, CardId, ChangeSource, EditorChange } from './signals.js';
9
+ export type { ActiveLeaf, CardId, CardOp, ChangeSource, EditorChange } from './signals.js';
@@ -1,4 +1,4 @@
1
- import type { Document, Quill, Addr, Diagnostic } from '@quillmark/wasm';
1
+ import type { Document, Quill, Addr, Diagnostic, FontFace } from '@quillmark/wasm';
2
2
  import type { Place } from '../core/address.js';
3
3
  import type { EditorErrorHandler } from '../core/errors.js';
4
4
  import type { ActiveLeaf, EditorChange } from './signals.js';
@@ -81,6 +81,19 @@ export interface VisualEditorProps {
81
81
  * (VISUAL_EDITOR §"Enum policy").
82
82
  */
83
83
  enumDisallowed?: 'hide' | 'disable';
84
+ /**
85
+ * The faces a `font_family` mark may set: `await engine.fontFaces(quill)`, over an
86
+ * engine built with the host's `fonts`. The format popover offers each family, and
87
+ * the editor registers each face with the page for as long as it is mounted, so a
88
+ * run draws in the face the preview sets it in. Absent or empty, no family is
89
+ * offered, and a family the document already sets still edits and can be cleared.
90
+ */
91
+ fonts?: FontFace[];
92
+ /**
93
+ * The name the picker shows for a family, keyed by the family the mark saves. A
94
+ * family missing here shows as itself.
95
+ */
96
+ fontLabels?: Readonly<Record<string, string>>;
84
97
  /**
85
98
  * Every word the surface says, keyed and partial: unset keys take the package's
86
99
  * English. Several are accessible names rather than decoration, so this is what
@@ -24,13 +24,24 @@ export type ChangeSource =
24
24
  * carries no card handle): it is minted at mount and dies with the surface, so it
25
25
  * does not survive a reload and a host persisting one is persisting a session key.
26
26
  *
27
- * The editor owns structural mutation for the session. The keys track the inserts,
28
- * moves and removals the editor performs; a host that mutates the card array behind
29
- * it (its own `doc.insertCard`) desyncs them, and the answer is to re-seed the
30
- * surface rather than expect the keys to follow. There is nothing document-side to
31
- * reconcile against, so this is a contract rather than a mechanism.
27
+ * The keys track the inserts, moves and removals the editor performs, and the ones a
28
+ * host reports through `applyCardOps` after making them itself (a live session's
29
+ * remote edits). A host that mutates the card array behind the editor and reports
30
+ * nothing desyncs them: there is nothing document-side to reconcile against.
32
31
  */
33
32
  export type CardId = string;
33
+ /** A change to the composable card list, by index, as the document applied it. */
34
+ export type CardOp = {
35
+ op: 'insert';
36
+ at: number;
37
+ } | {
38
+ op: 'remove';
39
+ at: number;
40
+ } | {
41
+ op: 'move';
42
+ from: number;
43
+ to: number;
44
+ };
34
45
  /** An edit that landed on the document, and which lane it came down. */
35
46
  export interface EditorChange {
36
47
  source: ChangeSource;
@@ -49,6 +60,9 @@ export interface EditorChange {
49
60
  * dismissal, which is document-level chrome and names no card.
50
61
  */
51
62
  cardId?: CardId;
63
+ /** The card-list change a structure op made: an add, a move or a removal. A retype
64
+ * and a rename leave the list as it was and carry none. */
65
+ op?: CardOp;
52
66
  }
53
67
  /** The leaf that has focus: where it sits, and which card holds it. */
54
68
  export interface ActiveLeaf {
@@ -81,6 +81,13 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings {
81
81
  formatLink: string;
82
82
  formatNumberedList: string;
83
83
  formatBulletedList: string;
84
+ /** The font picker's accessible name; drawn only where the host hands the editor a
85
+ * font library or the selection sets a family. */
86
+ formatFont: string;
87
+ /** The picker's option that sets no family: the text takes the surrounding face. */
88
+ fontDefault: string;
89
+ /** What the picker reads over a selection setting more than one family. */
90
+ fontMixed: string;
84
91
  /** The anchor button's accessible name. The popover withholds the button, so
85
92
  * nothing draws this or the title below. */
86
93
  formatAnchor: string;
@@ -60,11 +60,14 @@ export const DEFAULT_VISUAL_STRINGS = {
60
60
  formatBold: `Bold (${chord('B')})`,
61
61
  formatEmphasis: `Italic (${chord('I')})`,
62
62
  formatUnderline: `Underline (${chord('U')})`,
63
- formatStrikethrough: 'Strikethrough',
64
- formatCode: 'Code',
63
+ formatStrikethrough: `Strikethrough (${chord('Shift-X')})`,
64
+ formatCode: `Code (${chord('E')})`,
65
65
  formatLink: `Link (${chord('K')})`,
66
66
  formatNumberedList: `Numbered list (${chord('Shift-7')})`,
67
67
  formatBulletedList: `Bulleted list (${chord('Shift-8')})`,
68
+ formatFont: 'Font',
69
+ fontDefault: 'Default font',
70
+ fontMixed: 'Mixed fonts',
68
71
  formatAnchor: 'Anchor',
69
72
  formatAnchorTitle: 'Anchor — an identity handle over the selection',
70
73
  linkPlaceholder: 'https://…',