@quillmark/svelte 0.36.0 → 0.37.1

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 (71) 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 +14 -10
  6. package/dist/core/codec/field.js +34 -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 +20 -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 +44 -17
  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 +262 -145
  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 +22 -13
  34. package/dist/visual/FieldLabel.svelte +6 -42
  35. package/dist/visual/FieldLabel.svelte.d.ts +0 -3
  36. package/dist/visual/FormatPopover.svelte +53 -20
  37. package/dist/visual/MatrixAdd.svelte +9 -10
  38. package/dist/visual/MatrixField.svelte +114 -18
  39. package/dist/visual/NumberField.svelte +21 -5
  40. package/dist/visual/ObjectField.svelte +6 -2
  41. package/dist/visual/ProseField.svelte +6 -3
  42. package/dist/visual/ProseField.svelte.d.ts +2 -1
  43. package/dist/visual/ProseValue.svelte +13 -6
  44. package/dist/visual/ProseValue.svelte.d.ts +4 -1
  45. package/dist/visual/ReviewCard.svelte +93 -33
  46. package/dist/visual/ReviewCard.svelte.d.ts +2 -1
  47. package/dist/visual/ReviewProposal.svelte +0 -6
  48. package/dist/visual/TipsCard.svelte +1 -1
  49. package/dist/visual/VariantField.svelte +1 -0
  50. package/dist/visual/VisualEditor.svelte +12 -6
  51. package/dist/visual/VisualEditor.svelte.d.ts +5 -1
  52. package/dist/visual/VisualEditorInner.svelte +218 -302
  53. package/dist/visual/VisualEditorInner.svelte.d.ts +5 -1
  54. package/dist/visual/controls.css +2 -2
  55. package/dist/visual/guidance.d.ts +0 -2
  56. package/dist/visual/guidance.js +0 -10
  57. package/dist/visual/index.d.ts +2 -2
  58. package/dist/visual/proposals.d.ts +14 -4
  59. package/dist/visual/proposals.js +28 -5
  60. package/dist/visual/props.d.ts +1 -1
  61. package/dist/visual/review-order.d.ts +51 -0
  62. package/dist/visual/review-order.js +87 -0
  63. package/dist/visual/review.d.ts +27 -1
  64. package/dist/visual/review.js +1 -1
  65. package/dist/visual/review.svelte.d.ts +34 -17
  66. package/dist/visual/review.svelte.js +187 -44
  67. package/dist/visual/strings.d.ts +38 -19
  68. package/dist/visual/strings.js +81 -24
  69. package/dist/visual/structure.d.ts +17 -3
  70. package/dist/visual/structure.js +71 -5
  71. package/package.json +2 -2
@@ -70,9 +70,13 @@ export function baseType(f) {
70
70
  return (optionalCell(f) ? f.type.slice(0, -1) : f.type);
71
71
  }
72
72
  /** Whether a content field is one line: one paragraph, no container, no island. A `text`
73
- * or `richtext` field is one line unless it declares `multiline: true`. */
73
+ * or `richtext` field is one line unless it declares a `shape`. */
74
74
  export function oneLine(f) {
75
- return f.multiline !== true;
75
+ return f.shape === undefined;
76
+ }
77
+ /** Whether a `richtext` field holds formatted lines and no block: `shape: lines`. */
78
+ export function linesOnly(f) {
79
+ return baseType(f) === 'richtext' && f.shape === 'lines';
76
80
  }
77
81
  /** Whether a content field's codec is the literal one: `text`. */
78
82
  export function literalText(f) {
@@ -117,10 +121,10 @@ export function mountKey(name, f) {
117
121
  return [
118
122
  name,
119
123
  f.type,
120
- oneLine(f),
124
+ f.shape ?? '',
121
125
  f.max ?? '',
122
126
  items?.type ?? '',
123
- items ? oneLine(items) : '',
127
+ items?.shape ?? '',
124
128
  items?.max ?? ''
125
129
  ].join('\u0000');
126
130
  }
@@ -361,6 +365,51 @@ function stepInto(schema, step) {
361
365
  return undefined;
362
366
  }
363
367
  }
