@ai-matrx/print 0.7.1 → 0.8.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/dist/react.d.cts CHANGED
@@ -1,7 +1,34 @@
1
1
  import * as React from 'react';
2
2
 
3
+ /** CSL-JSON name (the citation-style-language standard item shape). */
4
+ interface CslName {
5
+ family?: string | undefined;
6
+ given?: string | undefined;
7
+ literal?: string | undefined;
8
+ }
9
+ /** A CSL-JSON reference item (the subset the three built-in styles read). */
10
+ interface CslItem {
11
+ id: string;
12
+ type?: string | undefined;
13
+ title?: string | undefined;
14
+ author?: CslName[] | undefined;
15
+ editor?: CslName[] | undefined;
16
+ issued?: {
17
+ "date-parts"?: Array<Array<number | string>> | undefined;
18
+ literal?: string | undefined;
19
+ } | undefined;
20
+ "container-title"?: string | undefined;
21
+ publisher?: string | undefined;
22
+ "publisher-place"?: string | undefined;
23
+ volume?: string | number | undefined;
24
+ issue?: string | number | undefined;
25
+ page?: string | undefined;
26
+ edition?: string | number | undefined;
27
+ URL?: string | undefined;
28
+ DOI?: string | undefined;
29
+ }
3
30
  interface DocumentNotice {
4
- code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "empty-document";
31
+ code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "content-lost" | "math-error" | "empty-document";
5
32
  message: string;
6
33
  remedy: string;
7
34
  }
@@ -334,6 +361,11 @@ interface DocumentPrintPreviewProps {
334
361
  className?: string;
335
362
  /** Called for every degraded or dropped piece (also listed in the panel). */
336
363
  onNotice?: (notice: DocumentNotice) => void;
364
+ /**
365
+ * Resolves citation keys the document's frontmatter does not define
366
+ * (e.g. `[@research:<id>]`, `[@file:<id>]`) to CSL-JSON references.
367
+ */
368
+ resolveReferences?: (keys: string[]) => Promise<CslItem[]>;
337
369
  }
338
370
  /**
339
371
  * Print preview for a markdown document: the real PDF (the same file the PDF
@@ -342,6 +374,6 @@ interface DocumentPrintPreviewProps {
342
374
  * HTML and Markdown. Everything comes from one parsed tree, so what you see
343
375
  * is what every format contains. Engines load lazily on mount.
344
376
  */
345
- declare function DocumentPrintPreview({ markdown, title, className, onNotice }: DocumentPrintPreviewProps): React.JSX.Element;
377
+ declare function DocumentPrintPreview({ markdown, title, className, onNotice, resolveReferences }: DocumentPrintPreviewProps): React.JSX.Element;
346
378
 
347
379
  export { DocumentPrintPreview, type DocumentPrintPreviewProps, LabelSheetPreview, type LabelSheetPreviewProps, PrintOptionsDialog, type PrintOptionsDialogProps, usePrintOptions };
package/dist/react.d.ts CHANGED
@@ -1,7 +1,34 @@
1
1
  import * as React from 'react';
2
2
 
3
+ /** CSL-JSON name (the citation-style-language standard item shape). */
4
+ interface CslName {
5
+ family?: string | undefined;
6
+ given?: string | undefined;
7
+ literal?: string | undefined;
8
+ }
9
+ /** A CSL-JSON reference item (the subset the three built-in styles read). */
10
+ interface CslItem {
11
+ id: string;
12
+ type?: string | undefined;
13
+ title?: string | undefined;
14
+ author?: CslName[] | undefined;
15
+ editor?: CslName[] | undefined;
16
+ issued?: {
17
+ "date-parts"?: Array<Array<number | string>> | undefined;
18
+ literal?: string | undefined;
19
+ } | undefined;
20
+ "container-title"?: string | undefined;
21
+ publisher?: string | undefined;
22
+ "publisher-place"?: string | undefined;
23
+ volume?: string | number | undefined;
24
+ issue?: string | number | undefined;
25
+ page?: string | undefined;
26
+ edition?: string | number | undefined;
27
+ URL?: string | undefined;
28
+ DOI?: string | undefined;
29
+ }
3
30
  interface DocumentNotice {
4
- code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "empty-document";
31
+ code: "frontmatter-invalid" | "setting-ignored" | "xref-unresolved" | "citation-unresolved" | "html-stripped" | "image-unavailable" | "glyph-substituted" | "content-lost" | "math-error" | "empty-document";
5
32
  message: string;
6
33
  remedy: string;
7
34
  }
