@quillmark/svelte 0.33.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 (98) 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.js +14 -5
  8. package/dist/core/codec/field.d.ts +47 -1
  9. package/dist/core/codec/field.js +147 -38
  10. package/dist/core/codec/index.d.ts +8 -2
  11. package/dist/core/codec/index.js +9 -2
  12. package/dist/core/codec/islands.d.ts +4 -1
  13. package/dist/core/codec/islands.js +6 -0
  14. package/dist/core/codec/keymap.d.ts +3 -0
  15. package/dist/core/codec/keymap.js +13 -12
  16. package/dist/core/codec/leave.d.ts +17 -0
  17. package/dist/core/codec/leave.js +78 -0
  18. package/dist/core/codec/prose.css +217 -0
  19. package/dist/core/codec/review-diff.d.ts +12 -0
  20. package/dist/core/codec/review-diff.js +131 -0
  21. package/dist/core/codec/review.d.ts +131 -0
  22. package/dist/core/codec/review.js +1077 -0
  23. package/dist/core/codec/shortcuts.d.ts +20 -4
  24. package/dist/core/codec/shortcuts.js +27 -7
  25. package/dist/core/codec/slash.d.ts +3 -0
  26. package/dist/core/codec/slash.js +2 -1
  27. package/dist/core/codec/table-view.js +163 -25
  28. package/dist/core/codec/undo.d.ts +6 -0
  29. package/dist/core/codec/undo.js +25 -2
  30. package/dist/core/dragfollow.d.ts +18 -0
  31. package/dist/core/dragfollow.js +63 -0
  32. package/dist/core/theme.css +36 -7
  33. package/dist/preview/controller.js +16 -0
  34. package/dist/preview/strings.d.ts +4 -0
  35. package/dist/preview/strings.js +3 -1
  36. package/dist/visual/ArrayField.svelte +363 -57
  37. package/dist/visual/ArrayField.svelte.d.ts +5 -0
  38. package/dist/visual/BooleanField.svelte +60 -5
  39. package/dist/visual/BooleanField.svelte.d.ts +2 -1
  40. package/dist/visual/Card.svelte +27 -17
  41. package/dist/visual/CardControls.svelte +17 -7
  42. package/dist/visual/CardControls.svelte.d.ts +2 -0
  43. package/dist/visual/DateField.svelte +90 -39
  44. package/dist/visual/DateField.svelte.d.ts +2 -2
  45. package/dist/visual/Field.svelte +126 -6
  46. package/dist/visual/FieldHint.svelte +24 -9
  47. package/dist/visual/FieldLabel.svelte +128 -22
  48. package/dist/visual/FieldLabel.svelte.d.ts +9 -0
  49. package/dist/visual/FormatPopover.svelte +125 -20
  50. package/dist/visual/MatrixAdd.svelte +13 -6
  51. package/dist/visual/MatrixAdd.svelte.d.ts +3 -2
  52. package/dist/visual/MatrixField.svelte +36 -8
  53. package/dist/visual/NumberField.svelte +27 -6
  54. package/dist/visual/NumberField.svelte.d.ts +3 -0
  55. package/dist/visual/ObjectField.svelte +25 -1
  56. package/dist/visual/ObjectField.svelte.d.ts +6 -0
  57. package/dist/visual/ProseField.svelte +23 -0
  58. package/dist/visual/ProseField.svelte.d.ts +3 -0
  59. package/dist/visual/ProseValue.svelte +107 -17
  60. package/dist/visual/ProseValue.svelte.d.ts +18 -4
  61. package/dist/visual/ReviewPopover.svelte +179 -0
  62. package/dist/visual/ReviewPopover.svelte.d.ts +16 -0
  63. package/dist/visual/ReviewProposal.svelte +149 -0
  64. package/dist/visual/ReviewProposal.svelte.d.ts +15 -0
  65. package/dist/visual/ReviewRows.svelte +68 -0
  66. package/dist/visual/ReviewRows.svelte.d.ts +11 -0
  67. package/dist/visual/SlashMenu.svelte +13 -1
  68. package/dist/visual/SlashMenu.svelte.d.ts +2 -0
  69. package/dist/visual/VisualEditor.svelte +23 -0
  70. package/dist/visual/VisualEditor.svelte.d.ts +7 -0
  71. package/dist/visual/VisualEditorInner.svelte +671 -22
  72. package/dist/visual/VisualEditorInner.svelte.d.ts +7 -0
  73. package/dist/visual/controls.css +17 -2
  74. package/dist/visual/guidance.d.ts +12 -0
  75. package/dist/visual/guidance.js +37 -2
  76. package/dist/visual/icons/nodes.d.ts +14 -2
  77. package/dist/visual/icons/nodes.js +12 -1
  78. package/dist/visual/index.d.ts +6 -0
  79. package/dist/visual/index.js +2 -0
  80. package/dist/visual/listhistory.d.ts +36 -0
  81. package/dist/visual/listhistory.js +53 -0
  82. package/dist/visual/proposals.d.ts +40 -0
  83. package/dist/visual/proposals.js +219 -0
  84. package/dist/visual/props.d.ts +35 -0
  85. package/dist/visual/removed.d.ts +20 -0
  86. package/dist/visual/removed.js +30 -0
  87. package/dist/visual/review.d.ts +170 -0
  88. package/dist/visual/review.js +269 -0
  89. package/dist/visual/review.svelte.d.ts +106 -0
  90. package/dist/visual/review.svelte.js +356 -0
  91. package/dist/visual/rowdrag.svelte.js +44 -55
  92. package/dist/visual/strings.d.ts +48 -7
  93. package/dist/visual/strings.js +32 -7
  94. package/dist/visual/structure.d.ts +5 -0
  95. package/dist/visual/structure.js +1 -1
  96. package/dist/visual/undo.svelte.d.ts +40 -7
  97. package/dist/visual/undo.svelte.js +98 -25
  98. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import { type FieldProposal } from './review.js';
