@ai-matrx/print 0.12.39 → 0.12.40
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 +11 -1
- package/dist/booklet.cjs +19 -0
- package/dist/booklet.cjs.map +1 -1
- package/dist/booklet.js +19 -0
- package/dist/booklet.js.map +1 -1
- package/dist/certificate.cjs +19 -0
- package/dist/certificate.cjs.map +1 -1
- package/dist/certificate.js +19 -0
- package/dist/certificate.js.map +1 -1
- package/dist/core.cjs +26 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +20 -1
- package/dist/core.d.ts +20 -1
- package/dist/core.js +26 -1
- package/dist/core.js.map +1 -1
- package/dist/education.cjs +19 -0
- package/dist/education.cjs.map +1 -1
- package/dist/education.js +19 -0
- package/dist/education.js.map +1 -1
- package/dist/exam.cjs +19 -0
- package/dist/exam.cjs.map +1 -1
- package/dist/exam.js +19 -0
- package/dist/exam.js.map +1 -1
- package/dist/flashcards.cjs +19 -0
- package/dist/flashcards.cjs.map +1 -1
- package/dist/flashcards.js +19 -0
- package/dist/flashcards.js.map +1 -1
- package/dist/labels.cjs +19 -0
- package/dist/labels.cjs.map +1 -1
- package/dist/labels.js +19 -0
- package/dist/labels.js.map +1 -1
- package/dist/markdown.cjs +21 -1
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js +21 -1
- package/dist/markdown.js.map +1 -1
- package/dist/react.cjs +19 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +19 -0
- package/dist/react.js.map +1 -1
- package/dist/zpl.cjs +19 -0
- package/dist/zpl.cjs.map +1 -1
- package/dist/zpl.js +19 -0
- package/dist/zpl.js.map +1 -1
- package/package.json +4 -4
package/dist/flashcards.js
CHANGED
|
@@ -109,8 +109,27 @@ function withMathStyles(htmlDocument) {
|
|
|
109
109
|
const head = htmlDocument.search(/<\/head>/i);
|
|
110
110
|
return head >= 0 ? htmlDocument.slice(0, head) + style + htmlDocument.slice(head) : style + htmlDocument;
|
|
111
111
|
}
|
|
112
|
+
var PRINT_HOST = /* @__PURE__ */ Symbol.for("ai-matrx.print.host");
|
|
113
|
+
function getPrintHost() {
|
|
114
|
+
return globalThis[PRINT_HOST] ?? null;
|
|
115
|
+
}
|
|
116
|
+
function handToPrintHost(htmlDocument, title) {
|
|
117
|
+
const host = getPrintHost();
|
|
118
|
+
if (!host) return false;
|
|
119
|
+
try {
|
|
120
|
+
const done = host(htmlDocument, { title });
|
|
121
|
+
if (done && typeof done.catch === "function") {
|
|
122
|
+
done.catch((error) => console.error("[@ai-matrx/print] the host's print failed", error));
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.error("[@ai-matrx/print] the host's print threw; using the print window instead", error);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
112
130
|
function openPrintWindow(rawDocument, filename = "print", windowFeatures = "width=920,height=720,scrollbars=yes") {
|
|
113
131
|
const htmlDocument = withMathStyles(rawDocument);
|
|
132
|
+
if (handToPrintHost(htmlDocument, filename)) return "opened";
|
|
114
133
|
const win = openOutbound("", "_blank", windowFeatures);
|
|
115
134
|
if (!win) return openPrintWindowFallback(htmlDocument, filename);
|
|
116
135
|
win.document.open();
|