@ai-matrx/print 0.12.8 → 0.12.10

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 CHANGED
@@ -1,11 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.10
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/print/v0.12.9..npm/print/v0.12.10 -- apps/shared/print`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.12.9
10
+
11
+ - Flashcards in a composed print (a message's Print): the study sheet is styled through the `css`
12
+ channel with `matrx-fc-*` classes (it was stripped to bare text), a bare array of cards is read,
13
+ `question`/`term` cards are read, and a deck the printer cannot read answers `null` so the default
14
+ path runs instead of printing a false "no cards". The standalone print is byte-identical.
15
+ Consumer action: a host that stores decks as `Front:/Back:` markdown parses them with its own parser
16
+ and hands `{ title, cards }` (matrx-frontend registers that adapter).
17
+
3
18
  ## 0.12.8
4
19
 
5
20
  Automatic changed-only republish (docs/metadata drift since the last tag — see
6
21
  `git diff npm/print/v0.12.7..npm/print/v0.12.8 -- apps/shared/print`).
7
22
  No source changes intended and no consumer action required.
8
23
 
24
+ ## 0.12.7
25
+
26
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
27
+ `git diff npm/print/v0.12.6..npm/print/v0.12.7 -- apps/shared/print`).
28
+ No source changes intended and no consumer action required.
29
+
9
30
  ## 0.12.6
10
31
 
11
32
  - A block printer's stylesheet reaches a composed print: `PrintBlockOutput` `{ html }` takes an
@@ -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
- if (typeof data === "object" && data !== null && "cards" in data) {
289
- const cards = data.cards;
290
- return Array.isArray(cards) ? cards : [];
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
- function renderStudySheet(cards, title, s, startIndex = 0) {
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="row-num">${startIndex + i + 1}.</span>${faceImageHtml(card, "front", s.showImages)}${mathTextHtml(card.front)}</td>
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="deck-header">
621
- <h1 class="deck-title">${mathTextHtml(title)}</h1>
622
- <div class="deck-meta">${cards.length} card${cards.length !== 1 ? "s" : ""} &nbsp;\xB7&nbsp; Study sheet</div>
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" : ""} &nbsp;\xB7&nbsp; 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 { notice: "This flashcard deck has no cards to print." };
1749
- return { html: renderStudySheet(cards, deriveTitle(data), resolveSettings(void 0)) };
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