Skip to content

Merge main into stable - #3868

Merged
caio-pizzol merged 3 commits into
stablefrom
merge/main-into-stable-2026-08-05
Aug 5, 2026
Merged

Merge main into stable#3868
caio-pizzol merged 3 commits into
stablefrom
merge/main-into-stable-2026-08-05

Conversation

@superdoc-orbit

@superdoc-orbit superdoc-orbit Bot commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • creates merge/main-into-stable-2026-08-05 from stable
  • merges main into the candidate branch
  • opens the promotion PR to stable

Auto-created by promote-stable workflow.

Review in cubic

caio-pizzol and others added 3 commits August 4, 2026 23:27
…#3861)

Keeps tables in documents whose `word/styles.xml` carries empty property containers, such as a self-closing `<w:rPr/>` on Table Grid. Word opens these files; SuperDoc was dropping the tables. Issue #3861 reports LibreOffice and some Word templates as the source.

xml-js omits the `elements` key rather than emitting an empty one, so `<w:rPr/>`, `<w:rPr />` and `<w:rPr></w:rPr>` all arrive with no children, and the style reader assumed that key was there. The importer catches per node, so the throw was swallowed and only the table vanished, which is why an affected document looked blank rather than raising an error.

- Reading through shared accessors closes five unguarded spots, not just the reported `w:rPr`. A `w:basedOn` pointing at a childless style throws first, before execution reaches the `w:rPr`, and with an identical message, so fixing only the reported line could look like no fix at all.
- Conditional formatting entries with no `w:type` are skipped rather than keyed under `undefined`. ECMA-376 marks that attribute required.
- Empty `w:tblPr`, `w:tcPr` and `w:trPr` were already safe. The issue lists them as broken, so tests record that they are not.
- Fixtures parse XML strings deliberately. Hand-authored nodes using `elements: []` do not reproduce the parser shape and pass against this bug.

Byte-identical across v1.43.2, v1.44.2, v1.45.2 and main.

Fixes #3861

Co-authored-by: Caio Pizzol <caio@harbourshare.com>
Source-PR: #3864
Closes #3864

