@quillmark/svelte 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +73 -1
  2. package/THEMING.md +11 -10
  3. package/dist/core/codec/anchor.d.ts +12 -0
  4. package/dist/core/codec/anchor.js +39 -0
  5. package/dist/core/codec/drag-move.d.ts +11 -0
  6. package/dist/core/codec/drag-move.js +143 -0
  7. package/dist/core/codec/encode.d.ts +2 -1
  8. package/dist/core/codec/encode.js +16 -6
  9. package/dist/core/codec/field.d.ts +47 -1
  10. package/dist/core/codec/field.js +201 -37
  11. package/dist/core/codec/index.d.ts +8 -2
  12. package/dist/core/codec/index.js +9 -2
  13. package/dist/core/codec/islands.d.ts +4 -1
  14. package/dist/core/codec/islands.js +6 -0
  15. package/dist/core/codec/keymap.d.ts +3 -0
  16. package/dist/core/codec/keymap.js +13 -12
  17. package/dist/core/codec/leave.d.ts +17 -0
  18. package/dist/core/codec/leave.js +78 -0
  19. package/dist/core/codec/prose.css +217 -0
  20. package/dist/core/codec/review-diff.d.ts +12 -0
  21. package/dist/core/codec/review-diff.js +131 -0
  22. package/dist/core/codec/review.d.ts +131 -0
  23. package/dist/core/codec/review.js +1077 -0
  24. package/dist/core/codec/shortcuts.d.ts +20 -4
  25. package/dist/core/codec/shortcuts.js +27 -7
  26. package/dist/core/codec/slash.d.ts +3 -0
  27. package/dist/core/codec/slash.js +2 -1
  28. package/dist/core/codec/table-view.js +163 -25
  29. package/dist/core/codec/undo.d.ts +6 -0
  30. package/dist/core/codec/undo.js +25 -2
  31. package/dist/core/dragfollow.d.ts +18 -0
  32. package/dist/core/dragfollow.js +63 -0
  33. package/dist/core/theme.css +36 -7
  34. package/dist/preview/controller.js +16 -0
  35. package/dist/preview/strings.d.ts +4 -0
  36. package/dist/preview/strings.js +3 -1
  37. package/dist/visual/ArrayField.svelte +363 -57
  38. package/dist/visual/ArrayField.svelte.d.ts +5 -0
  39. package/dist/visual/BooleanField.svelte +60 -5
  40. package/dist/visual/BooleanField.svelte.d.ts +2 -1
  41. package/dist/visual/Card.svelte +27 -17
  42. package/dist/visual/CardControls.svelte +17 -7
  43. package/dist/visual/CardControls.svelte.d.ts +2 -0
  44. package/dist/visual/DateField.svelte +90 -39
  45. package/dist/visual/DateField.svelte.d.ts +2 -2
  46. package/dist/visual/Field.svelte +126 -6
  47. package/dist/visual/FieldHint.svelte +24 -9
  48. package/dist/visual/FieldLabel.svelte +128 -22
  49. package/dist/visual/FieldLabel.svelte.d.ts +9 -0
  50. package/dist/visual/FormatPopover.svelte +125 -20
  51. package/dist/visual/MatrixAdd.svelte +13 -6
  52. package/dist/visual/MatrixAdd.svelte.d.ts +3 -2
  53. package/dist/visual/MatrixField.svelte +36 -8
  54. package/dist/visual/NumberField.svelte +27 -6
  55. package/dist/visual/NumberField.svelte.d.ts +3 -0
  56. package/dist/visual/ObjectField.svelte +25 -1
  57. package/dist/visual/ObjectField.svelte.d.ts +6 -0
  58. package/dist/visual/ProseField.svelte +23 -0
  59. package/dist/visual/ProseField.svelte.d.ts +3 -0
  60. package/dist/visual/ProseValue.svelte +107 -17
  61. package/dist/visual/ProseValue.svelte.d.ts +18 -4
  62. package/dist/visual/ReviewPopover.svelte +179 -0
  63. package/dist/visual/ReviewPopover.svelte.d.ts +16 -0
  64. package/dist/visual/ReviewProposal.svelte +149 -0
  65. package/dist/visual/ReviewProposal.svelte.d.ts +15 -0
  66. package/dist/visual/ReviewRows.svelte +68 -0
  67. package/dist/visual/ReviewRows.svelte.d.ts +11 -0
  68. package/dist/visual/SlashMenu.svelte +13 -1
  69. package/dist/visual/SlashMenu.svelte.d.ts +2 -0
  70. package/dist/visual/VisualEditor.svelte +23 -0
  71. package/dist/visual/VisualEditor.svelte.d.ts +7 -0
  72. package/dist/visual/VisualEditorInner.svelte +671 -22
  73. package/dist/visual/VisualEditorInner.svelte.d.ts +7 -0
  74. package/dist/visual/controls.css +17 -2
  75. package/dist/visual/guidance.d.ts +12 -0
  76. package/dist/visual/guidance.js +37 -2
  77. package/dist/visual/icons/nodes.d.ts +14 -2
  78. package/dist/visual/icons/nodes.js +12 -1
  79. package/dist/visual/index.d.ts +6 -0
  80. package/dist/visual/index.js +2 -0
  81. package/dist/visual/listhistory.d.ts +36 -0
  82. package/dist/visual/listhistory.js +53 -0
  83. package/dist/visual/proposals.d.ts +40 -0
  84. package/dist/visual/proposals.js +219 -0
  85. package/dist/visual/props.d.ts +35 -0
  86. package/dist/visual/removed.d.ts +20 -0
  87. package/dist/visual/removed.js +30 -0
  88. package/dist/visual/review.d.ts +170 -0
  89. package/dist/visual/review.js +269 -0
  90. package/dist/visual/review.svelte.d.ts +106 -0
  91. package/dist/visual/review.svelte.js +356 -0
  92. package/dist/visual/rowdrag.svelte.js +44 -55
  93. package/dist/visual/strings.d.ts +48 -7
  94. package/dist/visual/strings.js +32 -7
  95. package/dist/visual/structure.d.ts +5 -0
  96. package/dist/visual/structure.js +1 -1
  97. package/dist/visual/undo.svelte.d.ts +40 -7
  98. package/dist/visual/undo.svelte.js +98 -25
  99. package/package.json +1 -1
