Skip to content

feat(editor): header/footer + page-number authoring (DocxSession → editor) #236

Description

@JSv4

Summary

The DocxSession mutation API (and therefore the WASM bridge, npm DocxEditor, and docx-scalpel) has no surface for creating or editing headers, footers, or page-number fields. They can only be inspected: SectionInfo.HeaderPartUris / FooterPartUris are read-only, and there is no AddHeader / AddFooter / InsertPageNumber. This blocks faithful reproduction of real-world filings.

Surfaced during an editor smoke test reproducing the first page of a contract: the document's running footer (Last Updated October 2025) and centered page number (1) could not be authored at all — there is no UI affordance and no engine method.

Current state (confirmed)

  • Docxodus/DocxSession.cs — Insert/Add methods cover paragraphs, rules, tabs, tables, annotations, formatting; none for header/footer/page-number. SectionInfo exposes HeaderPartUris/FooterPartUris (read-only inspection only).
  • wasm/DocxodusWasm/DocxSessionBridge.cs — no header/footer ops.
  • npm/src/editor.ts — command surface is insertHorizontalRule/insertTab/insertTable/table CRUD/pageBreakBefore/lists/styles; no header/footer/page-number command.
  • Precedent for an explicit "not yet" signal already exists: the FootnoteRefNotSupported EditErrorCode.

Proposed scope (subsequent work — placeholder for design)

Author per-section headers/footers and page-number fields, addressed by the section that owns them (GetSectionInfo already returns the section's header/footer part URIs and page setup). Sketch, to be designed:

  • DocxSession.SetHeaderText(sectionAnchor, HeaderFooterType, markdown) / SetFooterText(...) — create the part + relationship + w:headerReference/w:footerReference if absent; default/first/even types.
  • DocxSession.InsertPageNumberField(headerOrFooterAnchor, offset, format?)PAGE (and NUMPAGES) field.
  • Ripple per CLAUDE.md: DocxSessionOps → bridge + stdio Dispatchertypes.ts/index.ts + docx-scalpel → tests → docs.
  • Editor: a header/footer editing affordance (likely a separate editable region, since header/footer parts live outside the body).

Related but separate: footnote/endnote authoring (also unsupported) — track independently.

Found via the editor multi-block-selection smoke test (branch feat/editor-multi-block-selection).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions