Skip to content

fix(super-editor): guard against style definition nodes without elements#2379

Open
luccas-harbour wants to merge 1 commit intomainfrom
luccas/sd-2193-bug-doc-imports-as-blank-and-crashes-on-exportroundtrip
Open

fix(super-editor): guard against style definition nodes without elements#2379
luccas-harbour wants to merge 1 commit intomainfrom
luccas/sd-2193-bug-doc-imports-as-blank-and-crashes-on-exportroundtrip

Conversation

@luccas-harbour
Copy link
Contributor

Summary

Prevents getDefaultStyleDefinition() from crashing when a matching style node exists in word/styles.xml but does not contain an elements array.

What changed

  • Added an early return in packages/super-editor/src/core/super-converter/docx-helpers/get-default-style-definition.js when the matched w:style node has no elements
  • Added a regression test in packages/super-editor/src/core/super-converter/docx-helpers/get-default-style-definition.test.js covering that malformed/incomplete style-
    definition shape
  • Verified the helper returns the minimal fallback object and does not attempt to parse marks in this case

Why

Some DOCX inputs can include a style definition node with the expected w:styleId but without child elements. Before this change, the helper assumed firstMatch.elements always existed and could throw while traversing the style definition. This makes the converter more defensive and preserves the existing fallback behavior for incomplete style data.

@linear
Copy link

linear bot commented Mar 12, 2026

@luccas-harbour luccas-harbour marked this pull request as ready for review March 12, 2026 17:21
@luccas-harbour luccas-harbour force-pushed the luccas/sd-2193-bug-doc-imports-as-blank-and-crashes-on-exportroundtrip branch from e8bc23f to 19a8cab Compare March 12, 2026 19:44
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