@pretextbook/web-editor 0.5.2 → 0.5.4

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.
@@ -187,11 +187,30 @@ export declare function parseDivisionRefs(content: string): string[];
187
187
  * Like {@link parseDivisionRefs} but also returns the division type inferred
188
188
  * from the tag name (e.g. `<plus:chapter ref="x"/>` → `{ type: "chapter", xmlId: "x" }`).
189
189
  * Used to auto-create Division records when new refs appear in edited content.
190
+ *
191
+ * Only tag names in {@link DIVISION_REF_TAGS} are considered — asset
192
+ * placeholders (`plus:image`, `plus:doenet`, ...) are not divisions and are
193
+ * skipped. The generic `<plus:division ref="x"/>` alias falls back to type
194
+ * `"section"`, matching {@link tagToType}'s default for unrecognised tags.
190
195
  */
191
196
  export declare function parseDivisionRefsWithTypes(content: string): {
192
197
  xmlId: string;
193
198
  type: DivisionType;
194
199
  }[];
200
+ /** A `<plus:image ref="..."/>` / `<plus:doenet ref="..."/>` asset placeholder. */
201
+ export interface AssetRef {
202
+ kind: "image" | "doenet";
203
+ ref: string;
204
+ }
205
+ /**
206
+ * Parse every `<plus:image ref="..."/>` / `<plus:doenet ref="..."/>` asset
207
+ * placeholder out of `content`, in document order, without de-duplicating.
208
+ *
209
+ * Asset placeholders share the `<plus:* ref="..."/>` shape used by division
210
+ * refs (see {@link DIVISION_REF_TAGS}) but are deliberately parsed by a
211
+ * separate, disjoint tag set so the two kinds of include are never conflated.
212
+ */
213
+ export declare function parseAssetRefs(content: string): AssetRef[];
195
214
  /**
196
215
  * Create a minimal Division record for a given `xmlId` and `type`.
197
216
  * Used when the user types a new `<plus:TYPE ref="id"/>` placeholder into a
@@ -297,17 +316,33 @@ export declare function buildDivisionTree(divisions: Division[], startXmlId: str
297
316
  */
298
317
  export declare function getOrphanRoots(divisions: Division[], rootXmlId: string): Division[];
299
318
  /**
300
- * Assemble the full PreTeXt source for a project by resolving the root
301
- * division and recursively expanding every `<plus:* ref="..."/>` placeholder
302
- * it (transitively) contains, converting any LaTeX/Markdown divisions to
303
- * PreTeXt along the way.
319
+ * Resolve the root division and recursively expand every
320
+ * `<plus:* ref="..."/>` placeholder it (transitively) contains, converting
321
+ * any LaTeX/Markdown divisions to PreTeXt along the way. Returns the bare
322
+ * root element (e.g. `<book>...</book>`) — *not* wrapped in `<pretext>` and
323
+ * without `<docinfo>`.
304
324
  *
305
- * This is what a host application sends to the build server (e.g.
306
- * `https://build.pretext.plus`) to produce the final rendered document the
307
- * `divisions` pool itself is never a valid build input, since it's a flat
308
- * list of fragments rather than a single document tree.
325
+ * This is the body half of a full document. Most callers that want an
326
+ * actual buildable/persistable document should use
327
+ * {@link assembleFullProjectSource} instead; this lower-level function
328
+ * remains for callers (like the division-scoped preview path) that need to
329
+ * compose the resolved body further before wrapping it themselves.
309
330
  */
310
331
  export declare function assembleProjectSource(divisions: Division[], rootXmlId: string): string;
332
+ /**
333
+ * Assemble the complete PreTeXt document for a project: the root division,
334
+ * fully resolved (every `<plus:* ref="..."/>` placeholder expanded and any
335
+ * LaTeX/Markdown divisions converted to PreTeXt), wrapped in the outer
336
+ * `<pretext>` element with `<docinfo>` inserted as its sibling.
337
+ *
338
+ * This is the same shape produced for a root-division preview build, and is
339
+ * what a host application should persist as "the full source" and send to a
340
+ * build server (e.g. `https://build.pretext.plus`) to produce the final
341
+ * rendered document — the `divisions` pool itself is never a valid build
342
+ * input, since it's a flat list of fragments rather than a single document
343
+ * tree.
344
+ */
345
+ export declare function assembleFullProjectSource(divisions: Division[], rootXmlId: string, docinfo: string): string;
311
346
  /**
312
347
  * Wrap a single division's own tagged XML (e.g.
313
348
  * `<section xml:id="...">...</section>`) into a standalone PreTeXt fragment