@@ -0,0 +1,63 @@
1
+ // What a held reorder drag owes the scrolls under it, for the two surfaces that carry one:
2
+ // a record list's handle (`visual/rowdrag.svelte.ts`) and a table island's grip
3
+ // (`codec/table-view.ts`). A scroll by any hand moves the lines under a pointer that has not
4
+ // moved, so the drag is told to read them again. Held in an edge band of its scrollport, the
5
+ // drag scrolls it toward the lines out of view, once the pointer has been outside the band:
6
+ // a press on a line already in the band does not scroll.
7
+ /** The band at a scrollport's two edges that scrolls it under a held drag, and the most one
8
+ * frame scrolls, reached at the edge itself. */
9
+ const EDGE = 48;
10
+ const STEP = 16;
11
+ const page = () => document.scrollingElement ?? document.documentElement;
12
+ /** The nearest ancestor that scrolls along `axis`, else the page. */
13
+ function scrollport(from, axis) {
14
+ for (let el = from.parentElement; el; el = el.parentElement) {
15
+ const style = getComputedStyle(el);
16
+ const scrolls = /auto|scroll/.test(axis === 'y' ? style.overflowY : style.overflowX);
17
+ const room = axis === 'y' ? el.scrollHeight > el.clientHeight : el.scrollWidth > el.clientWidth;
18
+ if (scrolls && room)
19
+ return el;
20
+ }
21
+ return page();
22
+ }
23
+ /** Follow an engaged drag until the returned stop is called. */
24
+ export function followDrag(o) {
25
+ const port = scrollport(o.grip, o.axis);
26
+ let armed = false;
27
+ let frame = 0;
28
+ let stopped = false;
29
+ const stop = () => {
30
+ stopped = true;
31
+ cancelAnimationFrame(frame);
32
+ removeEventListener('scroll', o.moved, { capture: true });
33
+ };
34
+ const edgeScroll = () => {
35
+ if (stopped)
36
+ return;
37
+ if (!o.grip.isConnected) {
38
+ stop();
39
+ o.lost();
40
+ return;
41
+ }
42
+ const vertical = o.axis === 'y';
43
+ const box = port === page() ? undefined : port.getBoundingClientRect();
44
+ const view = vertical ? innerHeight : innerWidth;
45
+ const near = Math.max((vertical ? box?.top : box?.left) ?? 0, 0);
46
+ const far = Math.min((vertical ? box?.bottom : box?.right) ?? view, view);
47
+ const at = o.at();
48
+ const into = Math.min(at - near - EDGE, 0) + Math.max(at - far + EDGE, 0);
49
+ if (!into)
50
+ armed = true;
51
+ // Only toward lines still out of view: past the list's end there is nothing to reach.
52
+ const lines = o.extent();
53
+ const beyond = into < 0 ? (lines?.start ?? near) < near : (lines?.end ?? 0) > far;
54
+ if (into && armed && beyond) {
55
+ const by = STEP * Math.max(-1, Math.min(1, into / EDGE));
56
+ port.scrollBy({ [vertical ? 'top' : 'left']: by, behavior: 'instant' });
57
+ }
58
+ frame = requestAnimationFrame(edgeScroll);
59
+ };
60
+ addEventListener('scroll', o.moved, { capture: true, passive: true });
61
+ frame = requestAnimationFrame(edgeScroll);
62
+ return stop;
63
+ }
@@ -88,7 +88,7 @@
88
88
  /* Neutral: the surface spends no hue on a state it can draw in grey. The pair
89
89
  clears WCAG 2.4.11's 3:1 against the card at both poles, at 4.8:1 and 5.8:1. */
