Skip to content

Commit 25957c8

Browse files
refactor(fields): accept generic options in SECTIONPAGES preprocessor
Replace the third positional `_docxOrFieldRunRPr` argument with a generic field-preprocessing `options` object (docx, instructionTokens, fieldRunRPr), keeping backward-compat with the legacy positional w:rPr. Update cache-invalidation test fixtures to the `pageNumberFieldFormat` run shape.
1 parent 487e8df commit 25957c8

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ describe('Cache Invalidation', () => {
5757
{
5858
kind: 'paragraph',
5959
id: 'p1',
60-
runs: [{ text: '0', token: 'pageNumber', pageNumberFormat: 'decimal' }],
60+
runs: [{ text: '0', token: 'pageNumber', pageNumberFieldFormat: { format: 'decimal' } }],
6161
} as ParagraphBlock,
6262
];
6363
const romanBlocks: FlowBlock[] = [
6464
{
6565
kind: 'paragraph',
6666
id: 'p1',
67-
runs: [{ text: '0', token: 'pageNumber', pageNumberFormat: 'upperRoman' }],
67+
runs: [{ text: '0', token: 'pageNumber', pageNumberFieldFormat: { format: 'upperRoman' } }],
6868
} as ParagraphBlock,
6969
];
7070

packages/super-editor/src/editors/v1/core/super-converter/field-references/fld-preprocessors/section-pages-preprocessor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { parsePageInstruction } from './page-instruction.js';
55
*
66
* @param {import('../../v2/types/index.js').OpenXmlNode[]} nodesToCombine The nodes between separate and end.
77
* @param {string} [instrText] The SECTIONPAGES instruction text.
8-
* @param {unknown} [_docxOrFieldRunRPr] The parsed docx in the main import path, or w:rPr in header/footer-only preprocessing.
8+
* @param {{ docx?: import('../../v2/docxHelper').ParsedDocx, instructionTokens?: Array<{type: string, text?: string}> | null, fieldRunRPr?: import('../../v2/types/index.js').OpenXmlNode | null } | import('../../v2/types/index.js').OpenXmlNode | null} [options] Generic field preprocessing options, or legacy positional w:rPr.
99
* @param {Array<{type: string, text?: string}> | null} [_instructionTokens] Raw instruction tokens.
1010
* @param {import('../../v2/types/index.js').OpenXmlNode | null} [fieldRunRPr=null] The w:rPr node captured from field sequence nodes.
1111
* @returns {import('../../v2/types/index.js').OpenXmlNode[]}
1212
*/
1313
export function preProcessSectionPagesInstruction(
1414
nodesToCombine,
1515
instrText = '',
16-
_docxOrFieldRunRPr = null,
16+
options = null,
1717
_instructionTokens,
1818
fieldRunRPr = null,
1919
) {
20-
const effectiveFieldRunRPr = fieldRunRPr ?? (_docxOrFieldRunRPr?.name === 'w:rPr' ? _docxOrFieldRunRPr : null);
20+
const effectiveFieldRunRPr = fieldRunRPr ?? options?.fieldRunRPr ?? (options?.name === 'w:rPr' ? options : null);
2121
const parsedInstruction = parsePageInstruction(instrText, 'SECTIONPAGES');
2222
const sectionPageCountNode = {
2323
name: 'sd:sectionPageCount',

0 commit comments

Comments
 (0)