@ai-matrx/print 0.8.66 → 0.8.68
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 +12 -0
- package/dist/react.cjs +50 -9
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +12 -1
- package/dist/react.d.ts +12 -1
- package/dist/react.js +50 -9
- package/dist/react.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.68
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/print/v0.8.67..npm/print/v0.8.68 -- apps/shared/print`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.8.67
|
|
10
|
+
|
|
11
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
12
|
+
`git diff npm/print/v0.8.66..npm/print/v0.8.67 -- apps/shared/print`).
|
|
13
|
+
No source changes intended and no consumer action required.
|
|
14
|
+
|
|
3
15
|
## 0.8.66
|
|
4
16
|
|
|
5
17
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
package/dist/react.cjs
CHANGED
|
@@ -1589,6 +1589,32 @@ function LabelSheetPreview({
|
|
|
1589
1589
|
}
|
|
1590
1590
|
);
|
|
1591
1591
|
}
|
|
1592
|
+
function hasInlinePdfViewer() {
|
|
1593
|
+
if (typeof navigator === "undefined") return true;
|
|
1594
|
+
if (navigator.pdfViewerEnabled === false) return false;
|
|
1595
|
+
return !(typeof window !== "undefined" && window.matchMedia?.("(pointer: coarse)").matches);
|
|
1596
|
+
}
|
|
1597
|
+
function printHtml(html) {
|
|
1598
|
+
const frame = document.createElement("iframe");
|
|
1599
|
+
frame.setAttribute("aria-hidden", "true");
|
|
1600
|
+
frame.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;";
|
|
1601
|
+
document.body.appendChild(frame);
|
|
1602
|
+
const win = frame.contentWindow;
|
|
1603
|
+
if (!win) {
|
|
1604
|
+
frame.remove();
|
|
1605
|
+
throw new Error("Printing is blocked in this browser.");
|
|
1606
|
+
}
|
|
1607
|
+
win.document.open();
|
|
1608
|
+
win.document.write(html);
|
|
1609
|
+
win.document.close();
|
|
1610
|
+
const run = () => {
|
|
1611
|
+
win.focus();
|
|
1612
|
+
win.print();
|
|
1613
|
+
setTimeout(() => frame.remove(), 6e4);
|
|
1614
|
+
};
|
|
1615
|
+
if (win.document.readyState === "complete") setTimeout(run, 50);
|
|
1616
|
+
else win.addEventListener("load", run, { once: true });
|
|
1617
|
+
}
|
|
1592
1618
|
var EXPORT_BUTTONS = [
|
|
1593
1619
|
{ format: "pdf", label: "PDF" },
|
|
1594
1620
|
{ format: "docx", label: "Word" },
|
|
@@ -1596,8 +1622,18 @@ var EXPORT_BUTTONS = [
|
|
|
1596
1622
|
{ format: "html", label: "HTML" },
|
|
1597
1623
|
{ format: "markdown", label: "Markdown" }
|
|
1598
1624
|
];
|
|
1599
|
-
function DocumentPrintPreview({
|
|
1600
|
-
|
|
1625
|
+
function DocumentPrintPreview({
|
|
1626
|
+
markdown,
|
|
1627
|
+
title,
|
|
1628
|
+
className,
|
|
1629
|
+
onNotice,
|
|
1630
|
+
resolveReferences,
|
|
1631
|
+
renderPages: renderPages2,
|
|
1632
|
+
printPages
|
|
1633
|
+
}) {
|
|
1634
|
+
const [inlineViewer] = (0, import_react.useState)(hasInlinePdfViewer);
|
|
1635
|
+
const canShowPages = inlineViewer || Boolean(renderPages2);
|
|
1636
|
+
const [view, setView] = (0, import_react.useState)(canShowPages ? "pages" : "web");
|
|
1601
1637
|
const [pdf, setPdf] = (0, import_react.useState)(null);
|
|
1602
1638
|
const [html, setHtml] = (0, import_react.useState)("");
|
|
1603
1639
|
const [notices, setNotices] = (0, import_react.useState)([]);
|
|
@@ -1659,18 +1695,23 @@ function DocumentPrintPreview({ markdown, title, className, onNotice, resolveRef
|
|
|
1659
1695
|
setBusy(null);
|
|
1660
1696
|
}
|
|
1661
1697
|
};
|
|
1662
|
-
const print = () => {
|
|
1698
|
+
const print = async () => {
|
|
1663
1699
|
if (!pdf) return;
|
|
1664
1700
|
try {
|
|
1665
|
-
frameRef.current?.contentWindow
|
|
1666
|
-
|
|
1667
|
-
|
|
1701
|
+
if (inlineViewer && frameRef.current?.contentWindow) {
|
|
1702
|
+
frameRef.current.contentWindow.print();
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
if (printPages) await printPages(pdf.url);
|
|
1706
|
+
else printHtml(html);
|
|
1707
|
+
} catch (err) {
|
|
1708
|
+
setError(`Print failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1668
1709
|
}
|
|
1669
1710
|
};
|
|
1670
1711
|
const btn = "inline-flex h-7 items-center gap-1 rounded-md border border-border bg-background px-2.5 text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50";
|
|
1671
1712
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: cn("flex min-h-0 flex-1 flex-col", className), "data-testid": "document-print-preview", children: [
|
|
1672
1713
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center gap-2 border-b border-border px-3 py-1.5 text-xs", children: [
|
|
1673
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "inline-flex overflow-hidden rounded-md border border-border", role: "tablist", children: ["pages", "web"].map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1714
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "inline-flex overflow-hidden rounded-md border border-border", role: "tablist", children: (canShowPages ? ["pages", "web"] : ["web"]).map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1674
1715
|
"button",
|
|
1675
1716
|
{
|
|
1676
1717
|
type: "button",
|
|
@@ -1684,7 +1725,7 @@ function DocumentPrintPreview({ markdown, title, className, onNotice, resolveRef
|
|
|
1684
1725
|
)) }),
|
|
1685
1726
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-muted-foreground", "data-testid": "document-print-summary", children: busy === "render" && !pdf ? "Laying out pages\u2026" : `${pdf?.pages ?? 0} page${pdf?.pages === 1 ? "" : "s"}${summary ? ` \xB7 ${summary}` : ""}` }),
|
|
1686
1727
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ml-auto flex flex-wrap items-center gap-1.5", children: [
|
|
1687
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: btn, onClick: print, disabled: !pdf, children: "Print" }),
|
|
1728
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: btn, onClick: () => void print(), disabled: !pdf, children: "Print" }),
|
|
1688
1729
|
EXPORT_BUTTONS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: btn, onClick: () => void download(b.format), disabled: busy === b.format, children: busy === b.format ? "Saving\u2026" : b.label }, b.format))
|
|
1689
1730
|
] })
|
|
1690
1731
|
] }),
|
|
@@ -1702,7 +1743,7 @@ function DocumentPrintPreview({ markdown, title, className, onNotice, resolveRef
|
|
|
1702
1743
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-muted-foreground", children: n.remedy })
|
|
1703
1744
|
] }, i)) })
|
|
1704
1745
|
] }),
|
|
1705
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "min-h-0 flex-1 bg-muted/40", children: view === "pages" ? pdf ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { ref: frameRef, title: "Print preview", src: pdf.url, className: "h-full min-h-[480px] w-full border-0" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "p-8 text-center text-xs text-muted-foreground", children: error ? "No preview." : "Laying out pages\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { title: "Web preview", srcDoc: html, sandbox: "allow-same-origin", className: "h-full min-h-[480px] w-full border-0 bg-white" }) })
|
|
1746
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "min-h-0 flex-1 bg-muted/40", children: view === "pages" ? pdf ? inlineViewer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { ref: frameRef, title: "Print preview", src: pdf.url, className: "h-full min-h-[480px] w-full border-0" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full min-h-[480px] w-full", children: renderPages2?.(pdf.url) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "p-8 text-center text-xs text-muted-foreground", children: error ? "No preview." : "Laying out pages\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { title: "Web preview", srcDoc: html, sandbox: "allow-same-origin", className: "h-full min-h-[480px] w-full border-0 bg-white" }) })
|
|
1706
1747
|
] });
|
|
1707
1748
|
}
|
|
1708
1749
|
//# sourceMappingURL=react.cjs.map
|