Skip to content

Preserve localized DOCX styles during import and editing #3823

Description

@caio-pizzol

What happened?

Some Word documents use document-specific identifiers for built-in styles. These identifiers can vary by language and document producer.

For example, a document's Heading 1 style might not use the identifier Heading1. It may use an identifier such as Ttulo1, Kop1, or 1.

When SuperDoc v1 imports these documents, it can add fallback styles even though the document already contains equivalent authored styles. This can cause:

  • Customized headings or titles to use fallback formatting.
  • Newly created headings to use a different style from existing headings.
  • Authored and fallback versions of the same style to appear separately.
  • Default paragraph formatting to be ignored when its identifier is not Normal.
  • Formatting to change after export and reopen.

Expected behavior:

  • Existing content uses the exact style definitions referenced by the document.
  • Built-in editing actions reuse the document's authored styles when available.
  • Fallback styles are used only when the document does not provide an appropriate style.
  • Style changes apply consistently across paragraphs, runs, tables, and other document content.
  • Export and reopen preserve the same style references and formatting.

This behavior is not specific to Portuguese. It has also been reproduced with Arabic and Chinese Word documents.

Steps to reproduce

  1. Create a DOCX file in Word with customized Title and Heading styles.
  2. Use a document where the built-in styles have document-specific identifiers instead of identifiers such as Heading1 and Normal.
  3. Import the document into SuperDoc v1.
  4. Compare the imported heading and title formatting with Microsoft Word.
  5. Insert a new Heading 1 paragraph.
  6. Compare the new heading with an existing Heading 1 paragraph.
  7. Export the document and reopen it.
  8. Observe that authored formatting can be replaced or separated from fallback styles added by SuperDoc.

SuperDoc version

Current v1 editor. The behavior is not believed to be limited to one v1 release.

Browser

Not browser-specific.

Additional context

PR #3807 identified a real interaction between imported styles and SuperDoc's fallback styles.

The proposed fix uses a list of localized aliases. That approach cannot cover every language because DOCX style identifiers are document-specific and can be arbitrary. Removing fallback styles based on aliases can also prevent newly created headings from finding a valid style.

This is planned for the v2 editor's style system rather than being addressed through a language-specific change in v1.

The original report includes a private document and private business context, so those materials are intentionally not attached. Minimized fixtures with generic text have been prepared for Portuguese, Arabic, Chinese, and linked-style catalog behavior.

Thanks to @replicant026 for identifying the problem and opening #3807.

localized-styles-arabic.docx
localized-styles-chinese.docx
localized-styles-portuguese.docx
styles-panel-linked-styles.docx

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions