Skip to content

Commit f5c3436

Browse files
committed
chore: resolve conflicts
1 parent ece83b6 commit f5c3436

2 files changed

Lines changed: 13 additions & 33 deletions

File tree

packages/super-editor/src/editors/v1/core/header-footer/HeaderFooterPerRidLayout.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ const makeBlock = (id: string): FlowBlock => ({
2424
runs: [{ text: id, fontFamily: 'Arial', fontSize: 12 }],
2525
});
2626

27+
const makeParagraph = (id: string, text: string): FlowBlock => ({
28+
kind: 'paragraph',
29+
id,
30+
runs: [{ text, fontFamily: 'Arial', fontSize: 12 }],
31+
});
32+
2733
const makeMeasure = (): Measure => ({
2834
kind: 'paragraph',
2935
lines: [

packages/super-editor/src/editors/v1/core/header-footer/HeaderFooterPerRidLayout.ts

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -189,36 +189,6 @@ function collectReferencedRIdsBySection(effectiveRefsBySection: Map<number, Head
189189
return result;
190190
}
191191

192-
/**
193-
* Resolve the default header/footer rId for each section.
194-
*
195-
* Multi-section layout has historically measured only the default variant with
196-
* section-specific constraints. Preserve that behavior to avoid changing
197-
* established rendering for documents that use first/even/odd variants.
198-
*/
199-
function resolveDefaultRIdPerSection(
200-
sectionMetadata: SectionMetadata[],
201-
kind: 'header' | 'footer',
202-
): Map<number, string> {
203-
const result = new Map<number, string>();
204-
let inheritedDefaultRId: string | undefined;
205-
206-
for (const section of sectionMetadata) {
207-
const refs = getRefsForKind(section, kind);
208-
const explicitDefaultRId = refs?.default;
209-
210-
if (explicitDefaultRId) {
211-
inheritedDefaultRId = explicitDefaultRId;
212-
}
213-
214-
if (inheritedDefaultRId) {
215-
result.set(section.sectionIndex, inheritedDefaultRId);
216-
}
217-
}
218-
219-
return result;
220-
}
221-
222192
/**
223193
* Layout header/footer blocks per rId, respecting per-section margins.
224194
*
@@ -411,7 +381,7 @@ async function layoutWithPerSectionConstraints(
411381
): Promise<void> {
412382
if (!blocksByRId) return;
413383

414-
const defaultRIdPerSection = resolveDefaultRIdPerSection(sectionMetadata, kind);
384+
const effectiveRefsBySection = buildEffectiveRefsBySection(sectionMetadata, kind);
415385

416386
// Extract table width specs per rId (SD-1837).
417387
// Word allows tables in headers/footers to extend beyond content margins.
@@ -433,8 +403,12 @@ async function layoutWithPerSectionConstraints(
433403
>();
434404

435405
for (const section of sectionMetadata) {
436-
const rId = defaultRIdPerSection.get(section.sectionIndex);
437-
if (!rId || !blocksByRId.has(rId)) continue;
406+
const refs = effectiveRefsBySection.get(section.sectionIndex);
407+
if (!refs) continue;
408+
409+
for (const variant of HEADER_FOOTER_VARIANTS) {
410+
const rId = refs[variant];
411+
if (!rId || !blocksByRId.has(rId)) continue;
438412

439413
// Resolve the minimum width needed for tables in this section.
440414
// For pct tables, this depends on the section's content width.

0 commit comments

Comments
 (0)