2
+ interface Props {
3
+ item: FieldProposal;
4
+ /** The value the control holds. */
5
+ value: unknown;
6
+ /** Take the focus back to the control: an answer given from the row unmounts it. */
7
+ refocus?: () => void;
8
+ /** Where the value is, for one drawn under a control that is not its own. */
9
+ label?: string;
10
+ /** It takes a list's member out, so nothing comes in its place. */
11
+ removes?: boolean;
12
+ }
13
+ declare const ReviewProposal: import("svelte").Component<Props, {}, "">;
14
+ type ReviewProposal = ReturnType<typeof ReviewProposal>;
15
+ export default ReviewProposal;
@@ -0,0 +1,68 @@
1
+ <!--
2
+ The review items a container hands to one of its places, drawn under that place's control:
3
+ a proposal as the value that would go and the value that would come with its two answers, an
4
+ accepted one as the line a changed field's control carries along its foot. An item naming a
5
+ place deeper than the control under which it is drawn, which no control of its own draws,
6
+ leads with where it is: the cells and members between, by name and number.
7
+ -->
8
+ <script lang="ts">
9
+ import type { PathStep } from '@quillmark/wasm';
10
+ import ReviewProposal from './ReviewProposal.svelte';
11
+ import { isChange, valueIn, type DeepReview } from './review.js';
12
+ import { review } from './review.svelte.js';
13
+ import { wording } from './strings.js';
14
+ import { humanize } from './structure.js';
15
+
16
+ interface Props {
17
+ entries: readonly DeepReview[] | undefined;
18
+ /** The value the place holds, which the entries' steps walk from. */
19
+ value: unknown;
20
+ /** The place is a list's member, which a proposal of nothing takes out. */
21
+ member?: boolean;
22
+ }
23
+ let { entries, value, member = false }: Props = $props();
24
+
25
+ const t = wording();
26
+ const reviewing = review();
27
+
28
+ const where = (steps: readonly PathStep[]): string | undefined =>
29
+ steps.length
30
+ ? steps
31
+ .map((step) =>
32
+ typeof step === 'number' ? t.strings.elementItem(step + 1) : humanize(step)
33
+ )
34
+ .join(' · ')
35
+ : undefined;
36
+ </script>
37
+
38
+ {#each entries ?? [] as { steps, item } (item.id)}
39
+ {#if !isChange(item)}
40
+ <ReviewProposal
41
+ {item}
42
+ value={valueIn(value, steps)}
43
+ label={where(steps)}
44
+ removes={item.after === undefined &&
45
+ (steps.length ? typeof steps.at(-1) === 'number' : member)}
46
+ />
47
+ {:else}
48
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
49
+ <div
50
+ class={['qm-review-line', { 'qm-review-lit': reviewing.lit === item.id }]}
51
+ data-qm-review={item.id}
52
+ onpointerenter={() => reviewing.point(item.id, 'pointer')}
53
+ onpointerleave={() => reviewing.point(undefined, 'pointer')}
54
+ ></div>
55
+ {/if}
56
+ {/each}
57
+
58
+ <style>
59
+ /* The line a changed control carries along its foot (`Field.svelte`), under the place it
60
+ changed, at the vertical width the surface draws a stroke at. */
61
+ .qm-review-line {
62
+ height: var(--_qm-vertical-width);
63
+ background: var(--_qm-review-line);
64
+ }
65
+ .qm-review-line.qm-review-lit {
66
+ box-shadow: 0 0 0 var(--_qm-vertical-width) var(--_qm-review-tint);
67
+ }
68
+ </style>
@@ -0,0 +1,11 @@
1
+ import { type DeepReview } from './review.js';
2
+ interface Props {
3
+ entries: readonly DeepReview[] | undefined;
4
+ /** The value the place holds, which the entries' steps walk from. */
5
+ value: unknown;
6
+ /** The place is a list's member, which a proposal of nothing takes out. */
7
+ member?: boolean;
8
+ }
9
+ declare const ReviewRows: import("svelte").Component<Props, {}, "">;
10
+ type ReviewRows = ReturnType<typeof ReviewRows>;
11
+ export default ReviewRows;
@@ -16,6 +16,11 @@
16
16
  second highlight the keyboard cannot reach (controls.css, the shared menu recipe).
17
17
  The keyboard's one claim here is the scroll: the arrows move an index, and only the
18
18
  chrome knows the port that index has to stay inside.
19
+
20
+ Focus never reaches an item, so nothing a screen reader follows says which one is
21
+ highlighted: a polite live region beside the menu speaks the highlighted row and its
22
+ place as the index moves. It is mounted with the leaf, since a region inserted with the
23
+ text it carries is not announced.
19
24
  -->
20
25
  <script lang="ts">
21
26
  import { Popover } from 'bits-ui';
@@ -32,10 +37,15 @@
32
37
  label: string;
33
38
  /** A command's row name, by its token. */
34
39
  name: (command: string) => string;
40
+ /** What the live region says of the highlighted row. */
41
+ position: (name: string, index: number, count: number) => string;
35
42
  }
36
- let { menu, leaf, label, name: nameOf }: Props = $props();
43
+ let { menu, leaf, label, name: nameOf, position }: Props = $props();
37
44
 
38
45
  let open = $derived(!!menu && menu.items.length > 0);
46
+ const announced = $derived(
47
+ open && menu ? position(nameOf(menu.items[menu.index]), menu.index + 1, menu.items.length) : ''
48
+ );
39
49
 
40
50
  /** The root to portal into, resolved from the leaf's own DOM so the menu lands
41
51
  * inside whichever `[data-qm-root]` raised it and inherits the consumer's dials;
@@ -57,6 +67,8 @@
57
67
  }
58
68
  </script>
59
69
 
70
+ <span class="qm-visually-hidden" aria-live="polite">{announced}</span>
71
+
60
72
  <Popover.Root bind:open>
61
73
  <Popover.Portal to={portalTarget}>
62
74
  <!-- Hung off the trigger and flush against it: the anchor is the `/` itself
@@ -9,6 +9,8 @@ interface Props {
9
9
  label: string;
10
10
  /** A command's row name, by its token. */
11
11
  name: (command: string) => string;
12
+ /** What the live region says of the highlighted row. */
13
+ position: (name: string, index: number, count: number) => string;
12
14
  }
