@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.
- package/README.md +18 -14
- package/THEMING.md +1 -1
- package/dist/core/codec/decode.d.ts +4 -2
- package/dist/core/codec/decode.js +5 -2
- package/dist/core/codec/field.d.ts +13 -10
- package/dist/core/codec/field.js +30 -24
- package/dist/core/codec/index.d.ts +3 -3
- package/dist/core/codec/index.js +2 -2
- package/dist/core/codec/prose.css +14 -4
- package/dist/core/codec/review.d.ts +4 -5
- package/dist/core/codec/review.js +6 -21
- package/dist/core/codec/schema.d.ts +12 -2
- package/dist/core/codec/schema.js +27 -5
- package/dist/core/codec/shortcuts.d.ts +3 -2
- package/dist/core/codec/shortcuts.js +3 -2
- package/dist/core/codec/table-view.js +15 -3
- package/dist/core/theme.css +39 -13
- package/dist/core/tooltip.css +49 -0
- package/dist/core/tooltip.d.ts +6 -0
- package/dist/core/tooltip.js +176 -0
- package/dist/preview/Preview.svelte +22 -1
- package/dist/preview/controller.js +38 -0
- package/dist/preview/strings.d.ts +2 -0
- package/dist/preview/strings.js +1 -0
- package/dist/visual/ArrayField.svelte +190 -86
- package/dist/visual/Card.svelte +21 -11
- package/dist/visual/CardControls.svelte +3 -3
- package/dist/visual/DateField.svelte +47 -5
- package/dist/visual/DiagnosticList.svelte +3 -2
- package/dist/visual/EnumField.svelte +6 -1
- package/dist/visual/EnumField.svelte.d.ts +2 -0
- package/dist/visual/Field.svelte +3 -3
- package/dist/visual/FieldHint.svelte +19 -8
- package/dist/visual/FormatPopover.svelte +53 -20
- package/dist/visual/MatrixField.svelte +7 -3
- package/dist/visual/NumberField.svelte +21 -5
- package/dist/visual/ObjectField.svelte +6 -2
- package/dist/visual/ProseField.svelte +6 -3
- package/dist/visual/ProseField.svelte.d.ts +2 -1
- package/dist/visual/ProseValue.svelte +11 -6
- package/dist/visual/ProseValue.svelte.d.ts +4 -1
- package/dist/visual/ReviewCard.svelte +85 -32
- package/dist/visual/ReviewCard.svelte.d.ts +2 -1
- package/dist/visual/ReviewProposal.svelte +0 -6
- package/dist/visual/TipsCard.svelte +1 -1
- package/dist/visual/VariantField.svelte +1 -0
- package/dist/visual/VisualEditor.svelte +12 -6
- package/dist/visual/VisualEditor.svelte.d.ts +5 -1
- package/dist/visual/VisualEditorInner.svelte +187 -275
- package/dist/visual/VisualEditorInner.svelte.d.ts +5 -1
- package/dist/visual/controls.css +2 -2
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +14 -4
- package/dist/visual/proposals.js +28 -5
- package/dist/visual/props.d.ts +1 -1
- package/dist/visual/review-order.d.ts +51 -0
- package/dist/visual/review-order.js +87 -0
- package/dist/visual/review.d.ts +27 -1
- package/dist/visual/review.js +1 -1
- package/dist/visual/review.svelte.d.ts +34 -17
- package/dist/visual/review.svelte.js +187 -44
- package/dist/visual/strings.d.ts +36 -19
- package/dist/visual/strings.js +80 -24
- package/dist/visual/structure.d.ts +17 -3
- package/dist/visual/structure.js +71 -5
- package/package.json +2 -2
package/dist/visual/structure.js
CHANGED
|
@@ -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 `
|
|
73
|
+
* or `richtext` field is one line unless it declares a `shape`. */
|
|
74
74
|
export function oneLine(f) {
|
|
75
|
-
return 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';
|
|
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
|
-
|
|
124
|
+
f.shape ?? '',
|
|
121
125
|
f.max ?? '',
|
|
122
126
|
items?.type ?? '',
|
|
123
|
-
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.
|
|
3
|
+
"version": "0.37.0",
|
|
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.
|
|
72
|
+
"@quillmark/wasm": ">=0.138.0-0",
|
|
73
73
|
"svelte": "^5.33.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|