@quillmark/svelte 0.37.1 → 0.38.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.
@@ -69,24 +69,29 @@ export function optionalCell(f) {
69
69
  export function baseType(f) {
70
70
  return (optionalCell(f) ? f.type.slice(0, -1) : f.type);
71
71
  }
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 a `shape`. */
74
- export function oneLine(f) {
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';
72
+ /** A field's text kind, read once from its schema; `undefined` for a field that is not text. A
73
+ * field that declares no `shape` is one line. */
74
+ export function textKind(f) {
75
+ const type = baseType(f);
76
+ if (type !== 'text' && type !== 'richtext')
77
+ return undefined;
78
+ return { type, shape: f.shape ?? 'line' };
80
79
  }
81
- /** Whether a content field's codec is the literal one: `text`. */
82
- export function literalText(f) {
83
- return baseType(f) === 'text';
80
+ /** What a prose leaf is built from: the kind, spelled as the leaf schema reads it. */
81
+ export function leafFlags(f) {
82
+ const kind = f && textKind(f);
83
+ return {
84
+ inline: kind?.shape === 'line',
85
+ plaintext: kind?.type === 'text',
86
+ paragraphs: kind?.type === 'richtext' && kind.shape === 'lines'
87
+ };
84
88
  }
85
89
  /** The character cap a content field's `max:` declares, `undefined` on any other. */
86
90
  export function textCap(f) {
87
91
  if (f?.max == null || controlKind(f) !== 'prose')
88
92
  return undefined;
89
- return { max: f.max, trimEnd: literalText(f) && oneLine(f) };
93
+ const kind = textKind(f);
94
+ return { max: f.max, trimEnd: kind?.type === 'text' && kind.shape === 'line' };
90
95
  }
91
96
  /**
92
97
  * A scalar `default:` as the text an unset control holds, where it prints: as
@@ -113,7 +118,7 @@ export function declaredContent(v, markdown) {
113
118
  return { text: text.replaceAll('\n', '\u2028'), blocks: [{ id: 'b0', kind: 'para' }] };
114
119
  }
115
120
  /** A field's `{#each}` key: its name and what a mounted leaf reads once, its type,
116
- * {@link oneLine} and `max:`, and its elements'. A retype or a quill swap that changes
121
+ * `shape` and `max:`, and its elements'. A retype or a quill swap that changes
117
122
  * any of them under a name remounts the field, where a kept leaf would commit on the old
118
123
  * schema. */
119
124
  export function mountKey(name, f) {
@@ -417,7 +422,7 @@ export function rankAt(field, steps, value) {
417
422
  export function shortCell(sub) {
418
423
  const kind = controlKind(sub);
419
424
  if (kind === 'prose')
420
- return oneLine(sub);
425
+ return textKind(sub)?.shape === 'line';
421
426
  return (kind === 'text' || kind === 'enum' || kind === 'number' || kind === 'boolean' || kind === 'date');
422
427
  }
423
428
  /**
@@ -508,9 +513,7 @@ export function fieldModels(cardSchema) {
508
513
  compact: schema.ui?.compact ?? packsByDefault(control),
509
514
  label: fieldTitle(name, schema),
510
515
  description: schema.description,
511
- inline: oneLine(schema),
512
- plaintext: literalText(schema),
513
- paragraphs: linesOnly(schema)
516
+ ...leafFlags(schema)
514
517
  };
515
518
  });
516
519
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.37.1",
3
+ "version": "0.38.1",
4
4
  "description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
5
5
  "repository": {
6
6
  "type": "git",