@ai-matrx/print 0.2.0 → 0.3.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 +107 -0
- package/README.md +44 -2
- package/dist/booklet.cjs +6 -5
- package/dist/booklet.cjs.map +1 -1
- package/dist/booklet.d.cts +4 -1
- package/dist/booklet.d.ts +4 -1
- package/dist/booklet.js +6 -5
- package/dist/booklet.js.map +1 -1
- 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 +3 -2
- package/dist/index.d.ts +3 -2
- 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/markdown.cjs +1260 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +177 -0
- package/dist/markdown.d.ts +177 -0
- package/dist/markdown.js +1237 -0
- package/dist/markdown.js.map +1 -0
- package/dist/pdf.cjs +77 -4
- package/dist/pdf.cjs.map +1 -1
- package/dist/pdf.d.cts +35 -9
- package/dist/pdf.d.ts +35 -9
- package/dist/pdf.js +77 -4
- package/dist/pdf.js.map +1 -1
- 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 +12 -2
package/dist/flashcards.js
CHANGED
|
@@ -95,8 +95,8 @@ ${bodyHtml}
|
|
|
95
95
|
</body>
|
|
96
96
|
</html>`;
|
|
97
97
|
}
|
|
98
|
-
function openPrintWindow(htmlDocument, filename = "print") {
|
|
99
|
-
const win = window.open("", "_blank",
|
|
98
|
+
function openPrintWindow(htmlDocument, filename = "print", windowFeatures = "width=920,height=720,scrollbars=yes") {
|
|
99
|
+
const win = window.open("", "_blank", windowFeatures);
|
|
100
100
|
if (!win) {
|
|
101
101
|
const blob = new Blob([htmlDocument], { type: "text/html;charset=utf-8" });
|
|
102
102
|
const url = URL.createObjectURL(blob);
|
|
@@ -106,12 +106,13 @@ function openPrintWindow(htmlDocument, filename = "print") {
|
|
|
106
106
|
document.body.appendChild(a);
|
|
107
107
|
a.click();
|
|
108
108
|
document.body.removeChild(a);
|
|
109
|
-
URL.revokeObjectURL(url);
|
|
110
|
-
return;
|
|
109
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
110
|
+
return "downloaded";
|
|
111
111
|
}
|
|
112
112
|
win.document.open();
|
|
113
113
|
win.document.write(htmlDocument);
|
|
114
114
|
win.document.close();
|
|
115
|
+
return "opened";
|
|
115
116
|
}
|
|
116
117
|
function buildFitTextScript(selectors) {
|
|
117
118
|
const selectorsJson = JSON.stringify([...selectors]);
|
|
@@ -947,22 +948,7 @@ ${bodyHtml}
|
|
|
947
948
|
${FIT_TEXT_SCRIPT}
|
|
948
949
|
</body>
|
|
949
950
|
</html>`;
|
|
950
|
-
|
|
951
|
-
if (!win) {
|
|
952
|
-
const blob = new Blob([html], { type: "text/html;charset=utf-8" });
|
|
953
|
-
const url = URL.createObjectURL(blob);
|
|
954
|
-
const a = document.createElement("a");
|
|
955
|
-
a.href = url;
|
|
956
|
-
a.download = `${title.replace(/\s+/g, "-").toLowerCase()}-flashcards.html`;
|
|
957
|
-
document.body.appendChild(a);
|
|
958
|
-
a.click();
|
|
959
|
-
document.body.removeChild(a);
|
|
960
|
-
URL.revokeObjectURL(url);
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
win.document.open();
|
|
964
|
-
win.document.write(html);
|
|
965
|
-
win.document.close();
|
|
951
|
+
return openPrintWindow(html, `${title}-flashcards`, "width=1100,height=720,scrollbars=yes");
|
|
966
952
|
}
|
|
967
953
|
var AVERY_5388_STYLES = `
|
|
968
954
|
@page { size: portrait; margin: 0; }
|
|
@@ -1144,22 +1130,7 @@ ${bodyHtml}
|
|
|
1144
1130
|
${FIT_TEXT_SCRIPT}
|
|
1145
1131
|
</body>
|
|
1146
1132
|
</html>`;
|
|
1147
|
-
|
|
1148
|
-
if (!win) {
|
|
1149
|
-
const blob = new Blob([html], { type: "text/html;charset=utf-8" });
|
|
1150
|
-
const url = URL.createObjectURL(blob);
|
|
1151
|
-
const a = document.createElement("a");
|
|
1152
|
-
a.href = url;
|
|
1153
|
-
a.download = `${title.replace(/\s+/g, "-").toLowerCase()}-avery5388.html`;
|
|
1154
|
-
document.body.appendChild(a);
|
|
1155
|
-
a.click();
|
|
1156
|
-
document.body.removeChild(a);
|
|
1157
|
-
URL.revokeObjectURL(url);
|
|
1158
|
-
return;
|
|
1159
|
-
}
|
|
1160
|
-
win.document.open();
|
|
1161
|
-
win.document.write(html);
|
|
1162
|
-
win.document.close();
|
|
1133
|
+
return openPrintWindow(html, `${title}-avery5388`, "width=900,height=720,scrollbars=yes");
|
|
1163
1134
|
}
|
|
1164
1135
|
var PORTRAIT_6UP_STYLES = `
|
|
1165
1136
|
@page { size: portrait; margin: 0; }
|
|
@@ -1409,22 +1380,7 @@ ${bodyHtml}
|
|
|
1409
1380
|
${FIT_TEXT_SCRIPT}
|
|
1410
1381
|
</body>
|
|
1411
1382
|
</html>`;
|
|
1412
|
-
|
|
1413
|
-
if (!win) {
|
|
1414
|
-
const blob = new Blob([html], { type: "text/html;charset=utf-8" });
|
|
1415
|
-
const url = URL.createObjectURL(blob);
|
|
1416
|
-
const a = document.createElement("a");
|
|
1417
|
-
a.href = url;
|
|
1418
|
-
a.download = `${title.replace(/\s+/g, "-").toLowerCase()}-flashcards-6up.html`;
|
|
1419
|
-
document.body.appendChild(a);
|
|
1420
|
-
a.click();
|
|
1421
|
-
document.body.removeChild(a);
|
|
1422
|
-
URL.revokeObjectURL(url);
|
|
1423
|
-
return;
|
|
1424
|
-
}
|
|
1425
|
-
win.document.open();
|
|
1426
|
-
win.document.write(html);
|
|
1427
|
-
win.document.close();
|
|
1383
|
+
return openPrintWindow(html, `${title}-flashcards-6up`, "width=900,height=720,scrollbars=yes");
|
|
1428
1384
|
}
|
|
1429
1385
|
function deriveTitle(data) {
|
|
1430
1386
|
if (data && typeof data === "object" && "title" in data) {
|
|
@@ -1603,7 +1559,7 @@ var flashcardsPrinter = {
|
|
|
1603
1559
|
const title = deriveTitle(data);
|
|
1604
1560
|
const s = resolveSettings(rawSettings);
|
|
1605
1561
|
if (allCards.length === 0) {
|
|
1606
|
-
openPrintWindow(
|
|
1562
|
+
return openPrintWindow(
|
|
1607
1563
|
buildPrintDocument(
|
|
1608
1564
|
"<p>No flashcard data available to print.</p>",
|
|
1609
1565
|
title,
|
|
@@ -1611,7 +1567,6 @@ var flashcardsPrinter = {
|
|
|
1611
1567
|
),
|
|
1612
1568
|
"flashcards"
|
|
1613
1569
|
);
|
|
1614
|
-
return;
|
|
1615
1570
|
}
|
|
1616
1571
|
const rawFrom = typeof rawSettings?.fromCard === "number" ? rawSettings.fromCard : 0;
|
|
1617
1572
|
const rawTo = typeof rawSettings?.toCard === "number" ? rawSettings.toCard : 0;
|
|
@@ -1621,36 +1576,31 @@ var flashcardsPrinter = {
|
|
|
1621
1576
|
const startIndex = fromIdx - 1;
|
|
1622
1577
|
const cards = allCards.slice(startIndex, toIdx);
|
|
1623
1578
|
if (variantId === "landscape-duplex") {
|
|
1624
|
-
openLandscapeWindow(
|
|
1579
|
+
return openLandscapeWindow(
|
|
1625
1580
|
renderLandscape(cards, title, "duplex", s, startIndex),
|
|
1626
1581
|
title
|
|
1627
1582
|
);
|
|
1628
|
-
return;
|
|
1629
1583
|
}
|
|
1630
1584
|
if (variantId === "landscape-stacked") {
|
|
1631
|
-
openLandscapeWindow(
|
|
1585
|
+
return openLandscapeWindow(
|
|
1632
1586
|
renderLandscape(cards, title, "stacked", s, startIndex),
|
|
1633
1587
|
title
|
|
1634
1588
|
);
|
|
1635
|
-
return;
|
|
1636
1589
|
}
|
|
1637
1590
|
if (variantId === "portrait-6up-duplex") {
|
|
1638
|
-
openPortrait6UpWindow(
|
|
1591
|
+
return openPortrait6UpWindow(
|
|
1639
1592
|
renderPortrait6Up(cards, title, "duplex", s, startIndex),
|
|
1640
1593
|
title
|
|
1641
1594
|
);
|
|
1642
|
-
return;
|
|
1643
1595
|
}
|
|
1644
1596
|
if (variantId === "portrait-6up-stacked") {
|
|
1645
|
-
openPortrait6UpWindow(
|
|
1597
|
+
return openPortrait6UpWindow(
|
|
1646
1598
|
renderPortrait6Up(cards, title, "stacked", s, startIndex),
|
|
1647
1599
|
title
|
|
1648
1600
|
);
|
|
1649
|
-
return;
|
|
1650
1601
|
}
|
|
1651
1602
|
if (variantId === "avery-5388") {
|
|
1652
|
-
openAveryWindow(renderAvery5388(cards, title, s, startIndex), title);
|
|
1653
|
-
return;
|
|
1603
|
+
return openAveryWindow(renderAvery5388(cards, title, s, startIndex), title);
|
|
1654
1604
|
}
|
|
1655
1605
|
let bodyHtml;
|
|
1656
1606
|
let styles;
|
|
@@ -1677,7 +1627,10 @@ var flashcardsPrinter = {
|
|
|
1677
1627
|
styles = BOTH_SIDES_STYLES;
|
|
1678
1628
|
break;
|
|
1679
1629
|
}
|
|
1680
|
-
openPrintWindow(
|
|
1630
|
+
return openPrintWindow(
|
|
1631
|
+
buildPrintDocument(bodyHtml, title, styles),
|
|
1632
|
+
"flashcards"
|
|
1633
|
+
);
|
|
1681
1634
|
}
|
|
1682
1635
|
};
|
|
1683
1636
|
export {
|