368
+ /**
369
+ * Where the place at `steps` under `field` is drawn among the places inside the field, a number
370
+ * for each step: a list's member by its index, a record's cell by its declared order, a matrix's
371
+ * member by the roster's and one `value` adds after them, a variant's discriminant ahead of its
372
+ * cells. A step the schema does not declare is last.
373
+ */
374
+ export function rankAt(field, steps, value) {
375
+ const out = [];
376
+ let cursor = field;
377
+ let held = value;
378
+ const among = (keys, step) => {
379
+ const at = keys.indexOf(String(step));
380
+ return at < 0 ? Number.MAX_SAFE_INTEGER : at;
381
+ };
382
+ for (const step of steps) {
383
+ if (!cursor) {
384
+ out.push(Number.MAX_SAFE_INTEGER);
385
+ continue;
386
+ }
387
+ switch (controlKind(cursor)) {
388
+ case 'array':
389
+ out.push(typeof step === 'number' ? step : Number.MAX_SAFE_INTEGER);
390
+ break;
391
+ case 'object':
392
+ out.push(among(Object.keys(cursor.properties ?? {}), step));
393
+ break;
394
+ case 'matrix': {
395
+ const map = held && typeof held === 'object' ? held : undefined;
396
+ const drawn = [...matrixMembers(cursor.members), ...addedItems(cursor, map)];
397
+ out.push(among(drawn.map((m) => m.id), step));
398
+ break;
399
+ }
400
+ case 'variant': {
401
+ const world = Object.values(cursor.variants ?? {}).find((cells) => Object.hasOwn(cells, String(step)));
402
+ out.push(step === VARIANT_DISCRIMINANT ? 0 : 1 + among(Object.keys(world ?? {}), step));
403
+ break;
404
+ }
405
+ default:
406
+ out.push(Number.MAX_SAFE_INTEGER);
407
+ }
408
+ cursor = stepInto(cursor, step);
409
+ held = held && typeof held === 'object' ? held[step] : undefined;
410
+ }
411
+ return out;
412
+ }
364
413
  // ── Short cells and layouts ──────────────────────────────────────────────────
365
414
  /**
366
415
  * Whether a cell is one line tall by declaration: what a table column can hold.
@@ -460,7 +509,8 @@ export function fieldModels(cardSchema) {
460
509
  label: fieldTitle(name, schema),
461
510
  description: schema.description,
462
511
  inline: oneLine(schema),
463
- plaintext: literalText(schema)
512
+ plaintext: literalText(schema),
513
+ paragraphs: linesOnly(schema)
464
514
  };
465
515
  });
466
516
  }
@@ -676,3 +726,19 @@ export class IdSeq {
676
726
  return Array.from({ length: count }, () => this.next());
677
727
  }
678
728
  }
729
+ /** Write `card` into `target` at `at`, under its `$id` where no card there holds that one and
730
+ * the document takes it, else under one the document mints. Throws where the card cannot be
731
+ * written. */
732
+ export function placeCardInto(target, card, at) {
733
+ const { id, ...bare } = card;
734
+ const free = id !== undefined &&
735
+ !Array.from({ length: target.cardCount }, (_, k) => target.card(k).id).includes(id);
736
+ try {
737
+ target.unchecked.insertCard(free ? card : bare, at);
738
+ }
739
+ catch (e) {
740
+ if (!free)
741
+ throw e;
742
+ target.unchecked.insertCard(bare, at);
743
+ }
744
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
4
4
  "description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -69,7 +69,7 @@
69
69
  "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
70
70
  },
71
71
  "peerDependencies": {
72
- "@quillmark/wasm": ">=0.135.0-0",
72
+ "@quillmark/wasm": ">=0.138.0-0",
73
73
  "svelte": "^5.33.0"
74
74
  },
75
75
  "dependencies": {