@quillmark/wasm 0.123.1 → 0.125.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/render/wasm.d.ts CHANGED
@@ -105,10 +105,17 @@ export type ContentLineKind =
105
105
  export type ContentContainer =
106
106
  | {
107
107
  container: "list_item";
108
- attrs: { ordered: boolean; start: number; ordinal: number };
108
+ /** `checked` is present on a task item: `true` ticked, `false` open. */
109
+ attrs: { ordered: boolean; start: number; ordinal: number; checked?: boolean };
109
110
  instance?: number;
110
111
  }
111
- | { container: "quote"; instance?: number };
112
+ | { container: "quote"; instance?: number }
113
+ | { container: "element"; attrs: ElementAttrs; instance?: number };
114
+
115
+ /** A carrier element's name and attributes, one bag: `$name` is the part of
116
+ * its `qm-<name>` tag after the prefix, and every other key an attribute as
117
+ * written. */
118
+ export type ElementAttrs = { $name: string; [attr: string]: string };
112
119
 
113
120
  /** A mark over char range `[start, end)` into `Content.text`. `type` is a
114
121
  * closed set, so `type === "link"` narrows `attrs` to `{ url: string }` with no
@@ -131,20 +138,34 @@ export type ContentMarkKind =
131
138
  export interface TableCell {
132
139
  text: string;
133
140
  marks: ContentMark[];
141
+ /** The cell's horizontal alignment; absent is its column's. */
142
+ align?: "left" | "center" | "right";
143
+ /** The cell's vertical alignment; absent is the quill's. */
144
+ valign?: "top" | "middle" | "bottom";
134
145
  }
135
146
 
136
147
  /** `props` of a `type: "table"` island: a pipe table normalized to one column
137
- * count that `header`, every row of `rows`, and `aligns` all share. */
148
+ * count that `header`, every row of `rows`, `aligns` and `widths` all share.
149
+ * A layout key at its default is absent; one holding a value outside its type
150
+ * stays as written and reads as absent. */
138
151
  export interface TableProps {
139
152
  header: TableCell[];
140
153
  rows: TableCell[][];
141
154
  /** Per-column alignment, one entry per column. */
142
155
  aligns: ("none" | "left" | "center" | "right")[];
156
+ /** Per-column relative weights; `null` is an auto-fit column. Absent when
157
+ * every column is auto-fit. A weight is an integer from 1 to
158
+ * `Number.MAX_SAFE_INTEGER`. */
159
+ widths?: (number | null)[];
160
+ /** The table's placement; absent is the quill's. */
161
+ align?: "left" | "center" | "right";
162
+ /** `true` draws `header` as the first body row; absent is a header row. */
163
+ headless?: true;
143
164
  }
144
165
 
