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

@@ -46,6 +46,23 @@ test('rejects structural problems', () => {
assert.deepEqual(validate(null), ['document must be an object']);
});
test('header validation: kinds, aligns, and one left / one right at most', () => {
const withHeader = (fields) => ({ ...good(), header: { fields } });
const ok = [{ kind: 'text', text: 'T', align: 'left' }, { kind: 'text', text: 'm' }, { kind: 'lastUpdated', text: '', align: 'right' }];
assert.deepEqual(validate(withHeader(ok)), []);
assert.deepEqual(validate(withHeader([])), []);
assert.deepEqual(validate(good()), []); // header is optional
const bad = [
[[{ kind: 'x', text: 'a' }], /unknown kind/],
[[{ kind: 'text', text: 5 }], /text must be a string/],
[[{ kind: 'text', text: 'a', align: 'center' }], /bad align/],
[[{ kind: 'text', text: 'a', align: 'left' }, { kind: 'text', text: 'b', align: 'left' }], /only one field can be left/],
[[{ kind: 'text', text: 'a', align: 'right' }, { kind: 'text', text: 'b', align: 'right' }], /only one field can be right/],
];
for (const [fields, re] of bad) assert.match(validate(withHeader(fields)).join('\n'), re);
assert.match(validate({ ...good(), header: {} }).join('\n'), /header.fields must be an array/);
});
// data/ is gitignored (private), so this only runs on a machine that has the seed.
test('data/seed.json, when present, is valid', { skip: !existsSync('data/seed.json') }, () => {
const seed = JSON.parse(readFileSync('data/seed.json', 'utf8'));