@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
package/core/wasm_bg.wasm
CHANGED
|
Binary file
|
package/core/wasm_bg.wasm.d.ts
CHANGED
|
@@ -3,69 +3,69 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_document_free: (a: number, b: number) => void;
|
|
5
5
|
export const __wbg_quill_free: (a: number, b: number) => void;
|
|
6
|
-
export const
|
|
6
|
+
export const document__addCard: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
7
|
+
export const document__commitField: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
|
+
export const document__commitFields: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
9
|
+
export const document__readerGet: (a: number, b: number, c: number, d: number) => void;
|
|
10
|
+
export const document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
7
11
|
export const document_applyChange: (a: number, b: number, c: number, d: number) => void;
|
|
8
12
|
export const document_blueprintInstruction: (a: number, b: number, c: number) => void;
|
|
13
|
+
export const document_card: (a: number, b: number, c: number) => void;
|
|
9
14
|
export const document_cardCount: (a: number) => number;
|
|
15
|
+
export const document_cardIndexById: (a: number, b: number, c: number) => number;
|
|
10
16
|
export const document_cards: (a: number, b: number) => void;
|
|
11
17
|
export const document_clone: (a: number) => number;
|
|
12
|
-
export const document_commitCardField: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
13
|
-
export const document_commitCardFields: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
14
|
-
export const document_commitField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
15
|
-
export const document_commitFields: (a: number, b: number, c: number, d: number) => void;
|
|
16
18
|
export const document_currentSchemaVersion: (a: number) => void;
|
|
17
19
|
export const document_equals: (a: number, b: number) => number;
|
|
18
20
|
export const document_formatDiagnostic: (a: number, b: number) => void;
|
|
19
21
|
export const document_formatRules: (a: number) => void;
|
|
20
22
|
export const document_fromJson: (a: number, b: number, c: number) => void;
|
|
21
23
|
export const document_fromMarkdown: (a: number, b: number, c: number) => void;
|
|
22
|
-
export const document_get: (a: number, b: number, c: number
|
|
23
|
-
export const
|
|
24
|
+
export const document_get: (a: number, b: number, c: number) => void;
|
|
25
|
+
export const document_getExt: (a: number, b: number, c: number) => void;
|
|
26
|
+
export const document_getExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
27
|
+
export const document_getMarkdown: (a: number, b: number, c: number) => void;
|
|
24
28
|
export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
|
|
25
29
|
export const document_install: (a: number, b: number, c: number, d: number) => void;
|
|
30
|
+
export const document_isFill: (a: number, b: number, c: number) => void;
|
|
26
31
|
export const document_loadJson: (a: number, b: number, c: number, d: number) => void;
|
|
27
32
|
export const document_main: (a: number, b: number) => void;
|
|
28
33
|
export const document_makeCard: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
29
34
|
export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
|
|
30
35
|
export const document_new: (a: number, b: number, c: number) => void;
|
|
31
|
-
export const document_pushCard: (a: number, b: number, c: number) => void;
|
|
32
36
|
export const document_quillRef: (a: number, b: number) => void;
|
|
33
37
|
export const document_quillRefHint: (a: number) => void;
|
|
34
38
|
export const document_removeCard: (a: number, b: number, c: number) => void;
|
|
35
|
-
export const
|
|
36
|
-
export const
|
|
37
|
-
export const
|
|
38
|
-
export const document_removeExt: (a: number, b: number) => void;
|
|
39
|
-
export const document_removeExtNamespace: (a: number, b: number, c: number, d: number) => void;
|
|
40
|
-
export const document_removeField: (a: number, b: number, c: number, d: number) => void;
|
|
39
|
+
export const document_removeExt: (a: number, b: number, c: number) => void;
|
|
40
|
+
export const document_removeExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
41
|
+
export const document_removeField: (a: number, b: number, c: number) => void;
|
|
41
42
|
export const document_removeSeedNamespace: (a: number, b: number, c: number, d: number) => void;
|
|
42
|
-
export const document_replaceBody: (a: number, b: number, c: number, d: number) => void;
|
|
43
43
|
export const document_revise: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
44
44
|
export const document_schemaVersionOf: (a: number, b: number, c: number) => void;
|
|
45
|
-
export const
|
|
46
|
-
export const document_setCardExtNamespace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
47
|
-
export const document_setCardField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
48
|
-
export const document_setCardFields: (a: number, b: number, c: number, d: number) => void;
|
|
45
|
+
export const document_seedOverlay: (a: number, b: number, c: number, d: number) => void;
|
|
49
46
|
export const document_setCardKind: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
50
|
-
export const document_setExt: (a: number, b: number, c: number) => void;
|
|
51
|
-
export const document_setExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
52
|
-
export const document_setField: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
53
|
-
export const document_setFields: (a: number, b: number, c: number) => void;
|
|
54
|
-
export const document_setFill: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
55
47
|
export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
|
|
56
|
-
export const
|
|
48
|
+
export const document_storeExt: (a: number, b: number, c: number, d: number) => void;
|
|
49
|
+
export const document_storeExtNamespace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
50
|
+
export const document_storeField: (a: number, b: number, c: number, d: number) => void;
|
|
51
|
+
export const document_storeFields: (a: number, b: number, c: number, d: number) => void;
|
|
52
|
+
export const document_storeFill: (a: number, b: number, c: number, d: number) => void;
|
|
53
|
+
export const document_storeSeedNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
57
54
|
export const document_toJson: (a: number, b: number) => void;
|
|
58
55
|
export const document_toMarkdown: (a: number, b: number) => void;
|
|
59
56
|
export const document_tryFromJson: (a: number, b: number) => number;
|
|
60
57
|
export const document_warnings: (a: number, b: number) => void;
|
|
61
58
|
export const exportMarkdown: (a: number, b: number) => void;
|
|
59
|
+
export const formatDocPath: (a: number, b: number) => void;
|
|
62
60
|
export const importMarkdown: (a: number, b: number, c: number) => void;
|
|
63
61
|
export const init: () => void;
|
|
64
62
|
export const mapPos: (a: number, b: number, c: number, d: number) => void;
|
|
63
|
+
export const parseDocPath: (a: number, b: number, c: number) => void;
|
|
65
64
|
export const quill_backendId: (a: number, b: number) => void;
|
|
66
65
|
export const quill_blueprint: (a: number, b: number) => void;
|
|
67
66
|
export const quill_fromTree: (a: number, b: number) => void;
|
|
68
67
|
export const quill_metadata: (a: number, b: number) => void;
|
|
68
|
+
export const quill_resolve: (a: number, b: number, c: number) => void;
|
|
69
69
|
export const quill_schema: (a: number, b: number) => void;
|
|
70
70
|
export const quill_seedCard: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
71
71
|
export const quill_seedDocument: (a: number) => number;
|
package/package.json
CHANGED
package/runtime/runtime.d.ts
CHANGED
|
@@ -14,8 +14,23 @@
|
|
|
14
14
|
// public entry point, so this is a structural fact. Replacing the re-export
|
|
15
15
|
// with a wrapper is a breaking design change, not a refactor. See runtime.js.
|
|
16
16
|
export { Quill, Document, init } from '../core/wasm.js';
|
|
17
|
-
// The document-free
|
|
17
|
+
// The document-free content codec, re-exported from the core build.
|
|
18
18
|
export { importMarkdown, exportMarkdown, rebase, mapPos } from '../core/wasm.js';
|
|
19
|
+
// The document-model path parser/serializer — route on `Diagnostic.path`
|
|
20
|
+
// segments instead of regexing the string.
|
|
21
|
+
export { parseDocPath, formatDocPath } from '../core/wasm.js';
|
|
22
|
+
|
|
23
|
+
import type { CardAddr } from '../core/wasm.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The main card's address — the default target of the card-scoped verbs
|
|
27
|
+
* (`storeFields` / `storeExt` / `commitFields` / …). A named, {@link CardAddr}-typed
|
|
28
|
+
* alias for the empty address `{}`, so a main-card write names its target:
|
|
29
|
+
* `doc.storeFields(MAIN_CARD_ADDR, fields)`. It IS `{}` (frozen at runtime), a
|
|
30
|
+
* pure alias — `{}` and `undefined` stay equally valid. A card selector only,
|
|
31
|
+
* never a field address.
|
|
32
|
+
*/
|
|
33
|
+
export declare const MAIN_CARD_ADDR: CardAddr;
|
|
19
34
|
|
|
20
35
|
// Core-build types consumers read off `Quill`/`Document`.
|
|
21
36
|
export type {
|
|
@@ -30,9 +45,53 @@ export type {
|
|
|
30
45
|
QuillCardBody,
|
|
31
46
|
QuillFieldUi,
|
|
32
47
|
QuillCardUi,
|
|
48
|
+
QuillGroupUi,
|
|
33
49
|
QuillMetadata
|
|
34
50
|
} from '../core/wasm.js';
|
|
35
51
|
|
|
52
|
+
// Content edit vocabulary — the op-grained content model `Document`'s methods
|
|
53
|
+
// speak (`applyChange(addr, bundle)`, `install(addr, rt)`, `revise(…) => Delta`).
|
|
54
|
+
// Declared in the core build; re-exported here so the single public entry point
|
|
55
|
+
// names every type its own re-exported surface already references — `Card.body`
|
|
56
|
+
// is a `Content`, `PayloadItem.nestedFills` a `PathStep[][]`, `CardInput.body` a
|
|
57
|
+
// `Content | string` — rather than forcing consumers to derive them structurally
|
|
58
|
+
// off the `Document` handle. The content write path (a ProseMirror↔content codec)
|
|
59
|
+
// must name all of them; they are its correctness core, not edge types.
|
|
60
|
+
export type {
|
|
61
|
+
Content,
|
|
62
|
+
ContentLine,
|
|
63
|
+
ContentContainer,
|
|
64
|
+
ContentMark,
|
|
65
|
+
ContentIsland,
|
|
66
|
+
TableProps,
|
|
67
|
+
ImageProps,
|
|
68
|
+
TableCell,
|
|
69
|
+
CardInput,
|
|
70
|
+
PathStep,
|
|
71
|
+
Addr,
|
|
72
|
+
CardAddr,
|
|
73
|
+
Delta,
|
|
74
|
+
Assoc,
|
|
75
|
+
LineOp,
|
|
76
|
+
MarkOp,
|
|
77
|
+
ChangeBundle,
|
|
78
|
+
DocPathSeg
|
|
79
|
+
} from '../core/wasm.js';
|
|
80
|
+
|
|
81
|
+
// The resolved-value view — the return shape of `quill.resolve(doc)`. Value
|
|
82
|
+
// + source rung per declared field (the body rides the fields map under
|
|
83
|
+
// `$body`); diagnostics stay `quill.validate`, guidance stays `quill.schema`.
|
|
84
|
+
// Declared in the core build's generated `.d.ts` via a
|
|
85
|
+
// `typescript_custom_section`; re-exported here so the single public entry
|
|
86
|
+
// point names them.
|
|
87
|
+
export type {
|
|
88
|
+
FieldSource,
|
|
89
|
+
ResolvedField,
|
|
90
|
+
ResolvedMain,
|
|
91
|
+
ResolvedCard,
|
|
92
|
+
Resolved
|
|
93
|
+
} from '../core/wasm.js';
|
|
94
|
+
|
|
36
95
|
// ── Error contract ──────────────────────────────────────────────────────────
|
|
37
96
|
|
|
38
97
|
/**
|
|
@@ -96,11 +155,11 @@ export interface RenderOptions {
|
|
|
96
155
|
}
|
|
97
156
|
|
|
98
157
|
/**
|
|
99
|
-
* How precisely a {@link
|
|
158
|
+
* How precisely a {@link ContentHit.pos} resolved — the marker a caret UI reads
|
|
100
159
|
* to decide whether to trust the offset. Never sub-cluster: `'cluster'` is the
|
|
101
160
|
* finest, `'segment'` the floor it degrades to on origin-less ink.
|
|
102
161
|
*
|
|
103
|
-
* - `'cluster'` — `pos` is the first
|
|
162
|
+
* - `'cluster'` — `pos` is the first content char of the cluster under the point
|
|
104
163
|
* (an escaped/CJK/shaping cluster floors to its first char). Place the caret
|
|
105
164
|
* at `pos` directly.
|
|
106
165
|
* - `'segment'` — the point hit origin-less ink (list markers, numbering, a
|
|
@@ -109,8 +168,12 @@ export interface RenderOptions {
|
|
|
109
168
|
*/
|
|
110
169
|
export type HitGranularity = 'cluster' | 'segment';
|
|
111
170
|
|
|
112
|
-
/** A click resolved to a field and USV offset into its
|
|
113
|
-
export interface
|
|
171
|
+
/** A click resolved to a field and USV offset into its Content. */
|
|
172
|
+
export interface ContentHit {
|
|
173
|
+
/**
|
|
174
|
+
* The field's canonical `DocPath` address (`parseDocPath`-routable) — the same
|
|
175
|
+
* address {@link LiveSession.fieldAt} returns for that point.
|
|
176
|
+
*/
|
|
114
177
|
field: string;
|
|
115
178
|
pos: number;
|
|
116
179
|
/**
|
|
@@ -121,8 +184,8 @@ export interface CorpusHit {
|
|
|
121
184
|
}
|
|
122
185
|
|
|
123
186
|
/**
|
|
124
|
-
* A rendered field region: the
|
|
125
|
-
* geometry (`rect`) on the page. Emitted by backends that place schema fields
|
|
187
|
+
* A rendered field region: the canonical `DocPath` field address (`field`) plus
|
|
188
|
+
* its geometry (`rect`) on the page. Emitted by backends that place schema fields
|
|
126
189
|
* (`pdfform` AcroForm widgets; Typst form-fields and span-tracked content —
|
|
127
190
|
* richtext bodies, `richtext[]` elements, card content fields, direct scalar
|
|
128
191
|
* references). Only fields with a schema address produce a region — a
|
|
@@ -158,15 +221,20 @@ export interface CorpusHit {
|
|
|
158
221
|
* ```
|
|
159
222
|
*/
|
|
160
223
|
export interface FieldRegion {
|
|
161
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* The field's canonical `DocPath` address (`parseDocPath`-routable), not a
|
|
226
|
+
* backend widget name: `main.signature_block` for a main field,
|
|
227
|
+
* `cards.<kind>[<i>].signature_block` for a card field (`cards[<i>].…` when the
|
|
228
|
+
* card's kind is unknown).
|
|
229
|
+
*/
|
|
162
230
|
field: string;
|
|
163
231
|
/** 0-based page index. */
|
|
164
232
|
page: number;
|
|
165
233
|
/** `[x0, y0, x1, y1]` in PDF points (1/72″), bottom-left origin. */
|
|
166
234
|
rect: [number, number, number, number];
|
|
167
235
|
/**
|
|
168
|
-
* The
|
|
169
|
-
* `
|
|
236
|
+
* The content slice this box covers — USV `[start, end)` into the field's
|
|
237
|
+
* `Content` for content ink (one segment), absent for a scalar reference
|
|
170
238
|
* site or widget. Consumers key segment highlights on it;
|
|
171
239
|
* {@link LiveSession.fieldBoxes} unions same-page segments for the
|
|
172
240
|
* whole-field box.
|
|
@@ -353,11 +421,11 @@ export declare class LiveSession {
|
|
|
353
421
|
apply(doc: Document): ChangeSet;
|
|
354
422
|
render(options?: RenderOptions): RenderResult;
|
|
355
423
|
/**
|
|
356
|
-
* Schema-field geometry for this compiled session, keyed on
|
|
357
|
-
*
|
|
358
|
-
* to scroll to / highlight the focused
|
|
359
|
-
* the click direction is {@link fieldAt}.
|
|
360
|
-
* no schema fields.
|
|
424
|
+
* Schema-field geometry for this compiled session, keyed on the canonical
|
|
425
|
+
* `DocPath` address (`parseDocPath`-routable). A session-level query: no
|
|
426
|
+
* render, no byte artifact. Read it to scroll to / highlight the focused
|
|
427
|
+
* field over a `paint`-ed canvas; the click direction is {@link fieldAt}.
|
|
428
|
+
* Empty for backends that place no schema fields.
|
|
361
429
|
*
|
|
362
430
|
* `field` is **not** unique: a content field surfaces its **first
|
|
363
431
|
* placement** as one {@link FieldRegion} per page that placement touches
|
|
@@ -370,9 +438,10 @@ export declare class LiveSession {
|
|
|
370
438
|
*/
|
|
371
439
|
regions(): FieldRegion[];
|
|
372
440
|
/**
|
|
373
|
-
* The whole-field highlight boxes for `field`
|
|
374
|
-
*
|
|
375
|
-
*
|
|
441
|
+
* The whole-field highlight boxes for `field` (a canonical `DocPath` address,
|
|
442
|
+
* as {@link regions} keys) — one union rect per page, over the field's
|
|
443
|
+
* `span`-bearing content segments (the "highlight the focused field"
|
|
444
|
+
* quantity). Owns the union {@link regions} leaves derived
|
|
376
445
|
* (span-filter + per-page union), keeping `regions()` the low-level disjoint
|
|
377
446
|
* truth, so a consumer stops reimplementing it. **Content only** — a field
|
|
378
447
|
* placed solely as a scalar reference or a bound widget carries no `span`
|
|
@@ -383,21 +452,25 @@ export declare class LiveSession {
|
|
|
383
452
|
/**
|
|
384
453
|
* The schema field whose content is under a point on `page` — the forward
|
|
385
454
|
* (click → field) direction: hit-test a click against the compiled
|
|
386
|
-
* document and get back the field address
|
|
387
|
-
* `
|
|
388
|
-
* **bottom-left** origin, the
|
|
389
|
-
* from a canvas click, invert the
|
|
455
|
+
* document and get back the canonical `DocPath` field address
|
|
456
|
+
* (`parseDocPath`-routable) to focus in the editor, or `undefined` off any
|
|
457
|
+
* field's ink. `x`/`y` are PDF points with a **bottom-left** origin, the
|
|
458
|
+
* same space as {@link FieldRegion.rect} — from a canvas click, invert the
|
|
459
|
+
* overlay transform documented there:
|
|
390
460
|
* `x = clickPx.x / renderScale`,
|
|
391
461
|
* `y = pageHeightPt - clickPx.y / renderScale`. Unlike {@link regions},
|
|
392
462
|
* *every* placement answers, not just the first.
|
|
393
463
|
*/
|
|
394
464
|
fieldAt(page: number, x: number, y: number): string | undefined;
|
|
395
465
|
/**
|
|
396
|
-
* Fine-grained click →
|
|
466
|
+
* Fine-grained click → content position (caret placement). Same PDF-point
|
|
397
467
|
* space as {@link fieldAt}; `undefined` off all content ink.
|
|
398
468
|
*/
|
|
399
|
-
positionAt(page: number, x: number, y: number):
|
|
400
|
-
/**
|
|
469
|
+
positionAt(page: number, x: number, y: number): ContentHit | undefined;
|
|
470
|
+
/**
|
|
471
|
+
* Content position → caret rect — reverse of {@link positionAt}. `field` is a
|
|
472
|
+
* canonical `DocPath` address (`parseDocPath`-routable), as {@link regions} keys.
|
|
473
|
+
*/
|
|
401
474
|
locate(field: string, pos: number): FieldRegion | undefined;
|
|
402
475
|
/** Page geometry in points (1/72″). Report-only; the painter sizes the canvas. */
|
|
403
476
|
pageSize(page: number): PageSize;
|
|
@@ -429,7 +502,7 @@ export declare class LiveSession {
|
|
|
429
502
|
free(): void;
|
|
430
503
|
}
|
|
431
504
|
|
|
432
|
-
// ── Typed writer — the
|
|
505
|
+
// ── Typed writer — the schema-bound front door ───────────────────────────────
|
|
433
506
|
|
|
434
507
|
// `quill.writer(doc)` is patched onto the re-exported `Quill` prototype (the
|
|
435
508
|
// class is re-exported verbatim, so the method is declared by merging into the
|
|
@@ -444,21 +517,30 @@ declare module '../core/wasm.js' {
|
|
|
444
517
|
* ephemeral by convention — bind, write, discard.
|
|
445
518
|
*/
|
|
446
519
|
writer(doc: Document): DocumentWriter;
|
|
520
|
+
/**
|
|
521
|
+
* Bind this quill's schema to `doc` for interpreted reads — the read twin of
|
|
522
|
+
* {@link Quill.writer}, mirroring core's `quill.reader(&doc)`. Each field is
|
|
523
|
+
* read by its declared type (a richtext field to markdown, every other type
|
|
524
|
+
* verbatim) with schema authority, so a name the schema does not declare
|
|
525
|
+
* throws rather than reading back `undefined`. Holds both handles by
|
|
526
|
+
* reference and owns neither (nothing to `free()`); ephemeral by convention —
|
|
527
|
+
* bind, read, discard.
|
|
528
|
+
*/
|
|
529
|
+
reader(doc: Document): DocumentReader;
|
|
447
530
|
}
|
|
448
531
|
}
|
|
449
532
|
|
|
450
533
|
/**
|
|
451
|
-
* A `Document` bound to its `Quill` for typed writes — the
|
|
452
|
-
* constructed via {@link Quill.writer}. Speaks names, values, and markdown
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* reference and owns neither — nothing to `free()`.
|
|
534
|
+
* A `Document` bound to its `Quill` for typed writes — the schema-bound writer,
|
|
535
|
+
* constructed via {@link Quill.writer}. Speaks names, values, and markdown. Bare
|
|
536
|
+
* `set` / `setAll` / `setBody` / `reviseField` / `addCard` / `card(i).set`
|
|
537
|
+
* instead of threading the `quill` handle through the underscored ABI. Holds both
|
|
538
|
+
* handles by reference and owns neither — nothing to `free()`.
|
|
457
539
|
*
|
|
458
540
|
* Typed commit is the default whenever a quill is in hand: it resolves each
|
|
459
541
|
* field's schema type and strict-commits it, throwing `UnknownField` for a name
|
|
460
542
|
* the schema does not declare — on the typed path an undeclared name is a typo,
|
|
461
|
-
* not a fallback. The raw `Document.
|
|
543
|
+
* not a fallback. The raw `Document.storeField` / `storeFields` verbs remain the
|
|
462
544
|
* deliberate quill-free primitive (standalone data, storage/migration infra, or
|
|
463
545
|
* holding not-yet-conforming in-progress input).
|
|
464
546
|
*/
|
|
@@ -483,13 +565,23 @@ export declare class DocumentWriter {
|
|
|
483
565
|
* `Delta` receipt.
|
|
484
566
|
*/
|
|
485
567
|
setBody(markdown: string): void;
|
|
568
|
+
/**
|
|
569
|
+
* Revise the richtext main-card field `name` from markdown — typed *and*
|
|
570
|
+
* anchor-preserving. Surviving anchors rebase, then the diffed result is
|
|
571
|
+
* schema-conformed (`richtext(inline)` rejects a multi-block result). Throws
|
|
572
|
+
* `UnknownField` for a name the schema does not declare. Returns the `Delta`.
|
|
573
|
+
*/
|
|
574
|
+
reviseField(name: string, markdown: string): Delta;
|
|
486
575
|
/**
|
|
487
576
|
* Build a composable card of `kind`, typed-commit `fields` onto it, set its
|
|
488
|
-
* body from optional markdown, and
|
|
489
|
-
* commit + `
|
|
490
|
-
*
|
|
577
|
+
* body from optional markdown, and place it — the fused `makeCard` + typed
|
|
578
|
+
* commit + insertion. `at` picks the position: omitted appends, a number
|
|
579
|
+
* inserts at that index, so a positioned typed insert is one atomic call
|
|
580
|
+
* rather than `addCard` + `moveCard`. Transactional: a rejected field (throws
|
|
581
|
+
* a per-field diagnostic bundle) or an invalid kind/body/position leaves the
|
|
582
|
+
* document untouched.
|
|
491
583
|
*/
|
|
492
|
-
addCard(kind: string, fields?: Record<string, unknown>, body?: string): void;
|
|
584
|
+
addCard(kind: string, fields?: Record<string, unknown>, body?: string, at?: number): void;
|
|
493
585
|
/** Remove the composable card at `index`, returning it (or `undefined`). */
|
|
494
586
|
removeCard(index: number): Card | undefined;
|
|
495
587
|
/**
|
|
@@ -511,8 +603,84 @@ export declare class CardWriter {
|
|
|
511
603
|
constructor(quill: Quill, doc: Document, index: number);
|
|
512
604
|
/** The bound card index. */
|
|
513
605
|
readonly index: number;
|
|
606
|
+
/**
|
|
607
|
+
* The bound card's `$kind` (empty string when it carries none), read through
|
|
608
|
+
* the document — mirrors core `CardWriter::kind()`. Throws `IndexOutOfRange`
|
|
609
|
+
* if the bound index is out of range.
|
|
610
|
+
*/
|
|
611
|
+
readonly kind: string;
|
|
514
612
|
set(name: string, value: unknown): void;
|
|
515
613
|
setAll(fields: Record<string, unknown>): void;
|
|
516
614
|
/** Set this card's body from markdown (edit semantics), discarding the delta. */
|
|
517
615
|
setBody(markdown: string): void;
|
|
616
|
+
/**
|
|
617
|
+
* Revise the richtext field `name` on this card from markdown — typed *and*
|
|
618
|
+
* anchor-preserving; the card twin of {@link DocumentWriter.reviseField}.
|
|
619
|
+
* Throws `UnknownField` for an undeclared name and `IndexOutOfRange` if the
|
|
620
|
+
* bound index is out of range. Returns the `Delta`.
|
|
621
|
+
*/
|
|
622
|
+
reviseField(name: string, markdown: string): Delta;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* A `Document` bound to its `Quill` for interpreted reads — the schema-plane read
|
|
627
|
+
* surface, constructed via {@link Quill.reader} and the read twin of
|
|
628
|
+
* {@link DocumentWriter}. One `get` reads each field by its declared type: a
|
|
629
|
+
* richtext field to its markdown projection, a plaintext field to its literal
|
|
630
|
+
* text, every other type its canonical value verbatim. Holds both handles by
|
|
631
|
+
* reference and owns neither — nothing to `free()`.
|
|
632
|
+
*
|
|
633
|
+
* The schema authority is the point: unlike the quill-free transport `Document.get`,
|
|
634
|
+
* a name the schema does not declare throws `UnknownField` (a typo) rather than
|
|
635
|
+
* reading back `undefined`, and a content field holding a value that does not
|
|
636
|
+
* decode throws `FieldRichtextDecode`. A field's markdown lives here, not on the
|
|
637
|
+
* body-only `Document.getMarkdown`. The body read stays quill-free (a body's type
|
|
638
|
+
* is a format fact) and never throws.
|
|
639
|
+
*/
|
|
640
|
+
export declare class DocumentReader {
|
|
641
|
+
constructor(quill: Quill, doc: Document);
|
|
642
|
+
/** The bound document — the instance passed in. */
|
|
643
|
+
readonly document: Document;
|
|
644
|
+
/**
|
|
645
|
+
* Read the value at `addr`, interpreted by its declared type: a richtext field
|
|
646
|
+
* to markdown, every other type verbatim. A bare string is `Addr` shorthand for
|
|
647
|
+
* `{ field }`; an absent `addr.field` reads the body markdown. `undefined` for
|
|
648
|
+
* an absent field; throws `UnknownField` for a name the schema does not declare,
|
|
649
|
+
* `FieldRichtextDecode` for a richtext field holding an undecodable value, and
|
|
650
|
+
* `IndexOutOfRange` for a bad `addr.card`.
|
|
651
|
+
*/
|
|
652
|
+
get(addr: Addr | string): unknown;
|
|
653
|
+
/** The main body's markdown — the quill-free body read. Equals `get({})`. */
|
|
654
|
+
getBody(): string;
|
|
655
|
+
/**
|
|
656
|
+
* A {@link CardReader} for the composable card at `index`. Index validity is
|
|
657
|
+
* checked lazily at read time, so this never throws. The cursor is ephemeral —
|
|
658
|
+
* a `removeCard`/`addCard` between binding and reading silently retargets it.
|
|
659
|
+
*/
|
|
660
|
+
card(index: number): CardReader;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* A composable card bound to its `Quill` for interpreted reads, from
|
|
665
|
+
* {@link DocumentReader.card}. Same verbs as {@link DocumentReader}, reading the card
|
|
666
|
+
* at its bound index; each read throws `IndexOutOfRange` if that index is out of
|
|
667
|
+
* range.
|
|
668
|
+
*/
|
|
669
|
+
export declare class CardReader {
|
|
670
|
+
constructor(quill: Quill, doc: Document, index: number);
|
|
671
|
+
/** The bound card index. */
|
|
672
|
+
readonly index: number;
|
|
673
|
+
/**
|
|
674
|
+
* The bound card's `$kind` (empty string when it carries none). Throws
|
|
675
|
+
* `IndexOutOfRange` if the bound index is out of range.
|
|
676
|
+
*/
|
|
677
|
+
readonly kind: string;
|
|
678
|
+
/**
|
|
679
|
+
* Read the field `name` on this card, interpreted by its declared type.
|
|
680
|
+
* `undefined` when absent; throws `UnknownField` for an undeclared name and
|
|
681
|
+
* `IndexOutOfRange` for a bad index.
|
|
682
|
+
*/
|
|
683
|
+
get(name: string): unknown;
|
|
684
|
+
/** This card's body markdown — the card twin of {@link DocumentReader.getBody}. */
|
|
685
|
+
getBody(): string;
|
|
518
686
|
}
|