13
15
  declare const SlashMenu: import("svelte").Component<Props, {}, "">;
14
16
  type SlashMenu = ReturnType<typeof SlashMenu>;
@@ -106,6 +106,29 @@
106
106
  export function applyCardOps(ops: readonly CardOp[]): void {
107
107
  inner?.applyCardOps(ops);
108
108
  }
109
+ /** Bring the review item `id` to the reader: its panel opened, scrolled to the middle of
110
+ * the view, lit, its card raised. The focus stays put unless `focus` sends the caret into
111
+ * the item, where its chords answer. False for an item not drawn. */
112
+ export async function revealReview(id: string, opts?: { focus?: boolean }): Promise<boolean> {
113
+ return (await inner?.revealReview(id, opts)) ?? false;
114
+ }
115
+ /** Answer items as their buttons would, in document order (`'all'`: every item drawn),
116
+ * moving neither the focus nor the caret and raising no toast; `'reopen'` takes back
117
+ * accepted proposals. Returns the ids answered. */
118
+ export function answerReview(
119
+ ids: readonly string[] | 'all',
120
+ action: 'accept' | 'dismiss' | 'reopen'
121
+ ): string[] {
122
+ return inner?.answerReview(ids, action) ?? [];
123
+ }
124
+ /** Bring the next or previous open item to the reader, round from either end, the caret
125
+ * or the focus in it unless `focus` is false. Resolves its id, `undefined` for none. */
126
+ export async function stepReview(
127
+ dir: 1 | -1,
128
+ opts?: { focus?: boolean }
129
+ ): Promise<string | undefined> {
130
+ return (await inner?.stepReview(dir, opts)) ?? undefined;
131
+ }
109
132
  </script>
110
133
 
111
134
  {#key props.doc}
@@ -13,6 +13,13 @@ declare const VisualEditor: import("svelte").Component<VisualEditorProps, {
13
13
  applyExternal: (field: DocPath, delta?: Delta) => void;
14
14
  refresh: () => void;
15
15
  applyCardOps: (ops: readonly CardOp[]) => void;
16
+ revealReview: (id: string, opts?: {
17
+ focus?: boolean;
18
+ }) => Promise<boolean>;
19
+ answerReview: (ids: readonly string[] | "all", action: "accept" | "dismiss" | "reopen") => string[];
20
+ stepReview: (dir: 1 | -1, opts?: {
21
+ focus?: boolean;
22
+ }) => Promise<string | undefined>;
16
23
  }, "">;
17
24
  type VisualEditor = ReturnType<typeof VisualEditor>;
18
25
  export default VisualEditor;