@quillmark/wasm 0.94.0 → 0.96.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/CHANGELOG.md +71 -318
- package/README.md +60 -43
- package/backends/pdfform/wasm.d.ts +361 -256
- package/backends/pdfform/wasm.js +1 -1
- package/backends/pdfform/wasm_bg.js +532 -458
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +25 -25
- package/backends/typst/wasm.d.ts +361 -256
- package/backends/typst/wasm.js +1 -1
- package/backends/typst/wasm_bg.js +532 -458
- package/backends/typst/wasm_bg.wasm +0 -0
- package/backends/typst/wasm_bg.wasm.d.ts +25 -25
- package/core/wasm.d.ts +346 -242
- package/core/wasm.js +1 -1
- package/core/wasm_bg.js +518 -445
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +25 -25
- package/package.json +1 -1
- package/runtime/runtime.d.ts +205 -37
- package/runtime/runtime.js +214 -29
|
@@ -17,7 +17,7 @@ export type PayloadItem =
|
|
|
17
17
|
/**
|
|
18
18
|
* Paths to `!must_fill` markers nested *inside* `value` (the `value`
|
|
19
19
|
* projection itself is fill-free). Absent when the field has no nested
|
|
20
|
-
* placeholders. Preserved across `
|
|
20
|
+
* placeholders. Preserved across `insertCard` / `makeCard`.
|
|
21
21
|
*/
|
|
22
22
|
nestedFills?: PathStep[][];
|
|
23
23
|
}
|
|
@@ -27,7 +27,7 @@ export type PayloadItem =
|
|
|
27
27
|
* A single card block, as read back from a document: returned by
|
|
28
28
|
* `Document.main` / `Document.cards` / `Document.removeCard` / `Quill.seedCard`
|
|
29
29
|
* / `Document.makeCard`. To feed a card *into* a document use `CardInput`
|
|
30
|
-
* (which `
|
|
30
|
+
* (which `insertCard` accepts); every `Card` is a valid `CardInput`,
|
|
31
31
|
* so a card read from one document pushes straight into another.
|
|
32
32
|
*
|
|
33
33
|
* `$` system entries are hoisted to named fields: `kind` (the `$kind`, empty
|
|
@@ -44,19 +44,19 @@ export interface Card {
|
|
|
44
44
|
seed?: Record<string, unknown>;
|
|
45
45
|
payloadItems: PayloadItem[];
|
|
46
46
|
/**
|
|
47
|
-
* The card body as canonical `
|
|
48
|
-
* Always this
|
|
47
|
+
* The card body as canonical `Content` — the source-of-truth content model.
|
|
48
|
+
* Always this content shape on read, never a markdown string. For the markdown
|
|
49
49
|
* projection call the codec `exportMarkdown(card.body)`. Write a body back
|
|
50
50
|
* with `doc.install(addr, rt)` / `doc.revise(addr, md)`, or via `CardInput.body`.
|
|
51
51
|
*/
|
|
52
|
-
body:
|
|
52
|
+
body: Content;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* A card written *into* a document — the input twin of `Card`, accepted by
|
|
57
|
-
* `Document.
|
|
58
|
-
* takes a markdown `string` (imported to the
|
|
59
|
-
* needn't build the `
|
|
57
|
+
* `Document.insertCard`. Like `Card` but `body` also
|
|
58
|
+
* takes a markdown `string` (imported to the content, so a markdown / LLM writer
|
|
59
|
+
* needn't build the `Content` shape), and every field but `kind` is optional —
|
|
60
60
|
* an absent field defaults (no payload items, an empty body). Write one inline
|
|
61
61
|
* (`{ kind, body }`) or build it with `Document.makeCard`.
|
|
62
62
|
*/
|
|
@@ -67,26 +67,26 @@ export interface CardInput {
|
|
|
67
67
|
ext?: Record<string, unknown>;
|
|
68
68
|
seed?: Record<string, unknown>;
|
|
69
69
|
payloadItems?: PayloadItem[];
|
|
70
|
-
body?:
|
|
70
|
+
body?: Content | string;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Canonical richtext
|
|
74
|
+
* Canonical richtext content — the content model for a card body (and richtext
|
|
75
75
|
* fields). One text sequence over a single coordinate space (Unicode scalar
|
|
76
76
|
* values): `text` plus line attributes, anchored `marks`, and embedded
|
|
77
77
|
* `islands`. Every edit is a splice; markdown is a projection, not the model.
|
|
78
|
-
* Mirrors `
|
|
78
|
+
* Mirrors `quillmark_content::serial`'s canonical JSON encoding.
|
|
79
79
|
*/
|
|
80
|
-
export interface
|
|
80
|
+
export interface Content {
|
|
81
81
|
text: string;
|
|
82
|
-
lines:
|
|
83
|
-
marks:
|
|
84
|
-
islands:
|
|
82
|
+
lines: ContentLine[];
|
|
83
|
+
marks: ContentMark[];
|
|
84
|
+
islands: ContentIsland[];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
/** One `\n`-separated segment of `
|
|
88
|
-
export type
|
|
89
|
-
containers:
|
|
87
|
+
/** One `\n`-separated segment of `Content.text`, in order. */
|
|
88
|
+
export type ContentLine = {
|
|
89
|
+
containers: ContentContainer[];
|
|
90
90
|
/** A within-block hard line break rather than a new block. Omitted (false) in the common case. */
|
|
91
91
|
continues?: boolean;
|
|
92
92
|
} & (
|
|
@@ -98,32 +98,68 @@ export type RichTextLine = {
|
|
|
98
98
|
);
|
|
99
99
|
|
|
100
100
|
/** An ancestor block a line nests inside, outermost first. */
|
|
101
|
-
export type
|
|
101
|
+
export type ContentContainer =
|
|
102
102
|
| { container: "list_item"; ordered: boolean; start: number; ordinal: number }
|
|
103
103
|
| { container: "quote" };
|
|
104
104
|
|
|
105
|
-
/** A mark over char range `[start, end)` into `
|
|
106
|
-
export type
|
|
105
|
+
/** A mark over char range `[start, end)` into `Content.text`. */
|
|
106
|
+
export type ContentMark = { start: number; end: number } & (
|
|
107
107
|
| { type: "strong" | "emph" | "underline" | "strike" | "code" }
|
|
108
108
|
| { type: "link"; url: string }
|
|
109
109
|
| { type: "anchor"; id: string }
|
|
110
110
|
| { type: string; attrs: unknown }
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
-
/** A
|
|
114
|
-
|
|
113
|
+
/** A cell in a `TableProps` — its plain `text` plus the `marks` over it. `marks`
|
|
114
|
+
* rides the same wire shape as prose `ContentMark`, but each mark's `start`/`end`
|
|
115
|
+
* are USV offsets into this cell's `text` (`0..text.length`), not into
|
|
116
|
+
* `Content.text`. */
|
|
117
|
+
export interface TableCell {
|
|
118
|
+
text: string;
|
|
119
|
+
marks: ContentMark[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** `props` of a `type: "table"` island: a pipe table normalized to one column
|
|
123
|
+
* count that `header`, every row of `rows`, and `aligns` all share. */
|
|
124
|
+
export interface TableProps {
|
|
125
|
+
header: TableCell[];
|
|
126
|
+
rows: TableCell[][];
|
|
127
|
+
/** Per-column alignment, one entry per column. */
|
|
128
|
+
aligns: ("none" | "left" | "center" | "right")[];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** `props` of a `type: "image"` island. */
|
|
132
|
+
export interface ImageProps {
|
|
133
|
+
url: string;
|
|
134
|
+
alt: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A structured object occupying one island slot in `Content.text`. `type` is an
|
|
138
|
+
* open set: the engine pins `props` as `TableProps` for `table` and `ImageProps`
|
|
139
|
+
* for `image`; an island of any other type round-trips with opaque `props`. Like
|
|
140
|
+
* `ContentMark`, the open `type` arm means a discriminant check does not itself
|
|
141
|
+
* narrow `props` — key off `type` and read `props` as the matching shape. */
|
|
142
|
+
export type ContentIsland = {
|
|
115
143
|
id: string;
|
|
116
|
-
type: string;
|
|
117
|
-
props: unknown;
|
|
118
144
|
/** How faithfully the markdown projection can carry this island. */
|
|
119
145
|
loss: "lossless" | "degraded" | "unrepresentable";
|
|
120
|
-
}
|
|
146
|
+
} & (
|
|
147
|
+
| { type: "table"; props: TableProps }
|
|
148
|
+
| { type: "image"; props: ImageProps }
|
|
149
|
+
| { type: string; props: unknown }
|
|
150
|
+
);
|
|
121
151
|
|
|
122
152
|
/**
|
|
123
|
-
* A
|
|
124
|
-
* `
|
|
125
|
-
*
|
|
126
|
-
*
|
|
153
|
+
* A write address — one navigation concept for the whole `Document` surface. An
|
|
154
|
+
* absent `field` targets the card body; an absent `card` targets the main card.
|
|
155
|
+
* `{}` is the main-card body; `{ card: 2 }` the body of the composable card at
|
|
156
|
+
* index 2; `{ field: "intro" }` the main card's `intro` field; `{ card: 2,
|
|
157
|
+
* field: "intro" }` a card field.
|
|
158
|
+
*
|
|
159
|
+
* On the `Addr`-taking verbs a **bare string** is shorthand for `{ field: name }`
|
|
160
|
+
* — `doc.storeField("qty", 3)`, `doc.revise("intro", md)` — the one coercion
|
|
161
|
+
* rule. A bare number is *not* an addr (`{ card: 2 }` is the self-documenting
|
|
162
|
+
* spelling), so no third navigation idiom re-fragments the surface.
|
|
127
163
|
*/
|
|
128
164
|
export interface Addr {
|
|
129
165
|
card?: number;
|
|
@@ -131,7 +167,17 @@ export interface Addr {
|
|
|
131
167
|
}
|
|
132
168
|
|
|
133
169
|
/**
|
|
134
|
-
* A
|
|
170
|
+
* A card-only address — the axis the card-scoped verbs (`storeFields`,
|
|
171
|
+
* `storeExt`, `getExt`, `commitFields`, …) take. An absent `card` targets the
|
|
172
|
+
* main card. A present `field` throws: a card address takes only `card`, and a
|
|
173
|
+
* would-be nested write is a bug the error names rather than silently ignores.
|
|
174
|
+
*/
|
|
175
|
+
export interface CardAddr {
|
|
176
|
+
card?: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A text-splice change set over the USV content (CodeMirror `ChangeSet`
|
|
135
181
|
* semantics) — plain, structured-clone-able data. Returned by `revise` and by
|
|
136
182
|
* the `rebase` codec; map a stored position through it with `mapPos`.
|
|
137
183
|
*/
|
|
@@ -143,9 +189,9 @@ export interface Delta {
|
|
|
143
189
|
export type Assoc = "before" | "after";
|
|
144
190
|
|
|
145
191
|
/**
|
|
146
|
-
* A mark edit in
|
|
147
|
-
* `
|
|
148
|
-
* anchor by id.
|
|
192
|
+
* A mark edit in final-text coordinates (post-delta, post-line-op). `add` /
|
|
193
|
+
* `remove` carry the `ContentMark` vocabulary (`{ type, … }`); `removeAnchor`
|
|
194
|
+
* drops one identity anchor by id.
|
|
149
195
|
*/
|
|
150
196
|
export type MarkOp =
|
|
151
197
|
| ({ op: "add" | "remove"; start: number; end: number } & (
|
|
@@ -156,7 +202,13 @@ export type MarkOp =
|
|
|
156
202
|
))
|
|
157
203
|
| { op: "removeAnchor"; id: string };
|
|
158
204
|
|
|
159
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* A line/block edit. `split`/`join` splice `\n`; `setKind`/`setContainers`/
|
|
207
|
+
* `setContinues` touch metadata. `setContinues` sets/clears a line's within-block
|
|
208
|
+
* hard-break flag (`ContentLine.continues`) — the op-grained way to lower a
|
|
209
|
+
* Shift+Enter hard break or a new code-fence interior line; `continues: true` on
|
|
210
|
+
* line 0 is rejected (nothing precedes it to continue).
|
|
211
|
+
*/
|
|
160
212
|
export type LineOp =
|
|
161
213
|
| { op: "split"; at: number }
|
|
162
214
|
| { op: "join"; line: number }
|
|
@@ -165,10 +217,11 @@ export type LineOp =
|
|
|
165
217
|
| { kind: "heading"; level: number }
|
|
166
218
|
| { kind: "code"; lang?: string }
|
|
167
219
|
))
|
|
168
|
-
| { op: "setContainers"; line: number; containers:
|
|
220
|
+
| { op: "setContainers"; line: number; containers: ContentContainer[] }
|
|
221
|
+
| { op: "setContinues"; line: number; continues: boolean };
|
|
169
222
|
|
|
170
223
|
/**
|
|
171
|
-
* A committed
|
|
224
|
+
* A committed content edit bundle for `applyChange`: a text `delta` (default no
|
|
172
225
|
* text change), then `lineOps`, then `markOps` (mark ranges are in post-delta
|
|
173
226
|
* coordinates). Every field is optional.
|
|
174
227
|
*/
|
|
@@ -180,6 +233,21 @@ export interface ChangeBundle {
|
|
|
180
233
|
|
|
181
234
|
|
|
182
235
|
|
|
236
|
+
/**
|
|
237
|
+
* One segment of a parsed `Diagnostic.path` (see `parseDocPath`). The head
|
|
238
|
+
* carries the document-model root — `main` (only before `body`), a `card`
|
|
239
|
+
* (`kind: null` is the unknown-kind `cards[i]` form), or a `field`; the tail is
|
|
240
|
+
* `field` / `index` / a terminal `body`.
|
|
241
|
+
*/
|
|
242
|
+
export type DocPathSeg =
|
|
243
|
+
| { seg: "main" }
|
|
244
|
+
| { seg: "card"; kind: string | null; index: number }
|
|
245
|
+
| { seg: "field"; name: string }
|
|
246
|
+
| { seg: "index"; index: number }
|
|
247
|
+
| { seg: "body" };
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
183
251
|
/**
|
|
184
252
|
* Page dimensions in points (1 pt = 1/72 inch). Typst measures in Typst
|
|
185
253
|
* points; pdfform measures in PDF points — the same unit.
|
|
@@ -265,6 +333,55 @@ export interface PaintResult {
|
|
|
265
333
|
|
|
266
334
|
|
|
267
335
|
|
|
336
|
+
/** The commitment-ladder rung that produced a `ResolvedField.value`. */
|
|
337
|
+
export type FieldSource = "authored" | "default" | "zero";
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* One resolved row: its `name`, the value the render projection would use, and
|
|
341
|
+
* the `FieldSource` rung it came from. Rows are an ordered array — declaration
|
|
342
|
+
* order is structural, not object-key order. The card body is a `body` sibling
|
|
343
|
+
* on its card, never a row in `fields`. Diagnostics stay `Quill.validate`'s;
|
|
344
|
+
* schema guidance (`example:`, labels) reads from `Quill.schema`.
|
|
345
|
+
*/
|
|
346
|
+
export interface ResolvedField {
|
|
347
|
+
name: string;
|
|
348
|
+
value: unknown;
|
|
349
|
+
source: FieldSource;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The main card's resolved rows in declaration order, plus its body row —
|
|
354
|
+
* `null` when the main enables no body.
|
|
355
|
+
*/
|
|
356
|
+
export interface ResolvedMain {
|
|
357
|
+
fields: ResolvedField[];
|
|
358
|
+
body: ResolvedField | null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* One composable card's resolved rows in declaration order, with its authored
|
|
363
|
+
* `kind` (`null` for an unknown-kind card), its document-array `index`, and its
|
|
364
|
+
* body row — `null` when the kind enables no body.
|
|
365
|
+
*/
|
|
366
|
+
export interface ResolvedCard {
|
|
367
|
+
kind: string | null;
|
|
368
|
+
index: number;
|
|
369
|
+
fields: ResolvedField[];
|
|
370
|
+
body: ResolvedField | null;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* The resolved-value view (`Quill.resolve`): the main card and every
|
|
375
|
+
* composable card. Value and provenance only — completeness and errors stay
|
|
376
|
+
* `Quill.validate`.
|
|
377
|
+
*/
|
|
378
|
+
export interface Resolved {
|
|
379
|
+
main: ResolvedMain;
|
|
380
|
+
cards: ResolvedCard[];
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
268
385
|
/** UI layout hints for a single field. Field display order is not a hint:
|
|
269
386
|
* key order in the schema's `fields`/`properties` objects is declaration
|
|
270
387
|
* order, the ordering contract. */
|
|
@@ -275,9 +392,23 @@ export interface QuillFieldUi {
|
|
|
275
392
|
multiline?: boolean;
|
|
276
393
|
}
|
|
277
394
|
|
|
395
|
+
/** One entry in a card's `ui.groups` registry: a display-label override for the
|
|
396
|
+
* group id (the map key). An empty object carries no override — the consumer
|
|
397
|
+
* derives the label from the id (`memo_for` → "Memo For"), as it does a field
|
|
398
|
+
* label from its key. */
|
|
399
|
+
export interface QuillGroupUi {
|
|
400
|
+
title?: string;
|
|
401
|
+
}
|
|
402
|
+
|
|
278
403
|
/** UI layout hints for a card (main or named card kind). */
|
|
279
404
|
export interface QuillCardUi {
|
|
280
405
|
title?: string;
|
|
406
|
+
/** The card's group registry: the ordered table of contents naming every
|
|
407
|
+
* group a field's `ui.group` may reference. The map key is the group id, and
|
|
408
|
+
* key order is declaration order — the display-order contract, the same one
|
|
409
|
+
* `fields` key order carries. Absent when the card declares no groups (or
|
|
410
|
+
* uses the deprecated implicit-group form). */
|
|
411
|
+
groups?: Record<string, QuillGroupUi>;
|
|
281
412
|
}
|
|
282
413
|
|
|
283
414
|
/** Body namespace for a card (main or named card kind). */
|
|
@@ -298,7 +429,7 @@ export interface QuillCardBody {
|
|
|
298
429
|
* zero-fills the field). There is no separate `required` axis.
|
|
299
430
|
*/
|
|
300
431
|
export interface QuillFieldSchema {
|
|
301
|
-
type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "datetime" | "richtext" | "plaintext" | "enum";
|
|
432
|
+
type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "date" | "datetime" | "richtext" | "plaintext" | "enum";
|
|
302
433
|
description?: string;
|
|
303
434
|
default?: unknown;
|
|
304
435
|
example?: unknown;
|
|
@@ -364,7 +495,7 @@ export interface ChangeSet {
|
|
|
364
495
|
dirtyPages: number[];
|
|
365
496
|
}
|
|
366
497
|
|
|
367
|
-
export interface
|
|
498
|
+
export interface ContentHit {
|
|
368
499
|
field: string;
|
|
369
500
|
pos: number;
|
|
370
501
|
granularity?: HitGranularity;
|
|
@@ -423,28 +554,16 @@ export class Document {
|
|
|
423
554
|
free(): void;
|
|
424
555
|
[Symbol.dispose](): void;
|
|
425
556
|
/**
|
|
426
|
-
*
|
|
427
|
-
* body from optional markdown, and append it — the ABI under
|
|
428
|
-
* `writer.addCard`. Fuses `makeCard` + typed commit + `pushCard`
|
|
429
|
-
* transactionally: the card is committed in full before it joins the
|
|
430
|
-
* document, so a rejected field (or an invalid kind or body) leaves the
|
|
431
|
-
* document untouched. Field errors throw the same per-field diagnostic
|
|
432
|
-
* bundle as [`commitFields`](Self::commit_fields), including an
|
|
433
|
-
* `[EditError::UnknownField]` per undeclared name; an invalid kind or body
|
|
434
|
-
* throws a single-entry bundle keyed `$kind` / `$body`.
|
|
435
|
-
*/
|
|
436
|
-
addCard(quill: Quill, kind: string, fields?: Record<string, unknown>, body?: string): void;
|
|
437
|
-
/**
|
|
438
|
-
* **Apply** a committed corpus edit `bundle` (`{ delta?, lineOps?, markOps? }`)
|
|
557
|
+
* **Apply** a committed content edit `bundle` (`{ delta?, lineOps?, markOps? }`)
|
|
439
558
|
* at `addr` — the editor splice: text delta first, then line ops, then mark
|
|
440
|
-
* ops (mark ranges in
|
|
559
|
+
* ops (mark ranges in final-text coordinates), each all-or-nothing. An absent
|
|
441
560
|
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
442
561
|
*
|
|
443
562
|
* Throws on an out-of-range card, a field that is not richtext, a malformed
|
|
444
563
|
* bundle, or an op that applies out of bounds (the value is unchanged on a
|
|
445
564
|
* failed apply).
|
|
446
565
|
*/
|
|
447
|
-
applyChange(addr: Addr, bundle: ChangeBundle): void;
|
|
566
|
+
applyChange(addr: Addr | string, bundle: ChangeBundle): void;
|
|
448
567
|
/**
|
|
449
568
|
* Authoring-ergonomics header introducing a blueprint to an LLM/MCP
|
|
450
569
|
* consumer for the given `quillName`. Re-exposes core's canonical text for
|
|
@@ -452,61 +571,22 @@ export class Document {
|
|
|
452
571
|
* uniform.
|
|
453
572
|
*/
|
|
454
573
|
static blueprintInstruction(quill_name: string): string;
|
|
455
|
-
clone(): Document;
|
|
456
574
|
/**
|
|
457
|
-
*
|
|
458
|
-
* twin of [`
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
* the same typed-mismatch / name errors as `commitField` — including
|
|
463
|
-
* `[EditError::UnknownField]` for a field the card-kind schema does not
|
|
464
|
-
* declare (an unknown `$kind` has no schema, so every field is undeclared).
|
|
465
|
-
*/
|
|
466
|
-
commitCardField(quill: Quill, index: number, name: string, value: any): void;
|
|
467
|
-
/**
|
|
468
|
-
* Batched twin of [`commitCardField`](Document::commit_card_field):
|
|
469
|
-
* typed-commit several fields on the card at `index` atomically, resolving
|
|
470
|
-
* each field's type from the card's `$kind` schema in `quill`. All-or-nothing
|
|
471
|
-
* with the same per-field-diagnostic contract as
|
|
472
|
-
* [`commitFields`](Document::commit_fields), including an
|
|
473
|
-
* `[EditError::UnknownField]` diagnostic per undeclared name. Throws
|
|
474
|
-
* `[EditError::IndexOutOfRange]` when `index` is out of range.
|
|
475
|
-
*/
|
|
476
|
-
commitCardFields(quill: Quill, index: number, fields: Record<string, unknown>): void;
|
|
477
|
-
/**
|
|
478
|
-
* Typed field write on the main card, resolving the field's schema `type`
|
|
479
|
-
* from `quill` — the one write verb for **every** field type (richtext,
|
|
480
|
-
* scalar, array, object). The schema carries the `inline` constraint, so no
|
|
481
|
-
* type token or flag is passed. A richtext-typed field stores the canonical
|
|
482
|
-
* corpus, so identity marks (anchors, island ids) and corpus-only marks
|
|
483
|
-
* (e.g. `underline`) live on it and survive compiles and the storage DTO.
|
|
484
|
-
* Values use the encoding the seam already speaks: a corpus object
|
|
485
|
-
* or markdown string for richtext, a scalar/array/object otherwise.
|
|
486
|
-
*
|
|
487
|
-
* A field declared in the schema is strict-committed — a mismatch throws
|
|
488
|
-
* now, not at render. A name the schema does not declare throws
|
|
489
|
-
* `[EditError::UnknownField]` rather than falling to the opaque store: on
|
|
490
|
-
* the typed path it is a typo. Use [`setField`](Document::set_field) when
|
|
491
|
-
* opaque storage is the intent. Also throws `[EditError::FieldConform]` /
|
|
492
|
-
* `[EditError::FieldRichtextDecode]` / `[EditError::FieldRichtextNotInline]`
|
|
493
|
-
* on a typed mismatch and `[EditError::InvalidFieldName]` on a malformed
|
|
494
|
-
* name.
|
|
495
|
-
*
|
|
496
|
-
* The `quill` handle is passed per call because a `Document` carries only a
|
|
497
|
-
* `$quill` reference, not the resolved schema.
|
|
575
|
+
* A single composable card by index — the whole `Card`, the card-indexed
|
|
576
|
+
* twin of the [`main`](Self::main) getter, so reading one card need not
|
|
577
|
+
* materialize every card via [`cards`](Self::cards). An out-of-range
|
|
578
|
+
* `index` throws `edit::index_out_of_range`, matching the card write
|
|
579
|
+
* verbs.
|
|
498
580
|
*/
|
|
499
|
-
|
|
581
|
+
card(index: number): Card;
|
|
500
582
|
/**
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* error and the thrown error's `diagnostics` carry one entry per offending
|
|
506
|
-
* field, including an `[EditError::UnknownField]` for any name the schema
|
|
507
|
-
* does not declare, so a whole-form submit sees every typo in one pass.
|
|
583
|
+
* The index of the first composable card whose `$id` equals `id`, or
|
|
584
|
+
* `undefined` when none carries it. Resolves the canonical durable address
|
|
585
|
+
* without a hand-rolled scan over [`cards`](Self::cards); `$id` is
|
|
586
|
+
* non-unique by design, so the first match wins.
|
|
508
587
|
*/
|
|
509
|
-
|
|
588
|
+
cardIndexById(id: string): number | undefined;
|
|
589
|
+
clone(): Document;
|
|
510
590
|
/**
|
|
511
591
|
* Schema version this build writes via [`toJson`](Document::to_json).
|
|
512
592
|
* Tracks the `Document` model version (not the running crate version):
|
|
@@ -546,30 +626,54 @@ export class Document {
|
|
|
546
626
|
*/
|
|
547
627
|
static fromMarkdown(markdown: string): Document;
|
|
548
628
|
/**
|
|
549
|
-
* Read
|
|
550
|
-
* object for a richtext field, a scalar/array/object otherwise), or
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
629
|
+
* Read the value at `addr` — the raw stored payload value of a field (a
|
|
630
|
+
* content object for a richtext field, a scalar/array/object otherwise), or
|
|
631
|
+
* the **body content** when `addr.field` is absent. A bare string is `Addr`
|
|
632
|
+
* shorthand for `{ field }`. Reads are total over the field axis: an absent
|
|
633
|
+
* field is `undefined`; only an out-of-range `addr.card` throws
|
|
634
|
+
* `edit::index_out_of_range`. Reads need no schema, so they live on
|
|
635
|
+
* `Document`, not the typed writer; for the markdown projection of a
|
|
636
|
+
* richtext value use [`getMarkdown`](Self::get_markdown).
|
|
637
|
+
*/
|
|
638
|
+
get(addr: Addr | string): unknown;
|
|
639
|
+
/**
|
|
640
|
+
* The whole `$ext` map at `addr` (a card address, absent `card` = main), or
|
|
641
|
+
* `undefined` when the card carries none. The fine-grained `$ext` read —
|
|
642
|
+
* your own state without serializing the whole card. Throws on a present
|
|
643
|
+
* `field` (a card address takes only `card`) or an out-of-range card.
|
|
554
644
|
*/
|
|
555
|
-
|
|
645
|
+
getExt(addr?: CardAddr): Record<string, unknown> | undefined;
|
|
556
646
|
/**
|
|
557
|
-
* The
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
* `bodyMarkdown` getters dropped in #925; call it only when markdown is what
|
|
562
|
-
* you need out.
|
|
647
|
+
* The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
|
|
648
|
+
* = main), or `undefined`. The namespace-scoped `$ext` read — your own slot
|
|
649
|
+
* without a whole-card serialize, and non-destructive (unlike
|
|
650
|
+
* `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
|
|
563
651
|
*/
|
|
564
|
-
|
|
652
|
+
getExtNamespace(addr: CardAddr, ns: string): unknown;
|
|
565
653
|
/**
|
|
566
|
-
*
|
|
567
|
-
* `
|
|
654
|
+
* The **body** markdown projection — the main body, or a composable card's
|
|
655
|
+
* body (`{ card }`) — the on-demand, lossy export (content-only marks do not
|
|
656
|
+
* survive markdown). A body's type is a format fact, not a schema fact, so
|
|
657
|
+
* this read stays quill-free; a body is never absent.
|
|
658
|
+
*
|
|
659
|
+
* `addr` is an optional **card address** (`{ card }`, absent = main). A
|
|
660
|
+
* present `field` throws — a field's markdown is read through the
|
|
661
|
+
* schema-plane `quill.reader(doc).get(field)`, which interprets by declared
|
|
662
|
+
* type (#978). An out-of-range `addr.card` throws.
|
|
568
663
|
*/
|
|
569
|
-
|
|
664
|
+
getMarkdown(addr?: CardAddr): string;
|
|
570
665
|
/**
|
|
571
|
-
*
|
|
572
|
-
*
|
|
666
|
+
* Insert a card — the single insertion verb: `at` absent appends, a number
|
|
667
|
+
* inserts at that index (must be in `0..=cards.length`). Accepts a
|
|
668
|
+
* `CardInput` — a card read back (`cards` / `removeCard` / `quill.seedCard`),
|
|
669
|
+
* a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
|
|
670
|
+
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
671
|
+
* not a valid kind name, or if `at` is out of range.
|
|
672
|
+
*/
|
|
673
|
+
insertCard(card: CardInput, at?: number): void;
|
|
674
|
+
/**
|
|
675
|
+
* **Install** a richtext value at `addr` — **value semantics**, content only.
|
|
676
|
+
* Stores exactly `rt` (a canonical `Content` content object); the identity
|
|
573
677
|
* anchors of any previous value are gone. An absent `addr.field` targets the
|
|
574
678
|
* body, an absent `addr.card` the main card. For "here's new markdown," use
|
|
575
679
|
* [`revise`](Document::revise); the cold-import path is spelled at the call
|
|
@@ -577,9 +681,16 @@ export class Document {
|
|
|
577
681
|
* source.
|
|
578
682
|
*
|
|
579
683
|
* Throws on an out-of-range card, a malformed field name, or an `rt` that is
|
|
580
|
-
* not a canonical
|
|
684
|
+
* not a canonical content object.
|
|
685
|
+
*/
|
|
686
|
+
install(addr: Addr | string, rt: Content): void;
|
|
687
|
+
/**
|
|
688
|
+
* Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
|
|
689
|
+
* shorthand for `{ field }`. `false` for an absent field (truthful — it isn't
|
|
690
|
+
* marked) and for a body address (a body is never a fill). Only an
|
|
691
|
+
* out-of-range `addr.card` throws.
|
|
581
692
|
*/
|
|
582
|
-
|
|
693
|
+
isFill(addr: Addr | string): boolean;
|
|
583
694
|
/**
|
|
584
695
|
* Replace this document's contents **in place** from a versioned storage
|
|
585
696
|
* DTO string — the mutating twin of the static
|
|
@@ -594,10 +705,10 @@ export class Document {
|
|
|
594
705
|
loadJson(json: string): void;
|
|
595
706
|
/**
|
|
596
707
|
* Build a fresh `Card` from a kind and a flat field map — the ergonomic
|
|
597
|
-
* constructor for `
|
|
708
|
+
* constructor for `insertCard`. `fields` is an optional
|
|
598
709
|
* `Record<string, unknown>` (each entry becomes a card field, in
|
|
599
710
|
* insertion order); `body` defaults to `""`. Kind validity is checked by
|
|
600
|
-
* `
|
|
711
|
+
* `insertCard`, not here.
|
|
601
712
|
*/
|
|
602
713
|
static makeCard(kind: string, fields?: Record<string, unknown>, body?: string): Card;
|
|
603
714
|
/**
|
|
@@ -613,14 +724,6 @@ export class Document {
|
|
|
613
724
|
* Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
|
|
614
725
|
*/
|
|
615
726
|
constructor(quill_ref: string);
|
|
616
|
-
/**
|
|
617
|
-
* Append a card to the end of the card list. Accepts a `CardInput` — a card
|
|
618
|
-
* read back (`cards` / `removeCard` / `quill.seedCard`), a
|
|
619
|
-
* [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
|
|
620
|
-
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
621
|
-
* not a valid kind name.
|
|
622
|
-
*/
|
|
623
|
-
pushCard(card: CardInput): void;
|
|
624
727
|
/**
|
|
625
728
|
* The canonical `$quill` reference grammar as author-facing text. Core is
|
|
626
729
|
* the single source of truth: drive schema `describe` and validation
|
|
@@ -631,54 +734,32 @@ export class Document {
|
|
|
631
734
|
static quillRefHint(): string;
|
|
632
735
|
removeCard(index: number): Card | undefined;
|
|
633
736
|
/**
|
|
634
|
-
* Remove the `$ext` map
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
|
|
638
|
-
removeCardExt(index: number): Record<string, unknown> | undefined;
|
|
639
|
-
/**
|
|
640
|
-
* Remove `namespace` from the composable card's `$ext` map, returning the
|
|
641
|
-
* value stored there or `undefined`; clears `$ext` entirely once empty.
|
|
642
|
-
* The card-indexed twin of `removeExtNamespace`. Throws if out of range.
|
|
643
|
-
*/
|
|
644
|
-
removeCardExtNamespace(index: number, namespace: string): any;
|
|
645
|
-
/**
|
|
646
|
-
* Remove a field on the card at `index`. Returns the removed value or
|
|
647
|
-
* `undefined`. Throws if `index` is out of range or `name` is invalid.
|
|
648
|
-
*/
|
|
649
|
-
removeCardField(index: number, name: string): any;
|
|
650
|
-
/**
|
|
651
|
-
* Remove the `$ext` map from the main card *entirely*, returning the
|
|
652
|
-
* previous map or `undefined`. This is a blunt escape hatch that discards
|
|
653
|
-
* every namespace at once — prefer `removeExtNamespace` to clear only your
|
|
654
|
-
* own slot while leaving sibling consumers' state intact.
|
|
737
|
+
* Remove the `$ext` map on the card `addr` targets *entirely*, returning the
|
|
738
|
+
* previous map or `undefined` — a blunt escape hatch that discards every
|
|
739
|
+
* namespace at once (prefer `removeExtNamespace`). `addr` is a card address
|
|
740
|
+
* (absent = main). Throws on a present `field` or an out-of-range card.
|
|
655
741
|
*/
|
|
656
|
-
removeExt(): Record<string, unknown> | undefined;
|
|
742
|
+
removeExt(addr?: CardAddr): Record<string, unknown> | undefined;
|
|
657
743
|
/**
|
|
658
|
-
* Remove `
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
744
|
+
* Remove `$ext[ns]` on the card `addr` targets, returning its value or
|
|
745
|
+
* `undefined`; drops `$ext` once empty. `addr` is a card address (absent =
|
|
746
|
+
* main). Preserves sibling namespaces. Throws on a present `field` or an
|
|
747
|
+
* out-of-range card.
|
|
662
748
|
*/
|
|
663
|
-
removeExtNamespace(
|
|
749
|
+
removeExtNamespace(addr: CardAddr, ns: string): any;
|
|
664
750
|
/**
|
|
665
|
-
* Remove a
|
|
666
|
-
*
|
|
751
|
+
* Remove a field at `addr`, returning the removed value or `undefined`. A
|
|
752
|
+
* bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
|
|
753
|
+
* every write lane. A body address throws; throws on an out-of-range card or
|
|
754
|
+
* a malformed name.
|
|
667
755
|
*/
|
|
668
|
-
removeField(
|
|
756
|
+
removeField(addr: Addr | string): any;
|
|
669
757
|
/**
|
|
670
758
|
* Remove `cardKind` from the main card's `$seed` map, returning its
|
|
671
|
-
* overlay or `undefined`; drops `$seed` entirely once empty. Sibling
|
|
672
|
-
*
|
|
759
|
+
* overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
|
|
760
|
+
* survive. `$seed` is main-only, so this takes no address.
|
|
673
761
|
*/
|
|
674
762
|
removeSeedNamespace(card_kind: string): any;
|
|
675
|
-
/**
|
|
676
|
-
* **Deprecated** — alias for `revise({}, markdown)`, kept one release cycle.
|
|
677
|
-
* Revise the main card's body from a markdown string (edit semantics: a
|
|
678
|
-
* `diff_import` that rebases surviving anchors). Discards the text delta;
|
|
679
|
-
* call [`revise`](Document::revise) to receive it.
|
|
680
|
-
*/
|
|
681
|
-
replaceBody(body: string): void;
|
|
682
763
|
/**
|
|
683
764
|
* **Revise** the richtext value at `addr` from a markdown string — **edit
|
|
684
765
|
* semantics**, the default write path, returning the text [`Delta`]. Imports
|
|
@@ -688,9 +769,9 @@ export class Document {
|
|
|
688
769
|
* absent `addr.card` the main card; an absent field cold-imports from empty.
|
|
689
770
|
*
|
|
690
771
|
* Throws on an out-of-range card, a malformed field name, a present
|
|
691
|
-
* non-
|
|
772
|
+
* non-content field value, or an over-nested markdown input.
|
|
692
773
|
*/
|
|
693
|
-
revise(addr: Addr, markdown: string): Delta;
|
|
774
|
+
revise(addr: Addr | string, markdown: string): Delta;
|
|
694
775
|
/**
|
|
695
776
|
* Read the `schema` version tag from a raw storage DTO string without a
|
|
696
777
|
* full parse, or `undefined`. Returns unknown future versions as-is —
|
|
@@ -699,30 +780,13 @@ export class Document {
|
|
|
699
780
|
*/
|
|
700
781
|
static schemaVersionOf(json: string): string | undefined;
|
|
701
782
|
/**
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* Merge `value` into the composable card's `$ext` map under `namespace`,
|
|
709
|
-
* preserving sibling namespaces. The card-indexed twin of `setExtNamespace`.
|
|
710
|
-
* Throws if out of range or `value` cannot be serialized.
|
|
711
|
-
*/
|
|
712
|
-
setCardExtNamespace(index: number, namespace: string, value: any): void;
|
|
713
|
-
/**
|
|
714
|
-
* Set a field on the card at `index` — the card-indexed twin of
|
|
715
|
-
* [`setField`](Document::set_field). Stores the value opaquely.
|
|
716
|
-
* Throws if `index` is out of range, `name` is reserved or invalid.
|
|
717
|
-
*/
|
|
718
|
-
setCardField(index: number, name: string, value: any): void;
|
|
719
|
-
/**
|
|
720
|
-
* Batched twin of [`setCardField`](Document::set_card_field): set
|
|
721
|
-
* several fields on the card at `index` atomically. Same all-or-nothing,
|
|
722
|
-
* one-diagnostic-per-field contract as [`setFields`](Document::set_fields).
|
|
723
|
-
* Throws if `index` is out of range.
|
|
783
|
+
* The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
|
|
784
|
+
* entry), or `undefined` when absent. The cheap read that feeds
|
|
785
|
+
* `quill.seedCard(kind, overlay)` without serializing the whole main card
|
|
786
|
+
* via [`main`](Self::main) to fish out one key — and it keeps `seedCard`
|
|
787
|
+
* pure: the quill still never reads the document.
|
|
724
788
|
*/
|
|
725
|
-
|
|
789
|
+
seedOverlay(kind: string): Record<string, unknown> | undefined;
|
|
726
790
|
/**
|
|
727
791
|
* Replace the kind of the card at `index`. Payload and body are untouched;
|
|
728
792
|
* schema-aware migration is the caller's responsibility.
|
|
@@ -730,50 +794,61 @@ export class Document {
|
|
|
730
794
|
*/
|
|
731
795
|
setCardKind(index: number, new_kind: string): void;
|
|
732
796
|
/**
|
|
733
|
-
* Replace the
|
|
734
|
-
* object; throws otherwise. `$ext` carries out-of-band consumer state and
|
|
735
|
-
* never reaches the rendered output. Pass `{}` to record an explicit
|
|
736
|
-
* empty `$ext`.
|
|
797
|
+
* Replace the QUILL reference string. Throws if `ref_str` is invalid.
|
|
737
798
|
*/
|
|
738
|
-
|
|
799
|
+
setQuillRef(ref_str: string): void;
|
|
739
800
|
/**
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
* `$ext
|
|
801
|
+
* Replace the opaque `$ext` map on the card `addr` targets (a card address,
|
|
802
|
+
* absent `card` = main). `value` must be a plain object. `$ext` carries
|
|
803
|
+
* out-of-band consumer state and never reaches the rendered output; pass
|
|
804
|
+
* `{}` for an explicit empty `$ext`. Quill-free and verbatim — an opaque
|
|
805
|
+
* `store` verb. Throws on a present `field` or an out-of-range card.
|
|
744
806
|
*/
|
|
745
|
-
|
|
807
|
+
storeExt(addr: CardAddr, value: any): void;
|
|
746
808
|
/**
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
809
|
+
* Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
|
|
810
|
+
* sibling namespaces — the recommended `$ext` write. `addr` is a card
|
|
811
|
+
* address (absent = main). Quill-free and verbatim — an opaque `store` verb.
|
|
812
|
+
* Throws on a present `field` or an out-of-range card.
|
|
750
813
|
*/
|
|
751
|
-
|
|
814
|
+
storeExtNamespace(addr: CardAddr, ns: string, value: any): void;
|
|
752
815
|
/**
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
816
|
+
* Store a field verbatim at `addr` — the opaque store (**store** = verbatim,
|
|
817
|
+
* coercion deferred to render; the typed write is
|
|
818
|
+
* [`commitField`](Document::commit_field)). A bare string is `Addr`
|
|
819
|
+
* shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
|
|
820
|
+
* `{ card: 2, field: "qty" }` targets a composable card. Clears any
|
|
821
|
+
* `!must_fill` marker. A body address (no `field`) throws — a body is never
|
|
822
|
+
* opaque; write it with `revise` / `install` / `writer.setBody`. Throws on
|
|
823
|
+
* an out-of-range card or a malformed name.
|
|
759
824
|
*/
|
|
760
|
-
|
|
825
|
+
storeField(addr: Addr | string, value: any): void;
|
|
761
826
|
/**
|
|
762
|
-
*
|
|
763
|
-
*
|
|
827
|
+
* Store several fields verbatim and atomically on the card `addr` targets —
|
|
828
|
+
* the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
|
|
829
|
+
* = main); a present `field` throws. The batch verb takes the address first
|
|
830
|
+
* and is never shape-overloaded, because `card` is a legal field name:
|
|
831
|
+
* `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
|
|
832
|
+
* fields)` a composable one — never ambiguous with "set field `card`".
|
|
833
|
+
* Nothing is applied on error; the thrown error's `diagnostics` carry one
|
|
834
|
+
* entry per offending field. Throws on an out-of-range card.
|
|
764
835
|
*/
|
|
765
|
-
|
|
836
|
+
storeFields(addr: CardAddr, fields: Record<string, unknown>): void;
|
|
766
837
|
/**
|
|
767
|
-
*
|
|
838
|
+
* Store a field verbatim at `addr` and mark it `!must_fill` — the opaque
|
|
839
|
+
* store's fill variant, card-capable (a bare string or `{ field }` for main,
|
|
840
|
+
* `{ card, field }` for a composable card). A body address throws. Same
|
|
841
|
+
* validation as [`storeField`](Document::store_field).
|
|
768
842
|
*/
|
|
769
|
-
|
|
843
|
+
storeFill(addr: Addr | string, value: any): void;
|
|
770
844
|
/**
|
|
771
|
-
* Merge a card-kind's seed `overlay` into the main card's `$seed` map
|
|
772
|
-
* under `cardKind`, preserving sibling kinds
|
|
773
|
-
*
|
|
774
|
-
*
|
|
845
|
+
* Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
|
|
846
|
+
* under `cardKind`, preserving sibling kinds — `$seed` lives on the main
|
|
847
|
+
* card by model, so this takes no address. Sets the starting values new
|
|
848
|
+
* cards of that kind spawn with. Quill-free and verbatim — an opaque `store`
|
|
849
|
+
* verb. Throws if `overlay` cannot be serialized or nests too deep.
|
|
775
850
|
*/
|
|
776
|
-
|
|
851
|
+
storeSeedNamespace(card_kind: string, overlay: any): void;
|
|
777
852
|
/**
|
|
778
853
|
* Serialize this document to a versioned storage DTO string.
|
|
779
854
|
*
|
|
@@ -841,8 +916,8 @@ export class LiveSession {
|
|
|
841
916
|
/**
|
|
842
917
|
* The schema field whose content is under a point on `page` — the
|
|
843
918
|
* forward (click → field) direction: hit-test a click against the
|
|
844
|
-
* compiled document and get back the field address to focus in
|
|
845
|
-
* editor, or `undefined` off any field's ink. `x`/`y` are PDF points
|
|
919
|
+
* compiled document and get back the `DocPath` field address to focus in
|
|
920
|
+
* the editor, or `undefined` off any field's ink. `x`/`y` are PDF points
|
|
846
921
|
* with a **bottom-left** origin, the same space as `FieldRegion.rect` —
|
|
847
922
|
* from a canvas click, invert the overlay transform documented on
|
|
848
923
|
* `FieldRegion`: `x = clickPx.x / renderScale`,
|
|
@@ -863,8 +938,8 @@ export class LiveSession {
|
|
|
863
938
|
*/
|
|
864
939
|
fieldBoxes(field: string): FieldRegion[];
|
|
865
940
|
/**
|
|
866
|
-
* A
|
|
867
|
-
* a field and a USV offset into its `
|
|
941
|
+
* A content position → **caret rect** — the reverse of `positionAt`: given
|
|
942
|
+
* a field and a USV offset into its `Content`, return the box (in the
|
|
868
943
|
* same bottom-left PDF-point space as `FieldRegion.rect`) to draw a caret
|
|
869
944
|
* at, its `span` collapsed to `[pos, pos]`; `undefined` when the field
|
|
870
945
|
* places no tracked content or the offset maps to no drawn glyph.
|
|
@@ -893,24 +968,25 @@ export class LiveSession {
|
|
|
893
968
|
*/
|
|
894
969
|
paint(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, page: number, opts: PaintOptions | undefined): PaintResult;
|
|
895
970
|
/**
|
|
896
|
-
* A point → **
|
|
971
|
+
* A point → **content position** — the fine-grained click direction:
|
|
897
972
|
* hit-test a point and get back the field *and* a USV offset into its
|
|
898
|
-
* `
|
|
973
|
+
* `Content` (for placing a caret or mapping a selection into the content
|
|
899
974
|
* model), or `undefined` off all content ink. `x`/`y` are PDF points,
|
|
900
975
|
* bottom-left origin — the same space as `fieldAt`. The offset is
|
|
901
976
|
* cluster-exact and degrades to the containing segment's start on
|
|
902
977
|
* origin-less ink (list markers, a code fence's interior). See
|
|
903
|
-
* `
|
|
978
|
+
* `ContentHit`.
|
|
904
979
|
*/
|
|
905
|
-
positionAt(page: number, x: number, y: number):
|
|
980
|
+
positionAt(page: number, x: number, y: number): ContentHit | undefined;
|
|
906
981
|
/**
|
|
907
982
|
* Schema-field geometry for this compiled session — each content field's
|
|
908
983
|
* **first placement** (one region per page it touches) plus widget and
|
|
909
|
-
* scalar-reference-site regions, keyed on the
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
*
|
|
984
|
+
* scalar-reference-site regions, keyed on the canonical `DocPath` address
|
|
985
|
+
* (`parseDocPath`-routable; the session resolves the backend's plate-space
|
|
986
|
+
* per-kind ordinal to it); a field may still appear more than once (group
|
|
987
|
+
* by `field`, see `FieldRegion`). A session-level query: no render, no byte
|
|
988
|
+
* artifact. An interactive preview reads it to scroll to / highlight the
|
|
989
|
+
* focused field over a `paint`-ed canvas; the click direction is `fieldAt`.
|
|
914
990
|
* Empty for backends that place no schema fields.
|
|
915
991
|
*/
|
|
916
992
|
regions(): FieldRegion[];
|
|
@@ -949,14 +1025,25 @@ export class Quill {
|
|
|
949
1025
|
* canonical shape.
|
|
950
1026
|
*/
|
|
951
1027
|
static fromTree(tree: Map<string, Uint8Array>): Quill;
|
|
1028
|
+
/**
|
|
1029
|
+
* The resolved-value view of `doc` against this quill's schema — for every
|
|
1030
|
+
* declared field the value the render projection would use and the
|
|
1031
|
+
* `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
|
|
1032
|
+
* one call. The card body rides the `fields` map under the `$body` key.
|
|
1033
|
+
*
|
|
1034
|
+
* Value and provenance only: completeness and errors stay `validate`'s
|
|
1035
|
+
* (a consumer merges it with its own diagnostic producers regardless), and
|
|
1036
|
+
* schema guidance reads from `Quill.schema`.
|
|
1037
|
+
*/
|
|
1038
|
+
resolve(doc: Document): Resolved;
|
|
952
1039
|
/**
|
|
953
1040
|
* Seed a starter composable `Card` of the given kind (carries `$kind`),
|
|
954
1041
|
* layering an optional per-kind seed `overlay` over the schema-example
|
|
955
1042
|
* base (`overlay › example › absent`). Returns `undefined` if `cardKind`
|
|
956
1043
|
* is not declared in this quill's schema, else a `Card` that feeds
|
|
957
|
-
* straight into `Document.
|
|
1044
|
+
* straight into `Document.insertCard`.
|
|
958
1045
|
*
|
|
959
|
-
* Pass `document.
|
|
1046
|
+
* Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
|
|
960
1047
|
* template-derived document inherits its curated starting values; omit it
|
|
961
1048
|
* (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
|
|
962
1049
|
* plain object — this reads the document, it does not mutate it.
|
|
@@ -1062,19 +1149,28 @@ export class Quillmark {
|
|
|
1062
1149
|
}
|
|
1063
1150
|
|
|
1064
1151
|
/**
|
|
1065
|
-
* Export a canonical `
|
|
1066
|
-
* codec
|
|
1067
|
-
*
|
|
1152
|
+
* Export a canonical `Content` content to its markdown projection — the pure
|
|
1153
|
+
* on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
|
|
1154
|
+
* canonical content.
|
|
1068
1155
|
*/
|
|
1069
|
-
export function exportMarkdown(rt:
|
|
1156
|
+
export function exportMarkdown(rt: Content): string;
|
|
1070
1157
|
|
|
1071
1158
|
/**
|
|
1072
|
-
*
|
|
1159
|
+
* Serialize structured [`DocPathSeg`] segments back to the canonical path
|
|
1160
|
+
* string — the inverse of `parseDocPath`, for a consumer that builds a path
|
|
1161
|
+
* rather than reads one. Throws on a segment array the deserializer rejects,
|
|
1162
|
+
* and on an empty segment array (symmetric with `parseDocPath("")`, which
|
|
1163
|
+
* throws "empty path").
|
|
1164
|
+
*/
|
|
1165
|
+
export function formatDocPath(segs: DocPathSeg[]): string;
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Import a markdown string to a canonical `Content` content — the pure,
|
|
1073
1169
|
* document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
|
|
1074
1170
|
* the cold (anchor-losing) write at the call site; prefer `revise` for edit
|
|
1075
1171
|
* semantics. Throws on an over-nested input.
|
|
1076
1172
|
*/
|
|
1077
|
-
export function importMarkdown(markdown: string):
|
|
1173
|
+
export function importMarkdown(markdown: string): Content;
|
|
1078
1174
|
|
|
1079
1175
|
/**
|
|
1080
1176
|
* Initialize the WASM module with panic hooks for better error messages
|
|
@@ -1082,7 +1178,7 @@ export function importMarkdown(markdown: string): RichText;
|
|
|
1082
1178
|
export function init(): void;
|
|
1083
1179
|
|
|
1084
1180
|
/**
|
|
1085
|
-
* Map a base
|
|
1181
|
+
* Map a base content position through a `delta` to its new position — the pure
|
|
1086
1182
|
* position-mapping codec an editor bridge composes to hold a caret stable
|
|
1087
1183
|
* across a `revise`. `assoc` decides the side of a same-position insertion
|
|
1088
1184
|
* (`"after"` moves past it). Throws on a malformed `delta`.
|
|
@@ -1090,10 +1186,19 @@ export function init(): void;
|
|
|
1090
1186
|
export function mapPos(delta: Delta, pos: number, assoc: Assoc): number;
|
|
1091
1187
|
|
|
1092
1188
|
/**
|
|
1093
|
-
*
|
|
1094
|
-
* `
|
|
1189
|
+
* Parse a canonical document-model `Diagnostic.path`
|
|
1190
|
+
* (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
|
|
1191
|
+
* structured [`DocPathSeg`] segments — the exported inverse of the engine's
|
|
1192
|
+
* one path serializer, so a consumer routes on segments instead of regexing
|
|
1193
|
+
* the string. Throws on a malformed path.
|
|
1194
|
+
*/
|
|
1195
|
+
export function parseDocPath(path: string): DocPathSeg[];
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Rebase `markdown` onto a `base` content — the pure, document-free twin of
|
|
1199
|
+
* `revise`: cold-import + `diff_import`, returning the new `content` and the
|
|
1095
1200
|
* text `delta` (surviving anchors rebased). Use it to compute a revise without
|
|
1096
1201
|
* a document in hand; `revise(addr, md)` fuses this with the store for
|
|
1097
|
-
* atomicity. Throws on an over-nested markdown input or a non-
|
|
1202
|
+
* atomicity. Throws on an over-nested markdown input or a non-content `base`.
|
|
1098
1203
|
*/
|
|
1099
|
-
export function rebase(base:
|
|
1204
|
+
export function rebase(base: Content, markdown: string): { content: Content; delta: Delta };
|