@@ -334,6 +361,11 @@ interface DocumentPrintPreviewProps {
334
361
  className?: string;
335
362
  /** Called for every degraded or dropped piece (also listed in the panel). */
336
363
  onNotice?: (notice: DocumentNotice) => void;
364
+ /**
365
+ * Resolves citation keys the document's frontmatter does not define
366
+ * (e.g. `[@research:<id>]`, `[@file:<id>]`) to CSL-JSON references.
367
+ */
368
+ resolveReferences?: (keys: string[]) => Promise<CslItem[]>;
337
369
  }
338
370
  /**
339
371
  * Print preview for a markdown document: the real PDF (the same file the PDF
@@ -342,6 +374,6 @@ interface DocumentPrintPreviewProps {
342
374
  * HTML and Markdown. Everything comes from one parsed tree, so what you see
343
375
  * is what every format contains. Engines load lazily on mount.
344
376
  */
345
- declare function DocumentPrintPreview({ markdown, title, className, onNotice }: DocumentPrintPreviewProps): React.JSX.Element;
377
+ declare function DocumentPrintPreview({ markdown, title, className, onNotice, resolveReferences }: DocumentPrintPreviewProps): React.JSX.Element;
346
378
 
347
379
  export { DocumentPrintPreview, type DocumentPrintPreviewProps, LabelSheetPreview, type LabelSheetPreviewProps, PrintOptionsDialog, type PrintOptionsDialogProps, usePrintOptions };
package/dist/react.js CHANGED
@@ -1544,7 +1544,7 @@ var EXPORT_BUTTONS = [
1544
1544
  { format: "html", label: "HTML" },
1545
1545
  { format: "markdown", label: "Markdown" }
1546
1546
  ];
1547
- function DocumentPrintPreview({ markdown, title, className, onNotice }) {
1547
+ function DocumentPrintPreview({ markdown, title, className, onNotice, resolveReferences }) {
1548
1548
  const [view, setView] = useState("pages");
1549
1549
  const [pdf, setPdf] = useState(null);
1550
1550
  const [html, setHtml] = useState("");
@@ -1562,7 +1562,7 @@ function DocumentPrintPreview({ markdown, title, className, onNotice }) {
1562
1562
  const timer = setTimeout(async () => {
1563
1563
  try {
1564
1564
  const doc = await import("@ai-matrx/print/document");
1565
- const exp = await doc.exportDocument(markdown, "pdf", { title });
1565
+ const exp = await doc.exportDocument(markdown, "pdf", { title, resolveReferences });
1566
1566
  if (cancelled) return;
1567
1567
  url = URL.createObjectURL(new Blob([exp.bytes], { type: "application/pdf" }));
1568
1568
  const images = await doc.resolveDocumentImages(exp.tree);
@@ -1593,12 +1593,12 @@ function DocumentPrintPreview({ markdown, title, className, onNotice }) {
1593
1593
  clearTimeout(timer);
1594
1594
  if (url) URL.revokeObjectURL(url);
1595
1595
  };
1596
- }, [markdown, title]);
1596
+ }, [markdown, title, resolveReferences]);
1597
1597
  const download = async (format) => {
1598
1598
  setBusy(format);
1599
1599
  try {
1600
1600
  const doc = await import("@ai-matrx/print/document");
1601
- const exp = await doc.exportDocument(markdown, format, { title });
1601
+ const exp = await doc.exportDocument(markdown, format, { title, resolveReferences });
1602
1602
  doc.downloadDocumentExport(exp);
1603
1603
  setError(null);
1604
1604
  } catch (err) {