Add configurable running print header

The line printed on every page is now a header stored in the document as
header.fields: any number of Text / Last updated fields, each optionally
aligned left or right (at most one of each). Printed order is left,
unaligned, right. Edited from a Print header panel with live preview;
documents without a header use the previous title/last-update default.
The header is a repeating table header so it sits in flow and cannot
overlap body text, replacing the fixed-position footer.

Also add "Open your existing Final Wishes file" to the start screen so
data in an older encrypted file can be carried into a newer build.

Closes #9

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 13:23:31 -05:00
parent e4a64eea5d
commit 70c384cdcb
9 changed files with 238 additions and 21 deletions

View File

@@ -1,3 +1,5 @@
import { defaultHeaderFields } from './model.js';
// Pure helpers for the printed document. No DOM; tested in Node.
// build.js strips `export` when bundling.
@@ -11,8 +13,25 @@ export function displayValue(field, includeSecrets) {
return field.value || '(blank)';
}
export function footerText(doc) {
return `${doc.meta.title || 'Final Wishes'} — Last update: ${doc.meta.lastUpdated}`;
export function headerFields(doc) {
return doc.header ? doc.header.fields : defaultHeaderFields(doc);
}
export function headerText(field, doc) {
return field.kind === 'lastUpdated' ? (field.text || '') + doc.meta.lastUpdated : field.text;
}
// { left, middle: [..], right } in printed order: the left-aligned field, then
// unaligned fields in list order, then the right-aligned field. Empty text is dropped.
export function headerLayout(doc) {
const fields = headerFields(doc);
const left = fields.find((f) => f.align === 'left');
const right = fields.find((f) => f.align === 'right');
return {
left: left ? headerText(left, doc) : '',
middle: fields.filter((f) => f.align !== 'left' && f.align !== 'right').map((f) => headerText(f, doc)).filter(Boolean),
right: right ? headerText(right, doc) : '',
};
}
export function countSecrets(doc) {