@ai-matrx/print 0.1.0 → 0.2.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.
- package/CHANGELOG.md +56 -0
- package/dist/barcode.cjs +182 -0
- package/dist/barcode.cjs.map +1 -0
- package/dist/barcode.d.cts +94 -0
- package/dist/barcode.d.ts +94 -0
- package/dist/barcode.js +151 -0
- package/dist/barcode.js.map +1 -0
- package/dist/booklet.cjs +203 -0
- package/dist/booklet.cjs.map +1 -0
- package/dist/booklet.d.cts +93 -0
- package/dist/booklet.d.ts +93 -0
- package/dist/booklet.js +180 -0
- package/dist/booklet.js.map +1 -0
- package/dist/core.cjs +6 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +25 -4
- package/dist/core.d.ts +25 -4
- package/dist/core.js +6 -5
- package/dist/core.js.map +1 -1
- package/dist/flashcards.cjs +18 -65
- package/dist/flashcards.cjs.map +1 -1
- package/dist/flashcards.js +18 -65
- package/dist/flashcards.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/labels.cjs +10 -11
- package/dist/labels.cjs.map +1 -1
- package/dist/labels.d.cts +3 -3
- package/dist/labels.d.ts +3 -3
- package/dist/labels.js +10 -11
- package/dist/labels.js.map +1 -1
- package/dist/qr-styled.cjs +219 -0
- package/dist/qr-styled.cjs.map +1 -0
- package/dist/qr-styled.d.cts +150 -0
- package/dist/qr-styled.d.ts +150 -0
- package/dist/qr-styled.js +188 -0
- package/dist/qr-styled.js.map +1 -0
- package/dist/react.cjs +23 -18
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +26 -3
- package/dist/react.d.ts +26 -3
- package/dist/react.js +23 -18
- package/dist/react.js.map +1 -1
- package/package.json +34 -2
package/dist/flashcards.cjs
CHANGED
|
@@ -121,8 +121,8 @@ ${bodyHtml}
|
|
|
121
121
|
</body>
|
|
122
122
|
</html>`;
|
|
123
123
|
}
|
|
124
|
-
function openPrintWindow(htmlDocument, filename = "print") {
|
|
125
|
-
const win = window.open("", "_blank",
|
|
124
|
+
function openPrintWindow(htmlDocument, filename = "print", windowFeatures = "width=920,height=720,scrollbars=yes") {
|
|
125
|
+
const win = window.open("", "_blank", windowFeatures);
|
|
126
126
|
if (!win) {
|
|
127
127
|
const blob = new Blob([htmlDocument], { type: "text/html;charset=utf-8" });
|
|
128
128
|
const url = URL.createObjectURL(blob);
|
|
@@ -132,12 +132,13 @@ function openPrintWindow(htmlDocument, filename = "print") {
|
|
|
132
132
|
document.body.appendChild(a);
|
|
133
133
|
a.click();
|
|
134
134
|
document.body.removeChild(a);
|
|
135
|
-
URL.revokeObjectURL(url);
|
|
136
|
-
return;
|
|
135
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
136
|
+
return "downloaded";
|
|
137
137
|
}
|
|
138
138
|
win.document.open();
|
|
139
139
|
win.document.write(htmlDocument);
|
|
140
140
|
win.document.close();
|
|
141
|
+
return "opened";
|
|
141
142
|
}
|
|
142
143
|
function buildFitTextScript(selectors) {
|
|
143
144
|
const selectorsJson = JSON.stringify([...selectors]);
|
|
@@ -973,22 +974,7 @@ ${bodyHtml}
|
|
|
973
974
|
${FIT_TEXT_SCRIPT}
|
|
974
975
|
</body>
|
|
975
976
|
</html>`;
|
|
976
|
-
|
|
977
|
-
if (!win) {
|
|
978
|
-
const blob = new Blob([html], { type: "text/html;charset=utf-8" });
|
|
979
|
-
const url = URL.createObjectURL(blob);
|
|
980
|
-
const a = document.createElement("a");
|
|
981
|
-
a.href = url;
|
|
982
|
-
a.download = `${title.replace(/\s+/g, "-").toLowerCase()}-flashcards.html`;
|
|
983
|
-
document.body.appendChild(a);
|
|
984
|
-
a.click();
|
|
985
|
-
document.body.removeChild(a);
|
|
986
|
-
URL.revokeObjectURL(url);
|
|
987
|
-
return;
|
|
988
|
-
}
|
|
989
|
-
win.document.open();
|
|
990
|
-
win.document.write(html);
|
|
991
|
-
win.document.close();
|
|
977
|
+
return openPrintWindow(html, `${title}-flashcards`, "width=1100,height=720,scrollbars=yes");
|
|
992
978
|
}
|
|
993
979
|
var AVERY_5388_STYLES = `
|
|
994
980
|
@page { size: portrait; margin: 0; }
|
|
@@ -1170,22 +1156,7 @@ ${bodyHtml}
|
|
|
1170
1156
|
${FIT_TEXT_SCRIPT}
|
|
1171
1157
|
</body>
|
|
1172
1158
|
</html>`;
|
|
1173
|
-
|
|
1174
|
-
if (!win) {
|
|
1175
|
-
const blob = new Blob([html], { type: "text/html;charset=utf-8" });
|
|
1176
|
-
const url = URL.createObjectURL(blob);
|
|
1177
|
-
const a = document.createElement("a");
|
|
1178
|
-
a.href = url;
|
|
1179
|
-
a.download = `${title.replace(/\s+/g, "-").toLowerCase()}-avery5388.html`;
|
|
1180
|
-
document.body.appendChild(a);
|
|
1181
|
-
a.click();
|
|
1182
|
-
document.body.removeChild(a);
|
|
1183
|
-
URL.revokeObjectURL(url);
|
|
1184
|
-
return;
|
|
1185
|
-
}
|
|
1186
|
-
win.document.open();
|
|
1187
|
-
win.document.write(html);
|
|
1188
|
-
win.document.close();
|
|
1159
|
+
return openPrintWindow(html, `${title}-avery5388`, "width=900,height=720,scrollbars=yes");
|
|
1189
1160
|
}
|
|
1190
1161
|
var PORTRAIT_6UP_STYLES = `
|
|
1191
1162
|
@page { size: portrait; margin: 0; }
|
|
@@ -1435,22 +1406,7 @@ ${bodyHtml}
|
|
|
1435
1406
|
${FIT_TEXT_SCRIPT}
|
|
1436
1407
|
</body>
|
|
1437
1408
|
</html>`;
|
|
1438
|
-
|
|
1439
|
-
if (!win) {
|
|
1440
|
-
const blob = new Blob([html], { type: "text/html;charset=utf-8" });
|
|
1441
|
-
const url = URL.createObjectURL(blob);
|
|
1442
|
-
const a = document.createElement("a");
|
|
1443
|
-
a.href = url;
|
|
1444
|
-
a.download = `${title.replace(/\s+/g, "-").toLowerCase()}-flashcards-6up.html`;
|
|
1445
|
-
document.body.appendChild(a);
|
|
1446
|
-
a.click();
|
|
1447
|
-
document.body.removeChild(a);
|
|
1448
|
-
URL.revokeObjectURL(url);
|
|
1449
|
-
return;
|
|
1450
|
-
}
|
|
1451
|
-
win.document.open();
|
|
1452
|
-
win.document.write(html);
|
|
1453
|
-
win.document.close();
|
|
1409
|
+
return openPrintWindow(html, `${title}-flashcards-6up`, "width=900,height=720,scrollbars=yes");
|
|
1454
1410
|
}
|
|
1455
1411
|
function deriveTitle(data) {
|
|
1456
1412
|
if (data && typeof data === "object" && "title" in data) {
|
|
@@ -1629,7 +1585,7 @@ var flashcardsPrinter = {
|
|
|
1629
1585
|
const title = deriveTitle(data);
|
|
1630
1586
|
const s = resolveSettings(rawSettings);
|
|
1631
1587
|
if (allCards.length === 0) {
|
|
1632
|
-
openPrintWindow(
|
|
1588
|
+
return openPrintWindow(
|
|
1633
1589
|
buildPrintDocument(
|
|
1634
1590
|
"<p>No flashcard data available to print.</p>",
|
|
1635
1591
|
title,
|
|
@@ -1637,7 +1593,6 @@ var flashcardsPrinter = {
|
|
|
1637
1593
|
),
|
|
1638
1594
|
"flashcards"
|
|
1639
1595
|
);
|
|
1640
|
-
return;
|
|
1641
1596
|
}
|
|
1642
1597
|
const rawFrom = typeof rawSettings?.fromCard === "number" ? rawSettings.fromCard : 0;
|
|
1643
1598
|
const rawTo = typeof rawSettings?.toCard === "number" ? rawSettings.toCard : 0;
|
|
@@ -1647,36 +1602,31 @@ var flashcardsPrinter = {
|
|
|
1647
1602
|
const startIndex = fromIdx - 1;
|
|
1648
1603
|
const cards = allCards.slice(startIndex, toIdx);
|
|
1649
1604
|
if (variantId === "landscape-duplex") {
|
|
1650
|
-
openLandscapeWindow(
|
|
1605
|
+
return openLandscapeWindow(
|
|
1651
1606
|
renderLandscape(cards, title, "duplex", s, startIndex),
|
|
1652
1607
|
title
|
|
1653
1608
|
);
|
|
1654
|
-
return;
|
|
1655
1609
|
}
|
|
1656
1610
|
if (variantId === "landscape-stacked") {
|
|
1657
|
-
openLandscapeWindow(
|
|
1611
|
+
return openLandscapeWindow(
|
|
1658
1612
|
renderLandscape(cards, title, "stacked", s, startIndex),
|
|
1659
1613
|
title
|
|
1660
1614
|
);
|
|
1661
|
-
return;
|
|
1662
1615
|
}
|
|
1663
1616
|
if (variantId === "portrait-6up-duplex") {
|
|
1664
|
-
openPortrait6UpWindow(
|
|
1617
|
+
return openPortrait6UpWindow(
|
|
1665
1618
|
renderPortrait6Up(cards, title, "duplex", s, startIndex),
|
|
1666
1619
|
title
|
|
1667
1620
|
);
|
|
1668
|
-
return;
|
|
1669
1621
|
}
|
|
1670
1622
|
if (variantId === "portrait-6up-stacked") {
|
|
1671
|
-
openPortrait6UpWindow(
|
|
1623
|
+
return openPortrait6UpWindow(
|
|
1672
1624
|
renderPortrait6Up(cards, title, "stacked", s, startIndex),
|
|
1673
1625
|
title
|
|
1674
1626
|
);
|
|
1675
|
-
return;
|
|
1676
1627
|
}
|
|
1677
1628
|
if (variantId === "avery-5388") {
|
|
1678
|
-
openAveryWindow(renderAvery5388(cards, title, s, startIndex), title);
|
|
1679
|
-
return;
|
|
1629
|
+
return openAveryWindow(renderAvery5388(cards, title, s, startIndex), title);
|
|
1680
1630
|
}
|
|
1681
1631
|
let bodyHtml;
|
|
1682
1632
|
let styles;
|
|
@@ -1703,7 +1653,10 @@ var flashcardsPrinter = {
|
|
|
1703
1653
|
styles = BOTH_SIDES_STYLES;
|
|
1704
1654
|
break;
|
|
1705
1655
|
}
|
|
1706
|
-
openPrintWindow(
|
|
1656
|
+
return openPrintWindow(
|
|
1657
|
+
buildPrintDocument(bodyHtml, title, styles),
|
|
1658
|
+
"flashcards"
|
|
1659
|
+
);
|
|
1707
1660
|
}
|
|
1708
1661
|
};
|
|
1709
1662
|
//# sourceMappingURL=flashcards.cjs.map
|