@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.
- package/dist/core/codec/field.d.ts +3 -3
- package/dist/core/codec/field.js +14 -20
- package/dist/core/codec/review.d.ts +2 -1
- package/dist/core/codec/review.js +64 -15
- package/dist/core/codec/value-diff.d.ts +4 -3
- package/dist/core/codec/value-diff.js +12 -7
- package/dist/core/codec/value-plan.d.ts +9 -0
- package/dist/core/codec/value-plan.js +110 -0
- package/dist/visual/ArrayField.svelte +77 -24
- package/dist/visual/Card.svelte +4 -3
- package/dist/visual/Card.svelte.d.ts +3 -2
- package/dist/visual/Field.svelte +12 -10
- package/dist/visual/Field.svelte.d.ts +3 -3
- package/dist/visual/ObjectField.svelte +24 -12
- package/dist/visual/ObjectField.svelte.d.ts +5 -0
- package/dist/visual/ProseField.svelte +16 -8
- package/dist/visual/ProseField.svelte.d.ts +3 -2
- package/dist/visual/ProseValue.svelte +22 -22
- package/dist/visual/ProseValue.svelte.d.ts +3 -2
- package/dist/visual/VisualEditorInner.svelte +37 -9
- package/dist/visual/proposals.d.ts +14 -11
- package/dist/visual/proposals.js +72 -29
- package/dist/visual/props.d.ts +6 -4
- package/dist/visual/review-order.d.ts +1 -0
- package/dist/visual/review-order.js +4 -3
- package/dist/visual/review.d.ts +25 -3
- package/dist/visual/review.js +46 -2
- package/dist/visual/review.svelte.d.ts +8 -1
- package/dist/visual/review.svelte.js +64 -11
- package/dist/visual/structure.d.ts +17 -9
- package/dist/visual/structure.js +20 -17
- package/package.json +1 -1
package/dist/visual/structure.js
CHANGED
|
@@ -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
|
-
/**
|
|
73
|
-
*
|
|
74
|
-
export function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
/**
|
|
82
|
-
export function
|
|
83
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
512
|
-
plaintext: literalText(schema),
|
|
513
|
-
paragraphs: linesOnly(schema)
|
|
516
|
+
...leafFlags(schema)
|
|
514
517
|
};
|
|
515
518
|
});
|
|
516
519
|
}
|