Ported-From-Source-Repo: superdoc/orbit
Ported-From-Source-Commit: 0f2d0c8330880789de1df54e7e9345eacd395ccd
Ported-Public-Prefix: superdoc/public
…able (#3861)

Stops one malformed `w:style` from discarding an entire imported document. Same root cause as #3861, much worse outcome, so it is split out for separate review.

The style catalogue is built outside the importer per-node recovery boundary. A throw there aborts `createDocumentJson`, `getSchema` returns null, and `createDocument` falls back to an empty document, losing the whole body instead of one node. The `exception` event does fire and hosts can subscribe via `onException`, so it is not strictly silent, but the default is a blank editable page with no error state.

- Scope: the fragment in #3861 does not reach this path. It needs an empty `w:outlineLvl`, an empty `w:tab`, a repeated `w:styleId` whose second record is empty, or a `w:style` with no attributes. Whether the reporting customer hit this is unknown without their file.
- Guarding the crash was not enough. An outline level with a missing or non-numeric `w:val` still parsed to NaN, and a tab stop missing `w:val` or `w:pos` was still emitted half-formed. Both attributes are required in ECMA-376, so both records are now dropped, and the tests assert parsed values rather than only that import survived.
- Style records with no `w:styleId` are skipped, since nothing can reference them, and the latent-style loop that collected into an unread list is gone.

Not included: the `getSchema` fallback of returning null and mounting an empty document. Turning a parse failure into a blank page is arguably wrong, but it changes an initialization contract and deserves its own decision.

Co-authored-by: Caio Pizzol <caio@harbourshare.com>
Source-PR: #3865
Closes #3865

Ported-From-Source-Repo: superdoc/orbit
Ported-From-Source-Commit: 3e95f6364d02575d3ea78019d3fa2a930617dcc4
Ported-Public-Prefix: superdoc/public
@superdoc-orbit
superdoc-orbit Bot requested a review from a team as a code owner August 5, 2026 00:35
@caio-pizzol
caio-pizzol enabled auto-merge August 5, 2026 00:37
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

I wasn't able to get the ecma-spec MCP tools authorized in this session (every call returned "haven't granted it yet"), so I verified the spec claims against my own knowledge of the ECMA-376 XSDs rather than the live tools. Flagging that caveat up front. Here's the review:

Status: PASS

This PR is a defensive-hardening refactor: it routes all .elements/.attributes access through safe helpers (xml-node-access.js) so empty-but-schema-valid containers (<w:rPr/>, <w:pPr/>, etc.) no longer throw during import (issue #3861). Crucially, it doesn't introduce any new elements or attributes — it reads the same OOXML vocabulary as before, just more safely. And the validation it adds actually tightens spec conformance rather than loosening it. Checking the specific spec assertions the code bakes in:

  • w:tab / CT_TabStop — code drops a stop unless both w:val and a finite w:pos are present. Correct: both are use="required" on CT_TabStop (w:val is ST_TabJc, w:pos is ST_SignedTwipsMeasure). The comment correctly notes w:pos is a union of xsd:integer and ST_UniversalMeasure, so dropping "1.5in" rather than validating it as an integer is the right call — it's an unimplemented conversion, not a rejection of legal XML. https://ooxml.dev/spec?q=tab

  • w:outlineLvl / CT_DecimalNumberw:val is use="required" and typed ST_DecimalNumber (integer). Replacing parseInt (which silently accepted "2abc"→2, "3.9"→3) with a strict /^[+-]?\d+$/ test is a genuine correctness improvement and stays within the spec type. https://ooxml.dev/spec?q=outlineLvl

  • w:tblStylePr / CT_TblStylePr — code skips entries lacking w:type. Correct: w:type (ST_TblStyleOverrideType) is use="required"; an untyped conditional-format record can't be keyed into the cascade. https://ooxml.dev/spec?q=tblStylePr

  • w:style styleId filter (docxImporter.js) — the comment says a style without w:styleId "cannot be referenced," which is accurate. Note w:styleId is actually optional in the CT_Style schema, but the code doesn't claim otherwise — dropping unreferenceable records is a sound practical choice, not a spec claim. https://ooxml.dev/spec?q=style

One pre-existing item, not introduced by this PR but carried through the refactor: get-default-style-definition.js:88 reads w:pageBreakAfter from w:pPr. There's no w:pageBreakAfter in CT_PPr (only w:pageBreakBefore exists) — so that lookup can never match a valid document. It's dead code rather than an active violation, and since the PR only mechanically rewrapped the existing .find in findChild, it's out of scope here, but worth a cleanup ticket.

Net: no non-existent attributes/elements added, no missing-required regressions, and the new guards align with the required-attribute definitions on CT_TabStop, CT_DecimalNumber, and CT_TblStylePr.

@caio-pizzol
caio-pizzol disabled auto-merge August 5, 2026 01:00
@caio-pizzol
caio-pizzol merged commit bcf7b9c into stable Aug 5, 2026
58 checks passed
@caio-pizzol
caio-pizzol deleted the merge/main-into-stable-2026-08-05 branch August 5, 2026 01:00
@superdoc-orbit

superdoc-orbit Bot commented Aug 5, 2026

Copy link
Copy Markdown
Author

🎉 This PR is included in superdoc-cli v0.23.1

The release is available on GitHub release

@superdoc-orbit

superdoc-orbit Bot commented Aug 5, 2026

Copy link
Copy Markdown
Author

🎉 This PR is included in superdoc-sdk v1.22.1

@superdoc-orbit

superdoc-orbit Bot commented Aug 5, 2026

Copy link
Copy Markdown
Author

🎉 This PR is included in @superdoc-dev/mcp v0.18.1

The release is available on GitHub release

@superdoc-orbit

superdoc-orbit Bot commented Aug 5, 2026

Copy link
Copy Markdown
Author

🎉 This PR is included in superdoc v1.46.1

The release is available on GitHub release

@superdoc-orbit

superdoc-orbit Bot commented Aug 5, 2026

Copy link
Copy Markdown
Author

🎉 This PR is included in @superdoc-dev/react v1.17.1

The release is available on GitHub release

@superdoc-orbit

superdoc-orbit Bot commented Aug 5, 2026

Copy link
Copy Markdown
Author

🎉 This PR is included in vscode-ext v2.18.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant