@quillmark/svelte 0.36.0 → 0.37.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 (66) hide show
  1. package/README.md +18 -14
  2. package/THEMING.md +1 -1
  3. package/dist/core/codec/decode.d.ts +4 -2
  4. package/dist/core/codec/decode.js +5 -2
  5. package/dist/core/codec/field.d.ts +13 -10
  6. package/dist/core/codec/field.js +30 -24
  7. package/dist/core/codec/index.d.ts +3 -3
  8. package/dist/core/codec/index.js +2 -2
  9. package/dist/core/codec/prose.css +14 -4
  10. package/dist/core/codec/review.d.ts +4 -5
  11. package/dist/core/codec/review.js +6 -21
  12. package/dist/core/codec/schema.d.ts +12 -2
  13. package/dist/core/codec/schema.js +27 -5
  14. package/dist/core/codec/shortcuts.d.ts +3 -2
  15. package/dist/core/codec/shortcuts.js +3 -2
  16. package/dist/core/codec/table-view.js +15 -3
  17. package/dist/core/theme.css +39 -13
  18. package/dist/core/tooltip.css +49 -0
  19. package/dist/core/tooltip.d.ts +6 -0
  20. package/dist/core/tooltip.js +176 -0
  21. package/dist/preview/Preview.svelte +22 -1
  22. package/dist/preview/controller.js +38 -0
  23. package/dist/preview/strings.d.ts +2 -0
  24. package/dist/preview/strings.js +1 -0
  25. package/dist/visual/ArrayField.svelte +190 -86
  26. package/dist/visual/Card.svelte +21 -11
  27. package/dist/visual/CardControls.svelte +3 -3
  28. package/dist/visual/DateField.svelte +47 -5
  29. package/dist/visual/DiagnosticList.svelte +3 -2
  30. package/dist/visual/EnumField.svelte +6 -1
  31. package/dist/visual/EnumField.svelte.d.ts +2 -0
  32. package/dist/visual/Field.svelte +3 -3
  33. package/dist/visual/FieldHint.svelte +19 -8
  34. package/dist/visual/FormatPopover.svelte +53 -20
  35. package/dist/visual/MatrixField.svelte +7 -3
  36. package/dist/visual/NumberField.svelte +21 -5
  37. package/dist/visual/ObjectField.svelte +6 -2
  38. package/dist/visual/ProseField.svelte +6 -3
  39. package/dist/visual/ProseField.svelte.d.ts +2 -1
  40. package/dist/visual/ProseValue.svelte +11 -6
  41. package/dist/visual/ProseValue.svelte.d.ts +4 -1
  42. package/dist/visual/ReviewCard.svelte +85 -32
  43. package/dist/visual/ReviewCard.svelte.d.ts +2 -1
  44. package/dist/visual/ReviewProposal.svelte +0 -6
  45. package/dist/visual/TipsCard.svelte +1 -1
  46. package/dist/visual/VariantField.svelte +1 -0
  47. package/dist/visual/VisualEditor.svelte +12 -6
  48. package/dist/visual/VisualEditor.svelte.d.ts +5 -1
  49. package/dist/visual/VisualEditorInner.svelte +187 -275
  50. package/dist/visual/VisualEditorInner.svelte.d.ts +5 -1
  51. package/dist/visual/controls.css +2 -2
  52. package/dist/visual/index.d.ts +2 -2
  53. package/dist/visual/proposals.d.ts +14 -4
  54. package/dist/visual/proposals.js +28 -5
  55. package/dist/visual/props.d.ts +1 -1
  56. package/dist/visual/review-order.d.ts +51 -0
  57. package/dist/visual/review-order.js +87 -0
  58. package/dist/visual/review.d.ts +27 -1
  59. package/dist/visual/review.js +1 -1
  60. package/dist/visual/review.svelte.d.ts +34 -17
  61. package/dist/visual/review.svelte.js +187 -44
  62. package/dist/visual/strings.d.ts +36 -19
  63. package/dist/visual/strings.js +80 -24
  64. package/dist/visual/structure.d.ts +17 -3
  65. package/dist/visual/structure.js +71 -5
  66. package/package.json +2 -2
@@ -1,19 +1,23 @@
1
1
  // The editor's review state: the host's list split by where each item draws, and the one current
2
2
  // item, which the answer card and the review keys answer.
3
3
  //
4
- // The current item is sticky: a step, a reveal, a click, the caret arriving in an item, or the
5
- // pointer resting on one names it, and it stays until another is named or it is answered. The
6
- // pointer names one only after a dwell, and never while it is over the answer card, so a pointer
7
- // crossing the text on its way to the card does not move the card from under it.
4
+ // The current item is sticky: a step, a reveal, a click or the caret arriving in an item names
5
+ // it, and it stays until another is named or it is answered. The pointer passing over an item
6
+ // names nothing.
8
7
  //
9
8
  // An answered item is drawn no more, from the answer and not from the host's next list: the
10
9
  // reader's press shows at once however long the host takes to hand over a list without it.
10
+ //
11
+ // The answer journal holds the answers since the reader's last edit, each undone by ⌘Z from
12
+ // anywhere in the editor, newest first, its item reopened with it. An edit that is not an answer
13
+ // empties it: an inverse is good against the document it was recorded over. An answer's own
14
+ // writes, and an inverse's, go down the lanes an edit does, so they are flagged while they are
15
+ // made.
11
16
  import { getContext, setContext } from 'svelte';
12
17
  import { SvelteMap } from 'svelte/reactivity';
13
18
  import { asContent, planValue } from '../core/codec/index.js';
14
19
  import { byBlocks, byCard, locate, onField, sameValue, textProposal, valueIn, writesProposed } from './review.js';
