Skip to content

Commit 0e71e21

Browse files
fix(layout-bridge): hash page number formats
1 parent d966125 commit 0e71e21

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

packages/layout-engine/layout-bridge/src/cacheInvalidation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function computeHeaderFooterContentHash(blocks: FlowBlock[]): string {
5151
if ('bold' in run && run.bold) parts.push('b');
5252
if ('italic' in run && run.italic) parts.push('i');
5353
if ('token' in run && run.token) parts.push(`token:${run.token}`);
54+
if ('pageNumberFormat' in run && run.pageNumberFormat) parts.push(`pnf:${run.pageNumberFormat}`);
5455
}
5556
}
5657
}

packages/layout-engine/layout-bridge/test/cacheInvalidation.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ describe('Cache Invalidation', () => {
5252
expect(hash).toContain('token:pageNumber');
5353
});
5454

55+
it('should include page number token format in hash', () => {
56+
const decimalBlocks: FlowBlock[] = [
57+
{
58+
kind: 'paragraph',
59+
id: 'p1',
60+
runs: [{ text: '0', token: 'pageNumber', pageNumberFormat: 'decimal' }],
61+
} as ParagraphBlock,
62+
];
63+
const romanBlocks: FlowBlock[] = [
64+
{
65+
kind: 'paragraph',
66+
id: 'p1',
67+
runs: [{ text: '0', token: 'pageNumber', pageNumberFormat: 'upperRoman' }],
68+
} as ParagraphBlock,
69+
];
70+
71+
expect(computeHeaderFooterContentHash(decimalBlocks)).not.toBe(computeHeaderFooterContentHash(romanBlocks));
72+
});
73+
5574
it('should produce different hashes for different content', () => {
5675
const blocks1: FlowBlock[] = [
5776
{

0 commit comments

Comments
 (0)