Skip to content

Respect localized built-in DOCX styles#3807

Open
replicant026 wants to merge 1 commit into
superdoc-dev:mainfrom
replicant026:codex/template-builder-superdoc-options
Open

Respect localized built-in DOCX styles#3807
replicant026 wants to merge 1 commit into
superdoc-dev:mainfrom
replicant026:codex/template-builder-superdoc-options

Conversation

@replicant026

@replicant026 replicant026 commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Updates DOCX default-style injection so SuperDoc recognizes localized built-in style equivalents before adding the built-in defaults.

Why

addDefaultStylesIfMissing previously checked only for exact canonical style IDs such as Title and Heading1. Some Word-authored DOCX files, especially localized documents, can contain built-in title/heading styles with localized or sanitized IDs/names, for example:

  • Ttulo / TΓ­tulo
  • Ttulo1 / TΓ­tulo 1
  • Kop1

Those styles should count as existing built-in title/heading styles. Without that recognition, SuperDoc appends its default Title/Heading1 definitions and consumers can see the default styling take precedence over the imported template's own heading/title styling.

What changed

  • Adds built-in style alias detection for the default style insertion path.
  • Normalizes style IDs and w:name values by stripping diacritics, spacing, and punctuation before matching.
  • Recognizes Portuguese title aliases (TΓ­tulo, TΓ­tulo 1) and existing localized heading examples such as Kop1.
  • Adds regression coverage for localized title/heading styles and for the normal missing-default case.

Validation

Passed:

node_modules/.bin/vitest.cmd run packages/super-editor/src/editors/v1/core/super-converter/v2/importer/docxImporter.test.js --root packages/super-editor

Result: 1 passed, 41 tests passed.

Note: running through pnpm --filter @superdoc/super-editor test -- ... on Windows triggered the monorepo prepare lifecycle with Unix shell syntax (if [ -z "$CI" ]), so the targeted test was run directly with the local Vitest binary after dependencies were installed.

@replicant026 replicant026 force-pushed the codex/template-builder-superdoc-options branch from 2354940 to 38a2027 Compare July 7, 2026 16:18
@replicant026 replicant026 changed the title Forward SuperDoc options from template builder Respect localized built-in DOCX styles Jul 7, 2026
@replicant026 replicant026 marked this pull request as ready for review July 7, 2026 16:20
@replicant026 replicant026 requested a review from a team as a code owner July 7, 2026 16:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38a2027144

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


function isEquivalentBuiltInStyle(styleElement, canonicalStyleId) {
if (styleElement.attributes?.['w:styleId'] === canonicalStyleId) return true;
if (styleElement.attributes?.['w:type'] !== 'paragraph') return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude custom styles from built-in alias matches

With this guard, any paragraph style can suppress a default built-in as soon as its normalized id or name matches an alias. In a DOCX that has a custom style marked w:customStyle="1" with an alias-like id/name such as Title or Kop1, but no canonical built-in Title/Heading1 definition, addDefaultStylesIfMissing now skips adding the fallback that previous imports provided; canonical w:pStyle references remain keyed by those canonical IDs and will not resolve to the custom style. Please exclude w:customStyle styles from alias matching, or otherwise require evidence that the style is actually a built-in localized equivalent.

Useful? React with πŸ‘Β / πŸ‘Ž.

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) πŸ“˜ Rule violations (0) πŸ“Ž Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@caio-pizzol caio-pizzol self-assigned this Jul 7, 2026
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.

2 participants