Files
final-wishes/src/print.js
Eric Bell e291ee75b6 Add print layout
Print dialog with withhold/include secrets modes, cover page with
contents, one section per page, non-splitting record blocks, TBD
highlighting that survives black and white, tick boxes on steps and
checklist items, and a per-page footer. Print content is built on demand
and cleared after printing. Pure display helpers live in print.js with
tests.

Closes #5

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 08:13:11 -05:00

25 lines
804 B
JavaScript

// Pure helpers for the printed document. No DOM; tested in Node.
// build.js strips `export` when bundling.
// What to print for a field. Secrets are either shown or withheld; an empty
// secret is always "(not set)" so a blank is never mistaken for a hidden value.
export function displayValue(field, includeSecrets) {
if (field.secret) {
if (!field.value) return '(not set)';
return includeSecrets ? field.value : '[withheld]';
}
return field.value || '(blank)';
}
export function footerText(doc) {
return `${doc.meta.title || 'Final Wishes'} — Last update: ${doc.meta.lastUpdated}`;
}
export function countSecrets(doc) {
let n = 0;
for (const s of doc.sections) {
for (const r of s.records || []) for (const f of r.fields) if (f.secret && f.value) n++;
}
return n;
}