15
- /** How long the pointer rests on an item before it is current, in ms. */
16
- export const DWELL_MS = 160;
20
+ import { orderOf } from './review-order.js';
17
21
  export function createReview(source) {
18
22
  /** The ids answered, each until a list arrives without it. */
19
23
  const answered = new Set();
@@ -61,7 +65,7 @@ export function createReview(source) {
61
65
  if (!byCard(item) || !open.has(item.id))
62
66
  continue;
63
67
  if ('remove' in item) {
64
- const key = listed[item.remove];
68
+ const key = item.card === undefined ? listed[item.remove] : source.cardFor(item.card);
65
69
  if (key !== undefined && standing.has(key))
66
70
  removes.set(key, item);
67
71
  else
@@ -79,12 +83,20 @@ export function createReview(source) {
79
83
  const item = all[at];
80
84
  for (let k = at - 1; k >= 0; k--) {
81
85
  const before = all[k];
82
- if (!byCard(before) || !('add' in before) || before.after !== item.after)
86
+ if (!byCard(before) || !('add' in before))
87
+ continue;
88
+ if (before.afterCard !== item.afterCard)
89
+ continue;
90
+ if (item.afterCard === undefined && before.after !== item.after)
83
91
  continue;
84
92
  const key = written.get(before.id);
85
93
  if (key !== undefined && standing.has(key))
86
94
  return key;
87
95
  }
96
+ if (item.afterCard !== undefined) {
97
+ const key = source.cardFor(item.afterCard);
98
+ return key !== undefined && standing.has(key) ? key : 'end';
99
+ }
88
100
  if (item.after === undefined || item.after < 0)
89
101
  return 'head';
90
102
  const key = listed[item.after];
@@ -165,15 +177,106 @@ export function createReview(source) {
165
177
  return placed.undrawn;
166
178
  return [...placed.undrawn, ...applied.map(([id]) => ({ id, reason: 'applied' }))];
167
179
  });
180
+ /** The open items drawn, in the page's order; one whose leaf no card lays out, last, in the
181
+ * list's order. */
182
+ const order = $derived.by(() => {
183
+ const undrawn = new Set(undrawnFields.map((u) => u.id));
184
+ const out = orderOf({
185
+ layout: source.layout(),
186
+ adds: cards.adds,
187
+ removes: cards.removes,
188
+ at: (key) => fields.get(key) ?? {},
189
+ reports: drawn,
190
+ undrawn
191
+ });
192
+ const placed = new Set(out);
193
+ const reported = new Set();
194
+ for (const report of drawn.values())
195
+ for (const id of report.ids)
196
+ reported.add(id);
197
+ for (const item of items) {
198
+ if (placed.has(item.id) || byCard(item))
199
+ continue;
200
+ if (onField(item) ? !undrawn.has(item.id) : reported.has(item.id))
201
+ out.push(item.id);
202
+ }
203
+ return out;
204
+ });
205
+ const report = $derived.by(() => {
206
+ const reported = new Set();
207
+ const stale = new Set(outdated);
208
+ const why = new Map();
209
+ for (const leaf of drawn.values()) {
210
+ for (const id of leaf.ids)
211
+ reported.add(id);
212
+ for (const id of leaf.outdated)
213
+ stale.add(id);
214
+ for (const { id, reason } of leaf.undrawn) {
215
+ reported.add(id);
216
+ why.set(id, reason);
217
+ }
218
+ }
219
+ for (const { id, reason } of undrawnFields)
220
+ why.set(id, reason);
221
+ for (const item of items)
222
+ if (!reported.has(item.id) && !why.has(item.id) && byBlocks(item))
223
+ why.set(item.id, 'block');
224
+ return {
225
+ open: order,
226
+ outdated: order.filter((id) => stale.has(id)),
227
+ undrawn: items.flatMap((item) => {
228
+ const reason = why.get(item.id);
229
+ return reason ? [{ id: item.id, reason }] : [];
230
+ })
231
+ };
232
+ });
168
233
  let current = $state();
169
- let dwell;
170
- let overCard = false;
171
234
  const lit = $derived(current !== undefined && byId.has(current) ? current : undefined);
172
235
  const name = (id) => {
173
- clearTimeout(dwell);
174
236
  current = id;
175
237
  };
176
- const answering = (id, action) => {
238
+ let journal = [];
239
+ /** The entry a batch of answers records into, and the current item it answered. */
240
+ let batching;
241
+ let offer;
242
+ let writing = 0;
243
+ const offerJournal = () => {
244
+ offer = journal.length
245
+ ? source.undo.offer('', unanswer, { standing: true, quiet: true, answer: true })
246
+ : undefined;
247
+ };
248
+ const unanswer = () => {
249
+ const top = journal.pop();
250
+ if (!top)
251
+ return;
252
+ writing++;
253
+ try {
254
+ for (const inverse of [...top.inverses].reverse())
255
+ inverse();
256
+ }
257
+ finally {
258
+ writing--;
259
+ }
260
+ offerJournal();
261
+ };
262
+ const record = (entry) => {
263
+ // Another step took the key since: the answers before it are no longer the last thing
264
+ // that happened.
265
+ if (!offer || !source.undo.holds(offer))
266
+ journal = [];
267
+ journal.push(entry);
268
+ offerJournal();
269
+ };
270
+ const answering = (id, action, made) => {
271
+ if (made !== true) {
272
+ if (batching) {
273
+ batching.ids.push(id);
274
+ batching.inverses.push(made);
275
+ }
276
+ else
277
+ record({ ids: [id], inverses: [made] });
278
+ }
279
+ const was = current === id;
177
280
  if (action === 'reopen')
178
281
  answered.delete(id);
179
282
  else
@@ -181,8 +284,12 @@ export function createReview(source) {
181
284
  answers++;
182
285
  if (action === 'reopen')
183
286
  name(id);
287
+ else if (!was)
288
+ return;
289
+ else if (batching)
290
+ batching.moved = id;
184
291
  else
185
- source.answered?.(id, current === id);
292
+ source.answered?.(id);
186
293
  };
187
294
  const self = {
188
295
  get items() {
@@ -198,6 +305,12 @@ export function createReview(source) {
198
305
  get fieldOutdated() {
199
306
  return outdated;
200
307
  },
308
+ get order() {
309
+ return order;
310
+ },
311
+ get report() {
312
+ return report;
313
+ },
201
314
  get lit() {
202
315
  return lit;
203
316
  },
@@ -239,36 +352,68 @@ export function createReview(source) {
239
352
  else
240
353
  drawn.delete(key);
241
354
  },
242
- point(id, via) {
243
- if (via === 'caret') {
244
- if (id !== undefined)
245
- name(id);
246
- return;
247
- }
248
- clearTimeout(dwell);
249
- if (id === undefined || id === current)
250
- return;
251
- dwell = setTimeout(() => {
252
- if (!overCard && byId.has(id))
253
- current = id;
254
- }, DWELL_MS);
355
+ point(id) {
356
+ if (id !== undefined)
357
+ name(id);
255
358
  },
256
359
  act(id, action) {
257
360
  const item = byId.get(id);
258
- if (!item || !source.answer(id, item, action))
361
+ const made = item && source.answer(id, item, action);
362
+ if (!made)
259
363
  return false;
260
- answering(id, action);
364
+ answering(id, action, made);
261
365
  return true;
262
366
  },
367
+ answer(ids, action) {
368
+ const before = order;
369
+ const stale = new Set(ids === 'all' && action === 'accept' ? report.outdated : []);
370
+ const asked = ids === 'all'
371
+ ? before.filter((id) => !stale.has(id))
372
+ : before.filter((id) => ids.includes(id));
373
+ const out = [];
374
+ const entry = { ids: [], inverses: [] };
375
+ batching = entry;
376
+ writing++;
377
+ try {
378
+ for (const id of asked) {
379
+ const item = byId.get(id);
380
+ if (!item)
381
+ continue;
382
+ const key = self.keyOf(id);
383
+ const made = onField(item) || byCard(item)
384
+ ? self.act(id, action)
385
+ : key !== undefined && source.answerProse(key, id, action);
386
+ if (made)
387
+ out.push(id);
388
+ }
389
+ }
390
+ finally {
391
+ writing--;
392
+ batching = undefined;
393
+ }
394
+ if (entry.ids.length)
395
+ record({ ids: entry.ids, inverses: entry.inverses });
396
+ if (entry.moved !== undefined)
397
+ source.answered?.(entry.moved, before);
398
+ return out;
399
+ },
400
+ settled() {
401
+ if (writing)
402
+ return;
403
+ journal = [];
404
+ offer = undefined;
405
+ source.undo.settle();
406
+ },
263
407
  answerWith(id, value) {
264
408
  const item = byId.get(id);
265
409
  if (!item || !onField(item))
266
410
  return false;
267
411
  const action = writesProposed(value, item.after) ? 'accept' : 'dismiss';
268
412
  const write = action === 'dismiss' ? { value } : undefined;
269
- if (!source.answer(id, item, action, undefined, write))
413
+ const made = source.answer(id, item, action, undefined, write);
414
+ if (!made)
270
415
  return false;
271
- answering(id, action);
416
+ answering(id, action, made);
272
417
  return true;
273
418
  },
274
419
  planned(id, state) {
@@ -287,20 +432,15 @@ export function createReview(source) {
287
432
  return item.after;
288
433
  return typeof item.after === 'string' ? merged.text : merged;
289
434
  },
290
- writing: (on) => source.writing?.(on),
291
- heard(id, action, key) {
292
- if (source.answer(id, byId.get(id), action, key))
293
- answering(id, action);
435
+ writing(on) {
436
+ writing += on ? 1 : -1;
294
437
  },
295
- reveal: name,
296
- hoverCard(on) {
297
- overCard = on;
298
- if (on)
299
- clearTimeout(dwell);
438
+ heard(id, action, key) {
439
+ const made = source.answer(id, byId.get(id), action, key);
440
+ if (made)
441
+ answering(id, action, made);
300
442
  },
301
- dispose() {
302
- clearTimeout(dwell);
303
- }
443
+ reveal: name
304
444
  };
305
445
  return self;
306
446
  }
@@ -316,6 +456,8 @@ const NO_REVIEW = {
316
456
  reports: new Map(),
317
457
  fieldUndrawn: [],
318
458
  fieldOutdated: new Set(),
459
+ order: [],
460
+ report: { open: [], outdated: [], undrawn: [] },
319
461
  lit: undefined,
320
462
  cards: { adds: new Map(), removes: new Map() },
321
463
  wrote() { },
@@ -325,14 +467,15 @@ const NO_REVIEW = {
325
467
  drew() { },
326
468
  point() { },
327
469
  act: () => false,
470
+ answer: () => [],
471
+ settled() { },
328
472
  answerWith: () => false,
329
473
  planned() { },
330
474
  current: () => undefined,
331
475
  writes: (item) => item.after,
332
476
  heard() { },
333
477
  writing() { },
334
- reveal() { },
335
- hoverCard() { }
478
+ reveal() { }
336
479
  };
337
480
  /** The editor's review state, or {@link NO_REVIEW} off-tree. */
338
481
  export function review() {
@@ -13,12 +13,13 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
13
13
  cardMoveUp: string;
14
14
  cardMoveDown: string;
15
15
  cardDelete: string;
16
- /** The card-title input's accessible name. */
16
+ /** The card-title input's own word in its accessible name, which {@link cardAction}
17
+ * completes with the card's title: `Card title, Findings`. */
17
18
  cardTitle: string;
18
19
  /**
19
- * A card control's accessible name, the action and the card it acts on, by the title
20
- * the header shows: `Delete card, Findings`. The action alone stays the tooltip.
21
- * Parametric, so word order stays the translator's.
20
+ * A card control's accessible name, the control's own word and the card it is on, by
21
+ * the title the header shows: `Delete card, Findings`. An action alone stays the
22
+ * tooltip. Parametric, so word order stays the translator's.
22
23
  */
23
24
  cardAction: (action: string, card: string) => string;
24
25
  /** A closed panel's header, spoken after its name (`Layout, has an issue`) when a field
@@ -56,15 +57,16 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
56
57
  undoAction: string;
57
58
  /** The standing control that puts a removed card back, named for it: `Restore Findings`. */
58
59
  undoRestore: (what: string) => string;
59
- /** The trailing strip's visible words, drawn after a `+`, and every
60
- * strip's accessible name. One string over
60
+ /** The trailing strip's visible words and every strip's accessible name. Words alone,
61
+ * as every add control's string is: the control draws its own `+`. One string over
61
62
  * one kind and many: the trigger seeds a card, and which kind is the menu's word
62
63
  * to say or the schema's to have already settled. */
63
64
  addCard: string;
65
+ /** A list's add chip: its words after the `+` the chip draws, and its accessible name. */
64
66
  arrayAdd: string;
65
67
  arrayRemove: string;
66
- /** The drag handle on an `object` row: its tooltip, which names the keys that move
67
- * the row too. */
68
+ /** The drag handle on an `object` row: its tooltip, which draws the keys that move the
69
+ * row beside it. */
68
70
  arrayDrag: string;
69
71
  /** What a list's standing row ghosts, the row that is not an element yet: the words
70
72
  * say what typing there does. */
@@ -101,6 +103,13 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
101
103
  diagTypeMismatch: (expected: string) => string;
102
104
  /** `validation::format_violation`: the value misses a string format (`args.format`). */
103
105
  diagFormatViolation: (format: string) => string;
106
+ /** What a screen reader hears once the errors the fields draw have changed and come to
107
+ * rest: each error's field label and its text, in the page's order, and none once the
108
+ * last has cleared. */
109
+ diagAnnounced: (issues: readonly {
110
+ field: string;
111
+ message: string;
112
+ }[]) => string;
104
113
  /** The tag on a field whose `default:` is what prints. */
105
114
  fieldDefault: string;
106
115
  /** The button that unsets a field written over its `default:`; its accessible name
@@ -132,7 +141,13 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
132
141
  * an island in a one-line leaf, an island in any subform cell), which it draws
133
142
  * read-only rather than lose. */
134
143
  proseHeld: string;
144
+ /** A field's guidance marker, named for the field it is about: `Subject guidance`.
145
+ * Parametric, so word order stays the translator's. */
146
+ fieldGuidance: (label: string) => string;
135
147
  formatGroup: string;
148
+ /** A mark or list button's name: its accessible name and its tooltip. The name alone:
149
+ * the button's shortcut is read off its binding, drawn beside the name in the tooltip
150
+ * and stated to assistive tech as `aria-keyshortcuts`. */
136
151
  formatBold: string;
137
152
  formatEmphasis: string;
138
153
  formatUnderline: string;
@@ -148,11 +163,10 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
148
163
  fontDefault: string;
149
164
  /** What the picker reads over a selection setting more than one family. */
150
165
  fontMixed: string;
151
- /** The anchor button's accessible name. The popover withholds the button, so
152
- * nothing draws this or the title below. */
166
+ /** The anchor button's name. The popover withholds the button, so nothing draws this. */
153
167
  formatAnchor: string;
154
- /** Its hover title, which says what an anchor is; the name above only says what. */
155
- formatAnchorTitle: string;
168
+ /** The link prompt's address input: its accessible name. */
169
+ linkAddress: string;
156
170
  linkPlaceholder: string;
157
171
  linkApply: string;
158
172
  /** Drawn only where the selection carries a link. */
@@ -213,14 +227,17 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
213
227
  */
214
228
  export type FormatDiagnostic = (d: Diagnostic) => string | undefined;
215
229
  /**
216
- * A `Mod` chord as the writer's platform prints it: `⌘B` on Apple's, `Ctrl+B`
217
- * elsewhere, and `Shift-7` as `⇧⌘7` or `Ctrl+Shift+7`. The platform test is the one
218
- * `prosemirror-keymap` resolves `Mod` by, so a tooltip names the chord the keymap binds.
230
+ * A binding as the writer's platform prints it, for the hint beside a control's name:
231
+ * `Mod-b` is `⌘B` on Apple's and `Ctrl+B` elsewhere, `Mod-Shift-7` is `⇧⌘7` or
232
+ * `Ctrl+Shift+7`, `Alt-ArrowUp` is `⌥↑` or `Alt+↑`.
219
233
  */
220
- export declare function chord(key: string, platform?: string): string;
221
- /** An `Alt` chord as the writer's platform prints it: `⌥↑` on Apple's, `Alt+↑` elsewhere,
222
- * on the test {@link chord} reads. */
223
- export declare function alt(key: string, platform?: string): string;
234
+ export declare function keycap(binding: string, platform?: string): string;
235
+ /**
236
+ * The same binding as `aria-keyshortcuts` spells it, which is where a control states its
237
+ * shortcut to assistive tech, its name staying its name: `Mod-b` is `Meta+B` on Apple's
238
+ * and `Control+B` elsewhere.
239
+ */
240
+ export declare function keyshortcut(binding: string, platform?: string): string;
224
241
  /** The package's English. Every key, so the merge below is total. */
225
242
  export declare const DEFAULT_VISUAL_STRINGS: VisualStrings;
226
243
  /** A consumer's wording: any subset, the rest the package's. */
@@ -19,23 +19,68 @@
19
19
  // which is a prop that means nothing to any of them.
20
20
  import { getContext, setContext } from 'svelte';
21
21
  import { DEFAULT_LEAVE_STRINGS, DEFAULT_SHORTCUT_STRINGS, DEFAULT_SLASH_STRINGS, DEFAULT_TABLE_STRINGS } from '../core/codec/index.js';
22
+ /** The platform test `prosemirror-keymap` resolves `Mod` by, so what is printed is what
23
+ * the keymap binds. */
24
+ const APPLE = /Mac|iP(hone|[oa]d)/;
25
+ const platformHere = () => (typeof navigator === 'undefined' ? '' : navigator.platform);
26
+ /** A binding in `prosemirror-keymap` notation, apart: its modifiers and its key, a letter
27
+ * in capitals as a keycap and `aria-keyshortcuts` both spell it. */
28
+ function parseBinding(binding) {
29
+ const parts = binding.split('-');
30
+ const key = parts.pop() ?? '';
31
+ return { mods: new Set(parts), key: /^[a-z]$/.test(key) ? key.toUpperCase() : key };
32
+ }
33
+ /** What a named key prints as. */
34
+ const KEY_GLYPH = {
35
+ ArrowUp: '↑',
36
+ ArrowDown: '↓',
37
+ ArrowLeft: '←',
38
+ ArrowRight: '→',
39
+ Enter: '↵',
40
+ Backspace: '⌫'
41
+ };
42
+ /** Apple's marks for the modifiers, in the order its menus print them. */
43
+ const APPLE_MODS = [
44
+ ['Ctrl', '⌃'],
45
+ ['Alt', '⌥'],
46
+ ['Shift', '⇧'],
47
+ ['Mod', '⌘']
48
+ ];
22
49
  /**
23
- * A `Mod` chord as the writer's platform prints it: `⌘B` on Apple's, `Ctrl+B`
24
- * elsewhere, and `Shift-7` as `⇧⌘7` or `Ctrl+Shift+7`. The platform test is the one
25
- * `prosemirror-keymap` resolves `Mod` by, so a tooltip names the chord the keymap binds.
50
+ * A binding as the writer's platform prints it, for the hint beside a control's name:
51
+ * `Mod-b` is `⌘B` on Apple's and `Ctrl+B` elsewhere, `Mod-Shift-7` is `⇧⌘7` or
52
+ * `Ctrl+Shift+7`, `Alt-ArrowUp` is `⌥↑` or `Alt+↑`.
26
53
  */
27
- export function chord(key, platform = typeof navigator === 'undefined' ? '' : navigator.platform) {
28
- const shift = key.startsWith('Shift-');
29
- const bare = shift ? key.slice('Shift-'.length) : key;
30
- if (/Mac|iP(hone|[oa]d)/.test(platform))
31
- return `${shift ? '⇧' : ''}⌘${bare}`;
32
- return `Ctrl+${shift ? 'Shift+' : ''}${bare}`;
54
+ export function keycap(binding, platform = platformHere()) {
55
+ const { mods, key } = parseBinding(binding);
56
+ const cap = KEY_GLYPH[key] ?? key;
57
+ if (APPLE.test(platform))
58
+ return APPLE_MODS.map(([mod, mark]) => (mods.has(mod) ? mark : '')).join('') + cap;
59
+ const names = [
60
+ mods.has('Mod') || mods.has('Ctrl') ? 'Ctrl' : '',
61
+ mods.has('Alt') ? 'Alt' : '',
62
+ mods.has('Shift') ? 'Shift' : ''
63
+ ];
64
+ return [...names.filter(Boolean), cap].join('+');
33
65
  }
34
- /** An `Alt` chord as the writer's platform prints it: `⌥↑` on Apple's, `Alt+↑` elsewhere,
35
- * on the test {@link chord} reads. */
36
- export function alt(key, platform = typeof navigator === 'undefined' ? '' : navigator.platform) {
37
- return /Mac|iP(hone|[oa]d)/.test(platform) ? `⌥${key}` : `Alt+${key}`;
66
+ /**
67
+ * The same binding as `aria-keyshortcuts` spells it, which is where a control states its
68
+ * shortcut to assistive tech, its name staying its name: `Mod-b` is `Meta+B` on Apple's
69
+ * and `Control+B` elsewhere.
70
+ */
71
+ export function keyshortcut(binding, platform = platformHere()) {
72
+ const { mods, key } = parseBinding(binding);
73
+ const names = [
74
+ mods.has('Mod') ? (APPLE.test(platform) ? 'Meta' : 'Control') : '',
75
+ mods.has('Ctrl') ? 'Control' : '',
76
+ mods.has('Alt') ? 'Alt' : '',
77
+ mods.has('Shift') ? 'Shift' : ''
78
+ ];
79
+ return [...names.filter(Boolean), key].join('+');
38
80
  }
81
+ /** How many fields `diagAnnounced` names before it counts the rest, so a host's batch over
82
+ * a whole document is still one sentence. */
83
+ const FIELDS_NAMED = 3;
39
84
  /** The package's English. Every key, so the merge below is total. */
40
85
  export const DEFAULT_VISUAL_STRINGS = {
41
86
  ...DEFAULT_TABLE_STRINGS,
@@ -65,9 +110,9 @@ export const DEFAULT_VISUAL_STRINGS = {
65
110
  undoAction: 'Undo',
66
111
  undoRestore: (what) => `Restore ${what}`,
67
112
  addCard: 'Add card',
68
- arrayAdd: '+ Add',
113
+ arrayAdd: 'Add',
69
114
  arrayRemove: 'Remove',
70
- arrayDrag: `Drag to move (${alt('↑/↓')})`,
115
+ arrayDrag: 'Drag to move',
71
116
  arrayStanding: 'Add an item…',
72
117
  arrayRowAction: (action, row) => `${action} ${row}`,
73
118
  arrayCount: (count, max) => `${count} / ${max}`,
@@ -86,6 +131,16 @@ export const DEFAULT_VISUAL_STRINGS = {
86
131
  : format === 'datetime'
87
132
  ? 'Not a real date and time. Check the day, month and time.'
88
133
  : `Doesn't match the ${format} format.`,
134
+ diagAnnounced: (issues) => {
135
+ if (issues.length === 0)
136
+ return 'No issues.';
137
+ if (issues.length === 1)
138
+ return `${issues[0].field}: ${issues[0].message}`;
139
+ const fields = [...new Set(issues.map((issue) => issue.field))];
140
+ const named = fields.slice(0, FIELDS_NAMED).join(', ');
141
+ const rest = fields.length - FIELDS_NAMED;
142
+ return `${issues.length} issues: ${named}${rest > 0 ? `, and ${rest} more` : ''}.`;
143
+ },
89
144
  fieldDefault: 'Default',
90
145
  fieldReset: 'Reset',
91
146
  enumUnsetTag: 'Default',
@@ -98,20 +153,21 @@ export const DEFAULT_VISUAL_STRINGS = {
98
153
  dateToday: 'Today',
99
154
  optionalGhost: 'None',
100
155
  proseHeld: "This field has formatting it can't edit here. It is kept as it is.",
156
+ fieldGuidance: (label) => `${label} guidance`,
101
157
  formatGroup: 'Formatting',
102
- formatBold: `Bold (${chord('B')})`,
103
- formatEmphasis: `Italic (${chord('I')})`,
104
- formatUnderline: `Underline (${chord('U')})`,
105
- formatStrikethrough: `Strikethrough (${chord('Shift-X')})`,
106
- formatCode: `Code (${chord('E')})`,
107
- formatLink: `Link (${chord('K')})`,
108
- formatNumberedList: `Numbered list (${chord('Shift-7')})`,
109
- formatBulletedList: `Bulleted list (${chord('Shift-8')})`,
158
+ formatBold: 'Bold',
159
+ formatEmphasis: 'Italic',
160
+ formatUnderline: 'Underline',
161
+ formatStrikethrough: 'Strikethrough',
162
+ formatCode: 'Code',
163
+ formatLink: 'Link',
164
+ formatNumberedList: 'Numbered list',
165
+ formatBulletedList: 'Bulleted list',
110
166
  formatFont: 'Font',
111
167
  fontDefault: 'Default font',
112
168
  fontMixed: 'Mixed fonts',
113
169
  formatAnchor: 'Anchor',
114
- formatAnchorTitle: 'Anchor — an identity handle over the selection',
170
+ linkAddress: 'Link address',
115
171
  linkPlaceholder: 'https://…',
116
172
  linkApply: 'Apply',
117
173
  linkRemove: 'Remove',
@@ -1,4 +1,4 @@
1
- import { type Content, type PathStep, type PayloadItem, type QuillCardSchema, type QuillFieldSchema, type QuillFieldType, type ResolvedField, type Resolved } from '@quillmark/wasm';
1
+ import { type Card, type Content, type Document, type PathStep, type PayloadItem, type QuillCardSchema, type QuillFieldSchema, type QuillFieldType, type ResolvedField, type Resolved } from '@quillmark/wasm';
2
2
  import type { TextCap } from '../core/codec/index.js';
3
3
  /** The control a field type maps to (INVARIANTS §"Structure mirrors the schema"). */
4
4
  export type ControlKind = 'prose' | 'text' | 'enum' | 'variant' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'matrix';
@@ -18,9 +18,10 @@ export interface FieldModel {
18
18
  label: string;
19
19
  /** Chrome-only; never gates. */
20
20
  description: string | undefined;
21
- /** Prose-leaf flags: {@link oneLine} and {@link literalText}. */
21
+ /** Prose-leaf flags: {@link oneLine}, {@link literalText} and {@link linesOnly}. */
22
22
  inline: boolean;
23
23
  plaintext: boolean;
24
+ paragraphs: boolean;
24
25
  }
25
26
  /** A panel section, a top-level `object`'s or a legacy `ui.group`'s: its label and the
26
27
  * fields (declaration order) inside it. */
@@ -141,8 +142,10 @@ export declare function optionalCell(f: QuillFieldSchema): boolean;
141
142
  */
142
143
  export declare function baseType(f: QuillFieldSchema): QuillFieldType;
143
144
  /** Whether a content field is one line: one paragraph, no container, no island. A `text`
144
- * or `richtext` field is one line unless it declares `multiline: true`. */
145
+ * or `richtext` field is one line unless it declares a `shape`. */
145
146
  export declare function oneLine(f: QuillFieldSchema): boolean;
147
+ /** Whether a `richtext` field holds formatted lines and no block: `shape: lines`. */
148
+ export declare function linesOnly(f: QuillFieldSchema): boolean;
146
149
  /** Whether a content field's codec is the literal one: `text`. */
147
150
  export declare function literalText(f: QuillFieldSchema): boolean;
148
151
  /** The character cap a content field's `max:` declares, `undefined` on any other. */
@@ -248,6 +251,13 @@ export declare function matrixMemberSchema(matrix: QuillFieldSchema, id: string)
248
251
  * before it asks the mounted tree for it (INVARIANTS §Surface).
249
252
  */
250
253
  export declare function schemaAt(field: QuillFieldSchema, steps: readonly PathStep[]): QuillFieldSchema | undefined;
254
+ /**
255
+ * Where the place at `steps` under `field` is drawn among the places inside the field, a number
256
+ * for each step: a list's member by its index, a record's cell by its declared order, a matrix's
257
+ * member by the roster's and one `value` adds after them, a variant's discriminant ahead of its
258
+ * cells. A step the schema does not declare is last.
259
+ */
260
+ export declare function rankAt(field: QuillFieldSchema, steps: readonly PathStep[], value?: unknown): number[];
251
261
  /**
252
262
  * Whether a cell is one line tall by declaration: what a table column can hold.
253
263
  */
@@ -373,3 +383,7 @@ export declare class IdSeq {
373
383
  /** `count` fresh ids, in order. */
374
384
  take(count: number): string[];
375
385
  }
386
+ /** Write `card` into `target` at `at`, under its `$id` where no card there holds that one and
387
+ * the document takes it, else under one the document mints. Throws where the card cannot be
388
+ * written. */
389
+ export declare function placeCardInto(target: Document, card: Card, at: number): void;