@ai-matrx/print 0.12.8 → 0.12.9
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 +15 -0
- package/dist/flashcards.cjs +52 -12
- package/dist/flashcards.cjs.map +1 -1
- package/dist/flashcards.js +52 -12
- package/dist/flashcards.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.9
|
|
4
|
+
|
|
5
|
+
- Flashcards in a composed print (a message's Print): the study sheet is styled through the `css`
|
|
6
|
+
channel with `matrx-fc-*` classes (it was stripped to bare text), a bare array of cards is read,
|
|
7
|
+
`question`/`term` cards are read, and a deck the printer cannot read answers `null` so the default
|
|
8
|
+
path runs instead of printing a false "no cards". The standalone print is byte-identical.
|
|
9
|
+
Consumer action: a host that stores decks as `Front:/Back:` markdown parses them with its own parser
|
|
10
|
+
and hands `{ title, cards }` (matrx-frontend registers that adapter).
|
|
11
|
+
|
|
3
12
|
## 0.12.8
|
|
4
13
|
|
|
5
14
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
15
|
`git diff npm/print/v0.12.7..npm/print/v0.12.8 -- apps/shared/print`).
|
|
7
16
|
No source changes intended and no consumer action required.
|
|
8
17
|
|
|
18
|
+
## 0.12.7
|
|
19
|
+
|
|
20
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
21
|
+
`git diff npm/print/v0.12.6..npm/print/v0.12.7 -- apps/shared/print`).
|
|
22
|
+
No source changes intended and no consumer action required.
|
|
23
|
+
|
|
9
24
|
## 0.12.6
|
|
10
25
|
|
|
11
26
|
- A block printer's stylesheet reaches a composed print: `PrintBlockOutput` `{ html }` takes an
|
package/dist/flashcards.cjs
CHANGED
|
@@ -283,13 +283,20 @@ function resolveSettings(raw) {
|
|
|
283
283
|
showImages: b("showImages")
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
|
+
function toCard(entry) {
|
|
287
|
+
if (!entry || typeof entry !== "object") return null;
|
|
288
|
+
const e = entry;
|
|
289
|
+
if (typeof e.front === "string") return entry;
|
|
290
|
+
const front = e.question ?? e.term;
|
|
291
|
+
if (typeof front !== "string") return null;
|
|
292
|
+
const back = e.back ?? e.answer ?? e.definition;
|
|
293
|
+
return { ...entry, front, back: typeof back === "string" ? back : "" };
|
|
294
|
+
}
|
|
286
295
|
function extractCards(data) {
|
|
287
296
|
if (!data) return [];
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
return [];
|
|
297
|
+
const list = Array.isArray(data) ? data : typeof data === "object" && "cards" in data ? data.cards : null;
|
|
298
|
+
if (!Array.isArray(list)) return [];
|
|
299
|
+
return list.map(toCard).filter((card) => card !== null);
|
|
293
300
|
}
|
|
294
301
|
function faceImageHtml(card, face, showImages = true) {
|
|
295
302
|
if (!showImages) return "";
|
|
@@ -610,16 +617,22 @@ var STUDY_SHEET_STYLES = `
|
|
|
610
617
|
tbody tr:nth-child(even) td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
611
618
|
}
|
|
612
619
|
`;
|
|
613
|
-
|
|
620
|
+
var STUDY_SHEET_LEGACY_CLASSES = {
|
|
621
|
+
header: "deck-header",
|
|
622
|
+
title: "deck-title",
|
|
623
|
+
meta: "deck-meta",
|
|
624
|
+
rowNum: "row-num"
|
|
625
|
+
};
|
|
626
|
+
function renderStudySheet(cards, title, s, startIndex = 0, c = STUDY_SHEET_LEGACY_CLASSES) {
|
|
614
627
|
const rows = cards.map(
|
|
615
628
|
(card, i) => ` <tr>
|
|
616
|
-
<td><span class="
|
|
629
|
+
<td><span class="${c.rowNum}">${startIndex + i + 1}.</span>${faceImageHtml(card, "front", s.showImages)}${mathTextHtml(card.front)}</td>
|
|
617
630
|
<td>${faceImageHtml(card, "back", s.showImages)}${mathTextHtml(card.back ?? "")}</td>
|
|
618
631
|
</tr>`
|
|
619
632
|
).join("\n");
|
|
620
|
-
return `<div class="
|
|
621
|
-
<h1 class="
|
|
622
|
-
<div class="
|
|
633
|
+
return `<div class="${c.header}">
|
|
634
|
+
<h1 class="${c.title}">${mathTextHtml(title)}</h1>
|
|
635
|
+
<div class="${c.meta}">${cards.length} card${cards.length !== 1 ? "s" : ""} \xB7 Study sheet</div>
|
|
623
636
|
</div>
|
|
624
637
|
<table>
|
|
625
638
|
<thead>
|
|
@@ -633,6 +646,29 @@ ${rows}
|
|
|
633
646
|
</tbody>
|
|
634
647
|
</table>`;
|
|
635
648
|
}
|
|
649
|
+
var COMPOSED_CLASSES = {
|
|
650
|
+
header: "matrx-fc-header",
|
|
651
|
+
title: "matrx-fc-title",
|
|
652
|
+
meta: "matrx-fc-meta",
|
|
653
|
+
rowNum: "matrx-fc-row-num"
|
|
654
|
+
};
|
|
655
|
+
var COMPOSED_STUDY_SHEET_CSS = `
|
|
656
|
+
.matrx-fc-sheet .matrx-fc-header { border-bottom: 1.5px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 16px; }
|
|
657
|
+
.matrx-fc-sheet .matrx-fc-title { font-size: 13pt; font-weight: 700; color: #1e293b; margin: 0 0 4px 0; letter-spacing: -0.01em; border-bottom: none; }
|
|
658
|
+
.matrx-fc-sheet .matrx-fc-meta { font-size: 8.5pt; color: #64748b; }
|
|
659
|
+
.matrx-fc-sheet table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 10pt; }
|
|
660
|
+
.matrx-fc-sheet thead th { background: #1e293b; color: #f1f5f9; padding: 8px 12px; text-align: left; font-size: 8.5pt; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
|
|
661
|
+
.matrx-fc-sheet thead th:first-child { width: 38%; }
|
|
662
|
+
.matrx-fc-sheet tbody tr { page-break-inside: avoid; break-inside: avoid; }
|
|
663
|
+
.matrx-fc-sheet tbody tr:nth-child(even) td { background: #f8fafc; }
|
|
664
|
+
.matrx-fc-sheet tbody td { padding: 8px 12px; vertical-align: top; border-bottom: 1px solid #e2e8f0; line-height: 1.5; white-space: pre-line; }
|
|
665
|
+
.matrx-fc-sheet tbody td:first-child { font-weight: 600; border-right: 1px solid #e2e8f0; color: #1e3a5f; }
|
|
666
|
+
.matrx-fc-sheet .matrx-fc-row-num { display: inline-block; width: 18px; font-size: 8pt; color: #94a3b8; font-weight: 400; margin-right: 4px; }
|
|
667
|
+
.matrx-fc-sheet .matrx-fc-face-image { display: block; max-width: 100%; max-height: 1.6in; margin: 0 auto 6px auto; object-fit: contain; }
|
|
668
|
+
@media print {
|
|
669
|
+
.matrx-fc-sheet thead th, .matrx-fc-sheet tbody tr:nth-child(even) td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
670
|
+
}
|
|
671
|
+
`;
|
|
636
672
|
var FRONT_ONLY_STYLES = `
|
|
637
673
|
${BASE_STYLES}
|
|
638
674
|
|
|
@@ -1745,8 +1781,12 @@ var flashcardsPrinter = {
|
|
|
1745
1781
|
// paper cannot flip, and a cut sheet belongs to the deck's own print.
|
|
1746
1782
|
toPrintHtml(data) {
|
|
1747
1783
|
const cards = extractCards(data);
|
|
1748
|
-
if (cards.length === 0) return
|
|
1749
|
-
|
|
1784
|
+
if (cards.length === 0) return null;
|
|
1785
|
+
const sheet = renderStudySheet(cards, deriveTitle(data), resolveSettings(void 0), 0, COMPOSED_CLASSES).replaceAll(
|
|
1786
|
+
'class="face-image"',
|
|
1787
|
+
'class="matrx-fc-face-image"'
|
|
1788
|
+
);
|
|
1789
|
+
return { html: `<div class="matrx-fc-sheet">${sheet}</div>`, css: COMPOSED_STUDY_SHEET_CSS };
|
|
1750
1790
|
}
|
|
1751
1791
|
};
|
|
1752
1792
|
//# sourceMappingURL=flashcards.cjs.map
|