@ai-matrx/print 0.8.0 → 0.8.1

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.
@@ -133,7 +133,7 @@ interface DocumentSettings {
133
133
  fontSize: number;
134
134
  }
135
135
  interface DocumentNotice {
136
- code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "content-lost" | "math-error" | "empty-document";
136
+ code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "content-lost" | "math-error" | "toc-pages-deferred" | "empty-document";
137
137
  message: string;
138
138
  remedy: string;
139
139
  }
@@ -133,7 +133,7 @@ interface DocumentSettings {
133
133
  fontSize: number;
134
134
  }
135
135
  interface DocumentNotice {
136
- code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "content-lost" | "math-error" | "empty-document";
136
+ code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "content-lost" | "math-error" | "toc-pages-deferred" | "empty-document";
137
137
  message: string;
138
138
  remedy: string;
139
139
  }
package/dist/document.js CHANGED
@@ -5471,7 +5471,21 @@ async function exportDocument(source, format, options = {}) {
5471
5471
  bytes = r.bytes;
5472
5472
  pageCount = r.pageCount;
5473
5473
  } else if (format === "docx") {
5474
- const pages = tree.toc.length ? await headingPages(tree, images, options.fonts) : void 0;
5474
+ const hasToc = tree.sections.some((sec) => sec.blocks.some((blk) => blk.type === "toc"));
5475
+ let pages;
5476
+ if (hasToc) {
5477
+ try {
5478
+ pages = await headingPages(tree, images, options.fonts);
5479
+ } catch (err) {
5480
+ const n = {
5481
+ code: "toc-pages-deferred",
5482
+ message: `The Word file's table of contents lists every heading; its page numbers fill in when the file is opened (they could not be measured here: ${err.message}).`,
5483
+ remedy: "Open the file in Word (or update fields) to show the page numbers."
5484
+ };
5485
+ tree.notices.push(n);
5486
+ options.onNotice?.(n);
5487
+ }
5488
+ }
5475
5489
  bytes = await documentToDocx(tree, { images, headingPages: pages });
5476
5490
  } else bytes = await documentToEpub(tree, { images });
5477
5491
  }