145
166
  /** `props` of a `type: "image"` island. Stores and round-trips; no backend
146
167
  * typesets one, and a render that holds one warns `backend::declined_construct`,
147
- * because what `url` names is undecided. */
168
+ * because no backend resolves `url`. */
148
169
  export interface ImageProps {
149
170
  url: string;
150
171
  alt: string;
@@ -205,6 +226,57 @@ export interface Delta {
205
226
  ops: ({ retain: number } | { insert: string } | { delete: number })[];
206
227
  }
207
228
 
229
+ /**
230
+ * The receipt of a markdown revise (`revise`, `writer.reviseBody`,
231
+ * `writer.reviseField`): the text `delta`, and one `parse::dropped_construct`
232
+ * warning per construct the import dropped, anchored at the revised address.
233
+ */
234
+ export interface Revised {
235
+ delta: Delta;
236
+ warnings: Diagnostic[];
237
+ }
238
+
239
+ /**
240
+ * The receipt of `writer.reviseDocument`. `droppedAnchors` names every prose
241
+ * anchor the write did not carry, at its path and line in the stored document; a table
242
+ * cell's anchors drop unnamed. `warnings` are the parse's, then each revised
243
+ * content field's `parse::dropped_construct`, then the writer's `conform::*`.
244
+ * A field that lands rather than revises, on an inserted card or over no stored
245
+ * content, reports no drop.
246
+ */
247
+ export interface DocumentRevised {
248
+ droppedAnchors: DocumentAnchor[];
249
+ warnings: Diagnostic[];
250
+ }
251
+
252
+ /**
253
+ * The read `toAnnotatedMarkdown` returns: `toMarkdown`'s markdown with a
254
+ * read-only `<qm-anchor ref="…"></qm-anchor>` at each prose anchor's
255
+ * start its line can hold, and every prose anchor of every body and content
256
+ * field, spelled or not; a table cell's anchors are neither. Each names the
257
+ * `path` of its body or field and the text of the `line` its start sits on,
258
+ * island slots removed.
259
+ */
260
+ export interface AnnotatedMarkdown {
261
+ markdown: string;
262
+ anchors: DocumentAnchor[];
263
+ }
264
+
265
+ export interface DocumentAnchor {
266
+ id: string;
267
+ path: string;
268
+ line: string;
269
+ }
270
+
271
+ /**
272
+ * A markdown import (`importMarkdown`): the canonical `content`, and one
273
+ * `parse::dropped_construct` warning per construct it dropped, with no `path`.
274
+ */
275
+ export interface Imported {
276
+ content: Content;
277
+ warnings: Diagnostic[];
278
+ }
279
+
208
280
  /** Which side of a same-position insertion `mapPos` lands a point on. */
209
281
  export type Assoc = "before" | "after";
210
282
 
@@ -385,6 +457,8 @@ export interface Resolved {
385
457
  /** UI layout hints for a single field. Display order is not a hint: key order
386
458
  * in the schema's `fields`/`properties` objects is the ordering contract. */
387
459
  export interface QuillFieldUi {
460
+ /** The id of the card section holding the field, a key of the card's
461
+ * `ui.groups`. */
388
462
  group?: string;
389
463
  compact?: boolean;
390
464
  multiline?: boolean;
@@ -401,18 +475,18 @@ export interface QuillFieldUi {
401
475
  layout?: "table" | "flat";
402
476
  }
403
477
 
404
- /** One entry in a card's `ui.groups` registry: a display-label override for the
405
- * group id (the map key). An empty object carries no override, and the consumer
406
- * derives the label from the id (`memo_for` → "Memo For"). */
478
+ /** One section in a card's `ui.groups`: a display-label override for the
479
+ * section id (the map key). An empty object carries no override, and the
480
+ * consumer derives the label from the id (`memo_for` → "Memo For"). */
407
481
  export interface QuillGroupUi {
408
482
  title?: string;
409
483
  }
410
484
 
411
485
  /** UI layout hints for a card (main or named card kind). */
412
486
  export interface QuillCardUi {
413
- /** The groups a field's `ui.group` may reference, keyed by group id. Key
414
- * order is the display-order contract, as with `fields`. Absent when the
415
- * card declares no groups. */
487
+ /** The card's sections keyed by id, each holding at least one field, which
488
+ * names it in its `ui.group`. Key order is the display-order contract, as
489
+ * with `fields`. Absent when the card declares no sections. */
416
490
  groups?: Record<string, QuillGroupUi>;
417
491
  }
418
492
 
@@ -554,7 +628,8 @@ export interface FieldRegion {
554
628
  rect: [number, number, number, number];
555
629
  /**
556
630
  * The slice this box covers: USV `[start, end)` into the field's `Content`
557
- * for one content segment, `undefined` for a scalar site or widget.
631
+ * for one content segment, `undefined` for a scalar's ink, a claim or a
632
+ * widget.
558
633
  */
559
634
  span?: [number, number];
560
635
  }
@@ -565,6 +640,23 @@ export interface FieldRegion {
565
640
  */
566
641
  export type HitGranularity = "cluster" | "segment";
567
642
 
643
+ /**
644
+ * One address a compiled document fills and the region address a click
645
+ * reaches it through: the consumer's copy of this contract is
646
+ * `runtime/runtime.d.ts`.
647
+ */
648
+ export interface FieldCoverage {
649
+ /**
650
+ * Canonical `DocPath` field address, as `FieldRegion.field` spells it.
651
+ */
652
+ field: string;
653
+ /**
654
+ * The `DocPath` of the region reaching `field`: itself, or the nearest
655
+ * enclosing address a region carries. `undefined` where no click does.
656
+ */
657
+ coveredBy?: string;
658
+ }
659
+
568
660
  /**
569
661
  * Output formats supported by backends. Gated behind the engine surface so
570
662
  * tsify omits it from the core bundle, which has no rendering surface.
@@ -596,8 +688,8 @@ export interface Diagnostic {
596
688
  message: string;
597
689
  location?: Location;
598
690
  /**
599
- * Document-model path anchor (e.g. `"cards.indorsement[0].signature_block"`),
600
- * set on schema validation diagnostics and `undefined` otherwise.
691
+ * Document-model path anchor (e.g. `"cards.indorsement[0].signature_block"`)
692
+ * where the diagnostic has a document address, `undefined` otherwise.
601
693
  */
602
694
  path?: string;
603
695
  hint?: string;
@@ -828,15 +920,17 @@ export class Document {
828
920
  /**
829
921
  * **Revise** the richtext value at `addr` from a markdown string: the
830
922
  * default write path. Imports the markdown, diffs it against the current
831
- * value, rebases surviving identity anchors, and returns the text `Delta` an
832
- * editor bridge maps its own positions through (`mapPos`). An absent
833
- * `addr.field` targets the body, an absent `addr.card` the main card; an
834
- * absent field cold-imports from empty.
923
+ * value, rebases surviving identity anchors, and returns the `Revised`
924
+ * receipt: the text `delta` an editor bridge maps its own positions through
925
+ * (`mapPos`), and a `parse::dropped_construct` warning per construct the
926
+ * import dropped, its `path` the address written. An absent `addr.field`
927
+ * targets the body, an absent `addr.card` the main card; an absent field
928
+ * cold-imports from empty.
835
929
  *
836
930
  * Throws on an out-of-range card, a malformed field name, a present
837
931
  * non-content field value, or an over-nested markdown input.
838
932
  */
839
- revise(addr: Addr | string, markdown: string): Delta;
933
+ revise(addr: Addr | string, markdown: string): Revised;
840
934
  /**
841
935
  * The main card's `$seed[kind]` overlay object, or `undefined`. Feeds
842
936
  * `quill.seedCard(kind, overlay)` without serializing the whole main card,
@@ -889,8 +983,18 @@ export class Document {
889
983
  */
890
984
  storeSeedOverlay(card_kind: string, overlay: any): void;
891
985
  /**
892
- * Emit canonical Quillmark Markdown. Round-trip safe: re-parsing the
893
- * result produces a `Document` equal to `self` by value and by type.
986
+ * `toMarkdown` with each prose anchor of every body and content field
987
+ * spelled read-only at its start where its line can hold the tag, and
988
+ * listed with its field's path and line either way. An import drops every
989
+ * tag, so `writer.reviseDocument` with the markdown keeps the anchors it keeps
990
+ * with `toMarkdown`'s.
991
+ */
992
+ toAnnotatedMarkdown(): AnnotatedMarkdown;
993
+ /**
994
+ * Emit canonical Quillmark Markdown. Re-parsing the result produces a
995
+ * `Document` equal to `self` by value and by type, but for content: a body
996
+ * or content field holds what its markdown spells, so its anchors drop and
997
+ * its island ids re-mint. `toStored` keeps both.
894
998
  */
895
999
  toMarkdown(): string;
896
1000
  /**
@@ -914,7 +1018,7 @@ export class Document {
914
1018
  * The non-fatal diagnostics of the load that produced this document: parse
915
1019
  * warnings, plus `conform::*` warnings when it came through `quill.parse`.
916
1020
  * Session state, not document value: `equals` and the storage DTO exclude
917
- * it, and `fromStored` / `loadStored` clear it.
1021
+ * it, and `fromStored` / `loadStored` / `writer.reviseDocument` clear it.
918
1022
  */
919
1023
  readonly warnings: Diagnostic[];
920
1024
  }
@@ -933,6 +1037,13 @@ export class LiveSession {
933
1037
  private constructor();
934
1038
  free(): void;
935
1039
  [Symbol.dispose](): void;
1040
+ /**
1041
+ * Each address the current compile fills that a reader could want to
1042
+ * click, and the `DocPath` of the region reaching it: the address itself,
1043
+ * the nearest enclosing one a region carries (a row claim reaching its
1044
+ * cells), or `undefined` where no click does. Reflects the current compile.
1045
+ */
1046
+ coverage(): FieldCoverage[];
936
1047
  /**
937
1048
  * The schema field whose content is under a point on `page`: the `DocPath`
938
1049
  * address to focus in the editor, or `undefined` off any field's ink.
@@ -953,9 +1064,9 @@ export class LiveSession {
953
1064
  /**
954
1065
  * The whole-field highlight boxes for `field`: one union rect per page over
955
1066
  * the field's `span`-bearing content segments, the union `regions()` leaves
956
- * derived. **Content only**: a field placed solely as a scalar reference or
957
- * a bound widget carries no `span` and returns `[]`, its box being a single
958
- * `regions()` rect. Reflects the current compile.
1067
+ * derived. **Content only**: a field placed solely as a scalar's ink, a
1068
+ * claim or a bound widget carries no `span` and returns `[]`, its box being
1069
+ * a single `regions()` rect. Reflects the current compile.
959
1070
  */
960
1071
  fieldBoxes(field: string): FieldRegion[];
961
1072
  /**
@@ -1000,9 +1111,9 @@ export class LiveSession {
1000
1111
  */
1001
1112
  positionAt(page: number, x: number, y: number, tol_pt?: number | null): ContentHit | undefined;
1002
1113
  /**
1003
- * Schema-field geometry for this compiled session: each content field's
1004
- * **first placement** (one region per page it touches) plus widget and
1005
- * scalar-reference-site regions, keyed on the canonical `DocPath` address. A
1114
+ * Schema-field geometry for this compiled session: each piece of generated
1115
+ * ink's **first placement** (one region per page it touches) plus claim and
1116
+ * widget regions, keyed on the canonical `DocPath` address. A
1006
1117
  * field may appear more than once, so group by `field` (see `FieldRegion`).
1007
1118
  * A session-level query: no render, no byte artifact. The click direction is
1008
1119
  * `fieldAt`. Empty for backends that place no schema fields.
@@ -1119,9 +1230,10 @@ export class Quill {
1119
1230
  */
1120
1231
  toTree(): Map<string, Uint8Array>;
1121
1232
  /**
1122
- * Validate `doc` against this quill's schema, returning every diagnostic
1123
- * (empty when the document is valid). Forwards the canonical
1124
- * `validation::*` diagnostics the engine emits.
1233
+ * Validate `doc` against this quill's schema, returning every diagnostic:
1234
+ * an error blocks a render, a warning does not. Forwards the engine's
1235
+ * `validation::*`, a markdown string's `parse::dropped_construct` and the
1236
+ * backend's `backend::declined_construct`.
1125
1237
  */
1126
1238
  validate(doc: Document): Diagnostic[];
1127
1239
  /**
@@ -1165,9 +1277,10 @@ export class Quillmark {
1165
1277
  open(quill: Quill, doc: Document, today?: string | null): LiveSession;
1166
1278
  /**
1167
1279
  * Render `doc` against `quill` in one shot: `open` + `LiveSession.render`,
1168
- * with `doc.warnings`, then every `quill.validate` warning, ahead of the
1169
- * compile's in `warnings`. An unset `output_format` falls back to the
1170
- * backend's first supported format. `today` reads as on `open`.
1280
+ * with every `quill.validate` warning in `warnings`, a decline among the
1281
+ * compile's and the rest ahead of them; the load's stay on `doc.warnings`.
1282
+ * An unset `output_format` falls back to the backend's first supported
1283
+ * format. `today` reads as on `open`.
1171
1284
  */
1172
1285
  render(quill: Quill, doc: Document, opts?: RenderOptions | null, today?: string | null): RenderResult;
1173
1286
  /**
@@ -1198,18 +1311,20 @@ export function exportMarkdown(rt: Content): string;
1198
1311
  export function formatDiagnostic(diagnostic: Diagnostic): string;
1199
1312
 
1200
1313
  /**
1201
- * Serialize structured [`DocPathSeg`] segments back to the canonical path
1314
+ * Serialize structured `DocPathSeg` segments back to the canonical path
1202
1315
  * string: the inverse of `parseDocPath`. Throws on a segment array the
1203
1316
  * deserializer rejects, and on an empty one.
1204
1317
  */
1205
1318
  export function formatDocPath(segs: DocPathSeg[]): string;
1206
1319
 
1207
1320
  /**
1208
- * Import a markdown string to canonical `Content`: the pure, document-free
1209
- * codec. `overwrite(addr, importMarkdown(md))` spells the cold, anchor-losing
1210
- * write; prefer `revise` for edit semantics. Throws on an over-nested input.
1321
+ * Import a markdown string: the pure, document-free codec. Returns the
1322
+ * canonical `content` and a `parse::dropped_construct` warning per construct
1323
+ * the import dropped, with no `path`. `overwrite(addr, importMarkdown(md).content)`
1324
+ * spells the cold, anchor-losing write; prefer `revise` for edit semantics.
1325
+ * Throws on an over-nested input.
1211
1326
  */
1212
- export function importMarkdown(markdown: string): Content;
1327
+ export function importMarkdown(markdown: string): Imported;
1213
1328
 
1214
1329
  /**
1215
1330
  * Whether `content` satisfies the `inline` constraint of `richtext` and
@@ -1257,7 +1372,7 @@ export function mapPos(delta: Delta, pos: number, assoc: Assoc): number;
1257
1372
 
1258
1373
  /**
1259
1374
  * Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
1260
- * `main.body`, `recipients[0].name`) into structured [`DocPathSeg`] segments, so
1375
+ * `main.body`, `recipients[0].name`) into structured `DocPathSeg` segments, so
1261
1376
  * a consumer routes on segments instead of regexing the string. Throws on a
1262
1377
  * malformed path.
1263
1378
  */
@@ -1265,11 +1380,12 @@ export function parseDocPath(path: string): DocPathSeg[];
1265
1380
 
1266
1381
  /**
1267
1382
  * Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
1268
- * returning the new `content` and the text `delta` (offsets are USV indices into
1269
- * `Content.text`, surviving anchors rebased). Throws on an over-nested markdown
1270
- * input or a non-content `base`.
1383
+ * returning the new `content`, the text `delta` (offsets are USV indices into
1384
+ * `Content.text`, surviving anchors rebased), and the import's
1385
+ * `parse::dropped_construct` warnings, with no `path`. Throws on an
1386
+ * over-nested markdown input or a non-content `base`.
1271
1387
  */
1272
- export function rebase(base: Content, markdown: string): { content: Content; delta: Delta };
1388
+ export function rebase(base: Content, markdown: string): { content: Content; delta: Delta; warnings: Diagnostic[] };
1273
1389
 
1274
1390
  /**
1275
1391
  * Runs at instantiation, so a Rust panic reaches the console as a stack trace
@@ -1292,6 +1408,7 @@ export interface InitOutput {
1292
1408
  readonly document__readerGet: (a: number, b: number, c: number, d: number) => void;
1293
1409
  readonly document__readerGetContent: (a: number, b: number, c: number, d: number) => void;
1294
1410
  readonly document__readerGetContentAt: (a: number, b: number, c: number, d: number, e: number) => void;
1411
+ readonly document__reviseDocument: (a: number, b: number, c: number, d: number, e: number) => void;
1295
1412
  readonly document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1296
1413
  readonly document_applyChange: (a: number, b: number, c: number, d: number) => void;
1297
1414
  readonly document_bodyMarkdown: (a: number, b: number, c: number) => void;
@@ -1328,6 +1445,7 @@ export interface InitOutput {
1328
1445
  readonly document_storeField: (a: number, b: number, c: number, d: number) => void;
1329
1446
  readonly document_storeFields: (a: number, b: number, c: number, d: number) => void;
1330
1447
  readonly document_storeSeedOverlay: (a: number, b: number, c: number, d: number, e: number) => void;
1448
+ readonly document_toAnnotatedMarkdown: (a: number, b: number) => void;
1331
1449
  readonly document_toMarkdown: (a: number, b: number) => void;
1332
1450
  readonly document_toStored: (a: number, b: number) => void;
1333
1451
  readonly document_warnings: (a: number, b: number) => void;
@@ -1338,6 +1456,7 @@ export interface InitOutput {
1338
1456
  readonly isInline: (a: number, b: number) => void;
1339
1457
  readonly isPlain: (a: number, b: number) => void;
1340
1458
  readonly livesession_backendId: (a: number, b: number) => void;
1459
+ readonly livesession_coverage: (a: number, b: number) => void;
1341
1460
  readonly livesession_fieldAt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1342
1461
  readonly livesession_fieldBoxes: (a: number, b: number, c: number, d: number) => void;
1343
1462
  readonly livesession_locate: (a: number, b: number, c: number, d: number, e: number) => void;