90
90
  --_qm-accent: var(--qm-accent, light-dark(#71717a, #a1a1aa));
91
- /* The one hue the surface spends, and it spends it on a state. Each pole is
91
+ /* One of the two hues the surface spends, each on a state. Each pole is
92
92
  its own figure rather than one ink shown twice: a hue calibrated against
93
93
  white reads as a stain on a dark card. Both clear WCAG 1.4.3's 4.5:1 against
94
94
  the card, which is the bar the label rung asks for and the one the glyphs
@@ -97,6 +97,12 @@
97
97
  figures are the host scale's (`preset/scale.css`), so a page's status line
98
98
  and a card's diagnostic carry one colour meaning error. */
99
99
  --_qm-danger: var(--qm-danger, light-dark(#9e1518, #f9786c));
100
+ /* Review: what someone other than the reader wrote here, and what one proposes. The
101
+ other hue, and a state's again: drawn in the accent's grey, a proposed word reads as a
102
+ code span and a changed field's line as its border, before either reads as someone
103
+ else's writing. A figure per pole, as danger's are. Nothing is set in this hue: it runs
104
+ under words and along them, and the words over it stay the ink. */
105
+ --_qm-review: var(--qm-review, light-dark(#4f46e5, #a5b4fc));
100
106
  --_qm-font: var(--qm-font, ui-sans-serif, system-ui, sans-serif);
101
107
  --_qm-font-mono: var(--qm-font-mono, ui-monospace, monospace);
102
108
 
@@ -209,6 +215,16 @@
209
215
  ratio `default` steps the ink. What is drawn over it in the card's colour, the
210
216
  thumb and the check, holds 3:1 at both poles, at 3.3:1 and 4.2:1. */
211
217
  --_qm-accent-default: color-mix(in oklab, var(--_qm-accent), var(--_qm-bg) 20%);
218
+ /* The review hue, three ways. `tint` is held under the words a proposal would add and
219
+ over a field someone else set, at the strength the accent's own tint is held under
220
+ body text plus what a state resting on a well has to clear. `lit` is that tint under
221
+ attention: the pointer over the item, the caret in it, a host revealing it. `line` is
222
+ the stroke: the line under changed words, the line through the words a proposal
223
+ would take, and a changed field's edge, held back so it sits under a link's
224
+ underline rather than beside it. */
225
+ --_qm-review-tint: color-mix(in oklab, var(--_qm-review) 20%, transparent);
226
+ --_qm-review-lit: color-mix(in oklab, var(--_qm-review) 34%, transparent);
227
+ --_qm-review-line: color-mix(in oklab, var(--_qm-review) 60%, transparent);
212
228
  /* The danger hue held: what a destructive control fills with where the family's
213
229
  neutral hover rung would read as one more button. Mixed at the accent tint's
214
230
  strength, so a held tint is a held tint whichever hue it carries. */
@@ -276,9 +292,9 @@
276
292
  `visual/controls.css`, since a rung each control reassembles is a scale
277
293
  only up to the point where it is assembled. One width: focus is the only
278
294
  state that draws a ring anywhere, so there is no held-back tier under it.
279
- Sub-pixel, because at two it reads as a second border on a card whose every
280
- other stroke is a hairline. */
281
- --_qm-ring-width: 1.5px;
295
+ Two whole pixels, WCAG 2.4.13's floor: a sub-pixel width rounds down to one
296
+ device pixel at 1x density, where the ring is then a hairline beside hairlines. */
297
+ --_qm-ring-width: 2px;
282
298
  /* Every ring the surface draws, focus and selection alike, which is why the name
283
299
  carries neither. Assembled here because the parts spelled out at a use site pass
284
300
  every axis — each reads a rung — while drawing a ring nothing else agrees with. */
@@ -413,11 +429,14 @@
413
429
  `--qm-font-size` anchors the chrome rung and `label` stands one 1.125 step under
414
430
  it. The ratio and the weight are fixed conventions, not dials: no consumer tunes
415
431
  a typographic ratio, and a dial nobody turns is a name every reader still holds.
416
- Two chrome rungs: nothing the chrome names ranks above the value it names, a card
417
- title being body at the mid weight, and a second step below `label` lands near
418
- 11px, under a size anything here wants to be read at. */
432
+ Two chrome rungs under the body and one over it. A second step below `label` lands
433
+ near 11px, under a size anything here wants to be read at. `title` is the card's
434
+ name alone, two steps up: a card holds sections whose headers stand at the body,
435
+ and one step is the paper's, which reads as a change of register rather than of
436
+ rank, so a card and the section inside it read as siblings at it. */
419
437
  --_qm-text-body: var(--qm-font-size, 0.875rem);
420
438
  --_qm-text-label: calc(var(--_qm-text-body) / 1.125);
439
+ --_qm-text-title: calc(var(--_qm-text-body) * 1.125 * 1.125);
421
440
  /* Paper: the document body answers to the preview's paper where every other
422
441
  surface here answers to the control beside it, so a rung shared with the chrome
423
442
  makes a consumer asking for larger prose take larger inputs with it. 16/15 where
@@ -490,6 +509,16 @@
490
509
  line-height: var(--_qm-leading-body);
491
510
  }
492
511
 
512
+ /* More contrast steps the two rungs that identify a control rather than a list of
513
+ selectors: the well's edge to 3:1 against the card at both poles (WCAG 1.4.11),
514
+ which half the ink over the well clears, and the ring a pixel wider. */
515
+ @media (prefers-contrast: more) {
516
+ :where([data-qm-root]) {
517
+ --_qm-well-edge: color-mix(in oklab, var(--_qm-fg) 50%, transparent);
518
+ --_qm-ring-width: 3px;
519
+ }
520
+ }
521
+
493
522
  /* Reduced motion collapses the scale, never a list of selectors.
494
523
  Two values here are not the rung they look like:
495
524
 
@@ -13,6 +13,14 @@ export function createPreview(session, opts) {
13
13
  const margin = opts.margin ?? 1;
14
14
  const t = mergePreviewStrings(opts.strings);
15
15
  container.classList.add(CONTAINER_CLASS);
16
+ // The pane is a tab stop (`viewport.ts`), so it is a named region a focus lands in; a
17
+ // role or a name the consumer gave the container stands.
18
+ const ownsRole = !container.hasAttribute('role');
19
+ const ownsName = !container.hasAttribute('aria-label') && !container.hasAttribute('aria-labelledby');
20
+ if (ownsRole)
21
+ container.setAttribute('role', 'region');
22
+ if (ownsName)
23
+ container.setAttribute('aria-label', t.previewLabel);
16
24
  // One element, restamped: the message states are mutually exclusive.
17
25
  let message;
18
26
  function showMessage(text, state) {
@@ -62,6 +70,10 @@ export function createPreview(session, opts) {
62
70
  const countChanged = pageCount !== paintLoop.slots.length;
63
71
  hideMessage();
64
72
  paintLoop.refresh(dirtyPages, pageCount);
73
+ for (const slot of paintLoop.slots) {
74
+ slot.el.setAttribute('role', 'img');
75
+ slot.el.setAttribute('aria-label', t.pageLabel(slot.page + 1, pageCount));
76
+ }
65
77
  if (countChanged || !bridge) {
66
78
  detach();
67
79
  attach();
@@ -112,6 +124,10 @@ export function createPreview(session, opts) {
112
124
  paintLoop.destroy();
113
125
  hideMessage();
114
126
  container.classList.remove(CONTAINER_CLASS);
127
+ if (ownsRole)
128
+ container.removeAttribute('role');
129
+ if (ownsName)
130
+ container.removeAttribute('aria-label');
115
131
  }
116
132
  };
117
133
  }
@@ -5,6 +5,10 @@ export interface PreviewStrings {
5
5
  noPages: string;
6
6
  /** The zoom pill's action, after the percentage it shows. */
7
7
  resetZoom: string;
8
+ /** The pane's accessible name, where the container carries none of its own. */
9
+ previewLabel: string;
10
+ /** A page's text alternative, 1-based: the canvas is pixels to a screen reader. */
11
+ pageLabel: (page: number, count: number) => string;
8
12
  }
9
13
  /** The package's English. */
10
14
  export declare const DEFAULT_PREVIEW_STRINGS: PreviewStrings;
@@ -3,7 +3,9 @@
3
3
  export const DEFAULT_PREVIEW_STRINGS = {
4
4
  renderFailed: 'Preview failed to render.',
5
5
  noPages: 'No pages to preview.',
6
- resetZoom: 'reset zoom'
6
+ resetZoom: 'reset zoom',
7
+ previewLabel: 'Document preview',
8
+ pageLabel: (page, count) => `Page ${page} of ${count}`
7
9
  };
8
10
  /** Fill a partial override to the whole key set. */
9
11
  export function mergePreviewStrings(custom) {