@quillmark/wasm 0.99.0 → 0.101.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 +108 -104
- package/README.md +54 -5
- package/backends/pdfform/wasm.d.ts +99 -17
- package/backends/pdfform/wasm_bg.js +138 -23
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +3 -1
- package/backends/typst/wasm.d.ts +99 -17
- package/backends/typst/wasm_bg.js +138 -23
- package/backends/typst/wasm_bg.wasm +0 -0
- package/backends/typst/wasm_bg.wasm.d.ts +3 -1
- package/core/wasm.d.ts +99 -17
- package/core/wasm_bg.js +138 -23
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +3 -1
- package/package.json +1 -1
- package/runtime/runtime.d.ts +36 -9
- package/runtime/runtime.js +43 -14
|
@@ -169,7 +169,48 @@ export class Document {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
|
-
*
|
|
172
|
+
* Interpreted **corpus** read at `addr`: the stable ABI under the runtime
|
|
173
|
+
* `reader.getContent` / `reader.card(i).getContent`. The corpus twin of
|
|
174
|
+
* [`reader.get`](Self::reader_get), which projects; this decodes the stored
|
|
175
|
+
* value through the codec the field's declared type names (`richtext` as
|
|
176
|
+
* markdown, `plaintext` as literal text) and returns the canonical `Content`.
|
|
177
|
+
*
|
|
178
|
+
* Total over the storage form: a committed field holds a content object and
|
|
179
|
+
* a parsed one holds the authored string, and both read back as a corpus
|
|
180
|
+
* here, so a consumer mounting a corpus editor stops branching on how the
|
|
181
|
+
* document was built.
|
|
182
|
+
*
|
|
183
|
+
* A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
|
|
184
|
+
* targets a composable card. Returns `undefined` for an **absent** field. An
|
|
185
|
+
* absent `addr.field` reads the **body** corpus, quill-free, mirroring
|
|
186
|
+
* [`getStored`](Self::get_stored). Throws `edit::unknown_field` for a name
|
|
187
|
+
* the schema does not declare, `edit::field_not_content` for a declared type
|
|
188
|
+
* that is not a content leaf (`array<richtext>` carries content and still has
|
|
189
|
+
* no one corpus), `edit::field_richtext_decode` for a stored value
|
|
190
|
+
* that decodes under neither encoding, and `edit::index_out_of_range` for a
|
|
191
|
+
* bad `addr.card`.
|
|
192
|
+
* @param {Quill} quill
|
|
193
|
+
* @param {Addr | string} addr
|
|
194
|
+
* @returns {Content | undefined}
|
|
195
|
+
*/
|
|
196
|
+
_readerGetContent(quill, addr) {
|
|
197
|
+
try {
|
|
198
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
199
|
+
_assertClass(quill, Quill);
|
|
200
|
+
wasm.document__readerGetContent(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr));
|
|
201
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
202
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
203
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
204
|
+
if (r2) {
|
|
205
|
+
throw takeObject(r1);
|
|
206
|
+
}
|
|
207
|
+
return takeObject(r0);
|
|
208
|
+
} finally {
|
|
209
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Revise the content field at `addr` from authored text, typed *and*
|
|
173
214
|
* anchor-preserving: the ABI under `writer.reviseField`. Resolves the
|
|
174
215
|
* field's schema from `quill` (main card, or the addressed card's `$kind`)
|
|
175
216
|
* and defers to [`TypedWriter::revise_field`](quillmark_core::TypedWriter::revise_field):
|
|
@@ -178,6 +219,9 @@ export class Document {
|
|
|
178
219
|
* multi-block result with `edit::field_richtext_not_inline`. Returns the
|
|
179
220
|
* text `Delta`.
|
|
180
221
|
*
|
|
222
|
+
* The codec is the declared type's: `richtext` diffs markdown, `plaintext`
|
|
223
|
+
* the literal text.
|
|
224
|
+
*
|
|
181
225
|
* `addr` must name a field (a bare string is `{ field }`); a body address
|
|
182
226
|
* throws (a body carries no field schema: use [`revise`](Self::revise)). A
|
|
183
227
|
* name the schema does not declare throws `edit::unknown_field`. Throws
|
|
@@ -185,14 +229,14 @@ export class Document {
|
|
|
185
229
|
* `writer.reviseField` in the runtime layer.
|
|
186
230
|
* @param {Quill} quill
|
|
187
231
|
* @param {Addr | string} addr
|
|
188
|
-
* @param {string}
|
|
232
|
+
* @param {string} text
|
|
189
233
|
* @returns {Delta}
|
|
190
234
|
*/
|
|
191
|
-
_reviseField(quill, addr,
|
|
235
|
+
_reviseField(quill, addr, text) {
|
|
192
236
|
try {
|
|
193
237
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
194
238
|
_assertClass(quill, Quill);
|
|
195
|
-
const ptr0 = passStringToWasm0(
|
|
239
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
196
240
|
const len0 = WASM_VECTOR_LEN;
|
|
197
241
|
wasm.document__reviseField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), ptr0, len0);
|
|
198
242
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -207,11 +251,16 @@ export class Document {
|
|
|
207
251
|
}
|
|
208
252
|
}
|
|
209
253
|
/**
|
|
210
|
-
* **Apply** a committed content edit `bundle`
|
|
211
|
-
*
|
|
212
|
-
*
|
|
254
|
+
* **Apply** a committed content edit `bundle`
|
|
255
|
+
* (`{ delta?, islandOps?, lineOps?, markOps? }`) at `addr`, the editor
|
|
256
|
+
* splice: text delta first, then island ops, then line ops, then mark ops
|
|
257
|
+
* (mark ranges in final-text coordinates), each all-or-nothing. An absent
|
|
213
258
|
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
214
259
|
*
|
|
260
|
+
* The island channel keeps a table or image edit on the op path: it moves
|
|
261
|
+
* the island alone, so the anchors elsewhere in the field survive an edit
|
|
262
|
+
* `install` would clear.
|
|
263
|
+
*
|
|
215
264
|
* Throws on an out-of-range card, a field that is not richtext, a malformed
|
|
216
265
|
* bundle, or an op that applies out of bounds (the value is unchanged on a
|
|
217
266
|
* failed apply).
|
|
@@ -289,20 +338,6 @@ export class Document {
|
|
|
289
338
|
const ret = wasm.document_cardCount(this.__wbg_ptr);
|
|
290
339
|
return ret >>> 0;
|
|
291
340
|
}
|
|
292
|
-
/**
|
|
293
|
-
* The index of the composable card whose `$id` equals `id`, or
|
|
294
|
-
* `undefined` when none carries it. Resolves the durable card handle
|
|
295
|
-
* without a hand-rolled scan over [`cards`](Self::cards); `$id` is
|
|
296
|
-
* unique per document, so at most one card matches.
|
|
297
|
-
* @param {string} id
|
|
298
|
-
* @returns {number | undefined}
|
|
299
|
-
*/
|
|
300
|
-
cardIndexById(id) {
|
|
301
|
-
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
302
|
-
const len0 = WASM_VECTOR_LEN;
|
|
303
|
-
const ret = wasm.document_cardIndexById(this.__wbg_ptr, ptr0, len0);
|
|
304
|
-
return takeObject(ret);
|
|
305
|
-
}
|
|
306
341
|
/**
|
|
307
342
|
* @returns {Card[]}
|
|
308
343
|
*/
|
|
@@ -536,8 +571,7 @@ export class Document {
|
|
|
536
571
|
}
|
|
537
572
|
/**
|
|
538
573
|
* Read the **verbatim stored value** at `addr`: the raw payload value of a
|
|
539
|
-
* field
|
|
540
|
-
* otherwise), or the **body content** when `addr.field` is absent. A bare
|
|
574
|
+
* field, or the **body content** when `addr.field` is absent. A bare
|
|
541
575
|
* string is `Addr` shorthand for `{ field }`. Reads are total over the field
|
|
542
576
|
* axis: an absent field is `undefined`; only an out-of-range `addr.card`
|
|
543
577
|
* throws `edit::index_out_of_range`. Needs no schema, so it lives on
|
|
@@ -545,6 +579,16 @@ export class Document {
|
|
|
545
579
|
* the interpreted schema-plane [`reader.get`](Self::reader_get). For the
|
|
546
580
|
* markdown projection use [`getMarkdown`](Self::get_markdown) (body) or
|
|
547
581
|
* `reader.get` (a field's declared type).
|
|
582
|
+
*
|
|
583
|
+
* **A content field at rest has one stored form per codec**: a `richtext`
|
|
584
|
+
* field holds the canonical content object, a `plaintext` field its literal
|
|
585
|
+
* string. A document that came through the bound door (`quill.parse` /
|
|
586
|
+
* `quill.conform`) is at rest, so this read no longer depends on which lane
|
|
587
|
+
* built it. A document that came through the transport door
|
|
588
|
+
* (`Document.fromMarkdown`, a legacy stored row) may rest as authored until
|
|
589
|
+
* it is conformed, and this read reports what is there. For the corpus
|
|
590
|
+
* either way, use the schema-plane `reader.getContent`, which decodes
|
|
591
|
+
* through the codec the field's declared type names.
|
|
548
592
|
* @param {Addr | string} addr
|
|
549
593
|
* @returns {unknown}
|
|
550
594
|
*/
|
|
@@ -1254,6 +1298,10 @@ export class Document {
|
|
|
1254
1298
|
return ret === 0 ? undefined : Document.__wrap(ret);
|
|
1255
1299
|
}
|
|
1256
1300
|
/**
|
|
1301
|
+
* The non-fatal diagnostics of the load that produced this document: parse
|
|
1302
|
+
* warnings, plus the `conform::*` warnings when it came through
|
|
1303
|
+
* `quill.parse`. Session state, not document value: `equals` and the
|
|
1304
|
+
* storage DTO exclude it, and `fromJson` / `loadJson` clear it.
|
|
1257
1305
|
* @returns {Diagnostic[]}
|
|
1258
1306
|
*/
|
|
1259
1307
|
get warnings() {
|
|
@@ -1649,6 +1697,40 @@ export class Quill {
|
|
|
1649
1697
|
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
1650
1698
|
}
|
|
1651
1699
|
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Land `doc`'s declared content fields at their canonical rest **in
|
|
1702
|
+
* place**, returning the `conform::*` diagnostics for the values that would
|
|
1703
|
+
* not commit (an empty array when everything rested).
|
|
1704
|
+
*
|
|
1705
|
+
* The read-repair verb: a document that arrived through the transport door
|
|
1706
|
+
* (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
|
|
1707
|
+
* eligible for rewrite under its current schema tag. Idempotent, and a
|
|
1708
|
+
* no-op on an already-canonical document: an equal value is not rewritten,
|
|
1709
|
+
* so YAML comments and stored bytes survive.
|
|
1710
|
+
*
|
|
1711
|
+
* A `!must_fill` marker anywhere in a field's value skips that field (the
|
|
1712
|
+
* marker is the state), and a value the strict write refuses stays as
|
|
1713
|
+
* authored with a diagnostic. Throws when `doc` declares a different
|
|
1714
|
+
* `$quill`, before any mutation.
|
|
1715
|
+
* @param {Document} doc
|
|
1716
|
+
* @returns {Diagnostic[]}
|
|
1717
|
+
*/
|
|
1718
|
+
conform(doc) {
|
|
1719
|
+
try {
|
|
1720
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1721
|
+
_assertClass(doc, Document);
|
|
1722
|
+
wasm.quill_conform(retptr, this.__wbg_ptr, doc.__wbg_ptr);
|
|
1723
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1724
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1725
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1726
|
+
if (r2) {
|
|
1727
|
+
throw takeObject(r1);
|
|
1728
|
+
}
|
|
1729
|
+
return takeObject(r0);
|
|
1730
|
+
} finally {
|
|
1731
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1652
1734
|
/**
|
|
1653
1735
|
* Build a quill from a file tree. Pure: no backend, no engine; the
|
|
1654
1736
|
* declared backend is resolved later, at render time.
|
|
@@ -1697,6 +1779,39 @@ export class Quill {
|
|
|
1697
1779
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1698
1780
|
}
|
|
1699
1781
|
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Parse `markdown` and conform it against this quill: the **primary
|
|
1784
|
+
* ingestion path**, and the bound twin of the schema-free
|
|
1785
|
+
* `Document.fromMarkdown`. The returned document rests at its canonical
|
|
1786
|
+
* form (a `richtext` field as a content object, a `plaintext` field as its
|
|
1787
|
+
* literal string), so `getStored` no longer answers "corpus or string?"
|
|
1788
|
+
* with "depends how this document was built".
|
|
1789
|
+
*
|
|
1790
|
+
* Parse warnings and the `conform::*` diagnostics both land on
|
|
1791
|
+
* `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
|
|
1792
|
+
* `$quill` this quill does not answer to: nothing conforms under the wrong
|
|
1793
|
+
* schema. To open a document whose `$quill` is stale, use the transport
|
|
1794
|
+
* door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
|
|
1795
|
+
* @param {string} markdown
|
|
1796
|
+
* @returns {Document}
|
|
1797
|
+
*/
|
|
1798
|
+
parse(markdown) {
|
|
1799
|
+
try {
|
|
1800
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1801
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1802
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1803
|
+
wasm.quill_parse(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1804
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1805
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1806
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1807
|
+
if (r2) {
|
|
1808
|
+
throw takeObject(r1);
|
|
1809
|
+
}
|
|
1810
|
+
return Document.__wrap(r0);
|
|
1811
|
+
} finally {
|
|
1812
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1700
1815
|
/**
|
|
1701
1816
|
* The resolved-value view of `doc` against this quill's schema: for every
|
|
1702
1817
|
* declared field the value the render projection would use and the
|
|
Binary file
|
|
@@ -9,12 +9,12 @@ export const document__addCard: (a: number, b: number, c: number, d: number, e:
|
|
|
9
9
|
export const document__commitField: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
10
|
export const document__commitFields: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
11
11
|
export const document__readerGet: (a: number, b: number, c: number, d: number) => void;
|
|
12
|
+
export const document__readerGetContent: (a: number, b: number, c: number, d: number) => void;
|
|
12
13
|
export const document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
13
14
|
export const document_applyChange: (a: number, b: number, c: number, d: number) => void;
|
|
14
15
|
export const document_blueprintInstruction: (a: number, b: number, c: number) => void;
|
|
15
16
|
export const document_card: (a: number, b: number, c: number) => void;
|
|
16
17
|
export const document_cardCount: (a: number) => number;
|
|
17
|
-
export const document_cardIndexById: (a: number, b: number, c: number) => number;
|
|
18
18
|
export const document_cards: (a: number, b: number) => void;
|
|
19
19
|
export const document_clone: (a: number) => number;
|
|
20
20
|
export const document_currentSchemaVersion: (a: number) => void;
|
|
@@ -78,8 +78,10 @@ export const mapPos: (a: number, b: number, c: number, d: number) => void;
|
|
|
78
78
|
export const parseDocPath: (a: number, b: number, c: number) => void;
|
|
79
79
|
export const quill_backendId: (a: number, b: number) => void;
|
|
80
80
|
export const quill_blueprint: (a: number, b: number) => void;
|
|
81
|
+
export const quill_conform: (a: number, b: number, c: number) => void;
|
|
81
82
|
export const quill_fromTree: (a: number, b: number) => void;
|
|
82
83
|
export const quill_metadata: (a: number, b: number) => void;
|
|
84
|
+
export const quill_parse: (a: number, b: number, c: number, d: number) => void;
|
|
83
85
|
export const quill_resolve: (a: number, b: number, c: number) => void;
|
|
84
86
|
export const quill_schema: (a: number, b: number) => void;
|
|
85
87
|
export const quill_seedCard: (a: number, b: number, c: number, d: number, e: number) => void;
|
package/core/wasm.d.ts
CHANGED
|
@@ -32,14 +32,13 @@ export type PayloadItem =
|
|
|
32
32
|
*
|
|
33
33
|
* `$` system entries are hoisted to named fields: `kind` (the `$kind`, empty
|
|
34
34
|
* string when none), optional `quill` (the `$quill` `name@version`, main card
|
|
35
|
-
* only), optional `
|
|
35
|
+
* only), optional `ext` (`$ext`), and optional `seed`
|
|
36
36
|
* (the `$seed` per-kind overlay map, main card only). `payloadItems` carries
|
|
37
37
|
* user fields and comments in order.
|
|
38
38
|
*/
|
|
39
39
|
export interface Card {
|
|
40
40
|
kind: string;
|
|
41
41
|
quill?: string;
|
|
42
|
-
id?: string;
|
|
43
42
|
ext?: Record<string, unknown>;
|
|
44
43
|
seed?: Record<string, unknown>;
|
|
45
44
|
payloadItems: PayloadItem[];
|
|
@@ -63,7 +62,6 @@ export interface Card {
|
|
|
63
62
|
export interface CardInput {
|
|
64
63
|
kind: string;
|
|
65
64
|
quill?: string;
|
|
66
|
-
id?: string;
|
|
67
65
|
ext?: Record<string, unknown>;
|
|
68
66
|
seed?: Record<string, unknown>;
|
|
69
67
|
payloadItems?: PayloadItem[];
|
|
@@ -242,13 +240,42 @@ export type LineOp =
|
|
|
242
240
|
| { op: "setContainers"; line: number; containers: ContentContainer[] }
|
|
243
241
|
| { op: "setContinues"; line: number; continues: boolean };
|
|
244
242
|
|
|
243
|
+
/**
|
|
244
|
+
* An island edit: the only channel that reaches an island's payload, a table's
|
|
245
|
+
* cells or an image's url.
|
|
246
|
+
*
|
|
247
|
+
* Both ops move one island entry and leave the field's text and marks alone, so
|
|
248
|
+
* an island edit keeps every identity anchor in the field. That is why a table
|
|
249
|
+
* edit lowers to `applyChange` rather than `install`, which drops them all.
|
|
250
|
+
*
|
|
251
|
+
* `set` addresses an existing island by `id`; an `id` no island carries throws
|
|
252
|
+
* rather than passing silently. `insert` places a new island's slot at `at` (a
|
|
253
|
+
* post-delta USV position) together with its entry, so a slot never exists
|
|
254
|
+
* without an island behind it; its `id` must be non-empty and unused. Deleting
|
|
255
|
+
* an island needs no op: a `delta` that removes its slot drops the island.
|
|
256
|
+
*
|
|
257
|
+
* A `set` stores the `loss` it is given: nothing re-derives the class from the
|
|
258
|
+
* new `props`, so a write that changes what markdown can carry must say so.
|
|
259
|
+
*
|
|
260
|
+
* An island is *inline* (a slot inside a paragraph) unless its line says
|
|
261
|
+
* otherwise. A **block** island is one bundle of all three channels, in the
|
|
262
|
+
* order they apply: `delta` inserts the `\n` that opens the line, `islandOps`
|
|
263
|
+
* inserts the slot, `lineOps` tags the line `{ op: "setKind", kind: "island" }`.
|
|
264
|
+
* `{ op: "split" }` cannot open that line, since line ops run after island ops.
|
|
265
|
+
*/
|
|
266
|
+
export type IslandOp =
|
|
267
|
+
| ({ op: "set" } & ContentIsland)
|
|
268
|
+
| ({ op: "insert"; at: number } & ContentIsland);
|
|
269
|
+
|
|
245
270
|
/**
|
|
246
271
|
* A committed content edit bundle for `applyChange`: a text `delta` (default no
|
|
247
|
-
* text change), then `lineOps`, then `markOps` (mark ranges
|
|
248
|
-
* coordinates). Every field is
|
|
272
|
+
* text change), then `islandOps`, then `lineOps`, then `markOps` (mark ranges
|
|
273
|
+
* are in final-text coordinates: every earlier channel applied). Every field is
|
|
274
|
+
* optional.
|
|
249
275
|
*/
|
|
250
276
|
export interface ChangeBundle {
|
|
251
277
|
delta?: Delta;
|
|
278
|
+
islandOps?: IslandOp[];
|
|
252
279
|
lineOps?: LineOp[];
|
|
253
280
|
markOps?: MarkOp[];
|
|
254
281
|
}
|
|
@@ -437,6 +464,16 @@ export interface Diagnostic {
|
|
|
437
464
|
*/
|
|
438
465
|
path?: string;
|
|
439
466
|
hint?: string;
|
|
467
|
+
/**
|
|
468
|
+
* The facts `message` interpolates, keyed by name. With `code`, the
|
|
469
|
+
* substitution unit needed to word this diagnostic in another language;
|
|
470
|
+
* `prose/canon/ERROR.md` § \"Diagnostic args\" tabulates the keys per code.
|
|
471
|
+
*
|
|
472
|
+
* Declared optional explicitly because `tsify` does not read
|
|
473
|
+
* `skip_serializing_if`: without this, a field the runtime omits is
|
|
474
|
+
* declared required. `sourceChain` carries that mismatch.
|
|
475
|
+
*/
|
|
476
|
+
args?: Record<string, unknown>;
|
|
440
477
|
sourceChain?: string[];
|
|
441
478
|
}
|
|
442
479
|
|
|
@@ -462,11 +499,16 @@ export class Document {
|
|
|
462
499
|
free(): void;
|
|
463
500
|
[Symbol.dispose](): void;
|
|
464
501
|
/**
|
|
465
|
-
* **Apply** a committed content edit `bundle`
|
|
466
|
-
*
|
|
467
|
-
*
|
|
502
|
+
* **Apply** a committed content edit `bundle`
|
|
503
|
+
* (`{ delta?, islandOps?, lineOps?, markOps? }`) at `addr`, the editor
|
|
504
|
+
* splice: text delta first, then island ops, then line ops, then mark ops
|
|
505
|
+
* (mark ranges in final-text coordinates), each all-or-nothing. An absent
|
|
468
506
|
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
469
507
|
*
|
|
508
|
+
* The island channel keeps a table or image edit on the op path: it moves
|
|
509
|
+
* the island alone, so the anchors elsewhere in the field survive an edit
|
|
510
|
+
* `install` would clear.
|
|
511
|
+
*
|
|
470
512
|
* Throws on an out-of-range card, a field that is not richtext, a malformed
|
|
471
513
|
* bundle, or an op that applies out of bounds (the value is unchanged on a
|
|
472
514
|
* failed apply).
|
|
@@ -487,13 +529,6 @@ export class Document {
|
|
|
487
529
|
* verbs.
|
|
488
530
|
*/
|
|
489
531
|
card(index: number): Card;
|
|
490
|
-
/**
|
|
491
|
-
* The index of the composable card whose `$id` equals `id`, or
|
|
492
|
-
* `undefined` when none carries it. Resolves the durable card handle
|
|
493
|
-
* without a hand-rolled scan over [`cards`](Self::cards); `$id` is
|
|
494
|
-
* unique per document, so at most one card matches.
|
|
495
|
-
*/
|
|
496
|
-
cardIndexById(id: string): number | undefined;
|
|
497
532
|
clone(): Document;
|
|
498
533
|
/**
|
|
499
534
|
* Schema version this build writes via [`toJson`](Document::to_json).
|
|
@@ -561,8 +596,7 @@ export class Document {
|
|
|
561
596
|
getMarkdown(addr?: CardAddr): string;
|
|
562
597
|
/**
|
|
563
598
|
* Read the **verbatim stored value** at `addr`: the raw payload value of a
|
|
564
|
-
* field
|
|
565
|
-
* otherwise), or the **body content** when `addr.field` is absent. A bare
|
|
599
|
+
* field, or the **body content** when `addr.field` is absent. A bare
|
|
566
600
|
* string is `Addr` shorthand for `{ field }`. Reads are total over the field
|
|
567
601
|
* axis: an absent field is `undefined`; only an out-of-range `addr.card`
|
|
568
602
|
* throws `edit::index_out_of_range`. Needs no schema, so it lives on
|
|
@@ -570,6 +604,16 @@ export class Document {
|
|
|
570
604
|
* the interpreted schema-plane [`reader.get`](Self::reader_get). For the
|
|
571
605
|
* markdown projection use [`getMarkdown`](Self::get_markdown) (body) or
|
|
572
606
|
* `reader.get` (a field's declared type).
|
|
607
|
+
*
|
|
608
|
+
* **A content field at rest has one stored form per codec**: a `richtext`
|
|
609
|
+
* field holds the canonical content object, a `plaintext` field its literal
|
|
610
|
+
* string. A document that came through the bound door (`quill.parse` /
|
|
611
|
+
* `quill.conform`) is at rest, so this read no longer depends on which lane
|
|
612
|
+
* built it. A document that came through the transport door
|
|
613
|
+
* (`Document.fromMarkdown`, a legacy stored row) may rest as authored until
|
|
614
|
+
* it is conformed, and this read reports what is there. For the corpus
|
|
615
|
+
* either way, use the schema-plane `reader.getContent`, which decodes
|
|
616
|
+
* through the codec the field's declared type names.
|
|
573
617
|
*/
|
|
574
618
|
getStored(addr: Addr | string): unknown;
|
|
575
619
|
/**
|
|
@@ -802,6 +846,12 @@ export class Document {
|
|
|
802
846
|
*/
|
|
803
847
|
readonly main: Card;
|
|
804
848
|
readonly quillRef: string;
|
|
849
|
+
/**
|
|
850
|
+
* The non-fatal diagnostics of the load that produced this document: parse
|
|
851
|
+
* warnings, plus the `conform::*` warnings when it came through
|
|
852
|
+
* `quill.parse`. Session state, not document value: `equals` and the
|
|
853
|
+
* storage DTO exclude it, and `fromJson` / `loadJson` clear it.
|
|
854
|
+
*/
|
|
805
855
|
readonly warnings: Diagnostic[];
|
|
806
856
|
}
|
|
807
857
|
|
|
@@ -809,6 +859,23 @@ export class Quill {
|
|
|
809
859
|
private constructor();
|
|
810
860
|
free(): void;
|
|
811
861
|
[Symbol.dispose](): void;
|
|
862
|
+
/**
|
|
863
|
+
* Land `doc`'s declared content fields at their canonical rest **in
|
|
864
|
+
* place**, returning the `conform::*` diagnostics for the values that would
|
|
865
|
+
* not commit (an empty array when everything rested).
|
|
866
|
+
*
|
|
867
|
+
* The read-repair verb: a document that arrived through the transport door
|
|
868
|
+
* (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
|
|
869
|
+
* eligible for rewrite under its current schema tag. Idempotent, and a
|
|
870
|
+
* no-op on an already-canonical document: an equal value is not rewritten,
|
|
871
|
+
* so YAML comments and stored bytes survive.
|
|
872
|
+
*
|
|
873
|
+
* A `!must_fill` marker anywhere in a field's value skips that field (the
|
|
874
|
+
* marker is the state), and a value the strict write refuses stays as
|
|
875
|
+
* authored with a diagnostic. Throws when `doc` declares a different
|
|
876
|
+
* `$quill`, before any mutation.
|
|
877
|
+
*/
|
|
878
|
+
conform(doc: Document): Diagnostic[];
|
|
812
879
|
/**
|
|
813
880
|
* Build a quill from a file tree. Pure: no backend, no engine; the
|
|
814
881
|
* declared backend is resolved later, at render time.
|
|
@@ -819,6 +886,21 @@ export class Quill {
|
|
|
819
886
|
* canonical shape.
|
|
820
887
|
*/
|
|
821
888
|
static fromTree(tree: Map<string, Uint8Array>): Quill;
|
|
889
|
+
/**
|
|
890
|
+
* Parse `markdown` and conform it against this quill: the **primary
|
|
891
|
+
* ingestion path**, and the bound twin of the schema-free
|
|
892
|
+
* `Document.fromMarkdown`. The returned document rests at its canonical
|
|
893
|
+
* form (a `richtext` field as a content object, a `plaintext` field as its
|
|
894
|
+
* literal string), so `getStored` no longer answers "corpus or string?"
|
|
895
|
+
* with "depends how this document was built".
|
|
896
|
+
*
|
|
897
|
+
* Parse warnings and the `conform::*` diagnostics both land on
|
|
898
|
+
* `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
|
|
899
|
+
* `$quill` this quill does not answer to: nothing conforms under the wrong
|
|
900
|
+
* schema. To open a document whose `$quill` is stale, use the transport
|
|
901
|
+
* door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
|
|
902
|
+
*/
|
|
903
|
+
parse(markdown: string): Document;
|
|
822
904
|
/**
|
|
823
905
|
* The resolved-value view of `doc` against this quill's schema: for every
|
|
824
906
|
* declared field the value the render projection would use and the
|