-
Notifications
You must be signed in to change notification settings - Fork 118
fix(style-engine): resolve built-in Word heading styles when missing from styles.xml #2806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gpardhivvarma
wants to merge
2
commits into
superdoc-dev:main
Choose a base branch
from
gpardhivvarma:fix/builtin-heading-styles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
255 changes: 255 additions & 0 deletions
255
packages/layout-engine/style-engine/src/ooxml/builtin-styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,255 @@ | ||
| import type { StyleDefinition } from './styles-types.js'; | ||
|
|
||
| /** | ||
| * Built-in Word heading style defaults. | ||
| * | ||
| * Word defines ~260 built-in styles that implicitly exist even when not declared | ||
| * in a document's styles.xml. When a paragraph references a built-in style | ||
| * (e.g., `<w:pStyle w:val="Heading1"/>`) that has no explicit definition, | ||
| * these defaults provide the expected visual properties. | ||
| * | ||
| * Values match Word's defaults per ECMA-376 §17.7.4.9. Font sizes are in | ||
| * half-points (OOXML convention), spacing in twips (twentieths of a point). | ||
| * | ||
| * Heading7–9 use a muted text color (595959) instead of the accent color | ||
| * used by Heading1–6, matching Word's visual hierarchy. | ||
| * | ||
| * All headings inherit from 'Normal' via basedOn, so any document-level Normal | ||
| * style properties (font family, line spacing, etc.) cascade correctly. | ||
| */ | ||
| export const BUILTIN_STYLE_DEFAULTS: Record<string, StyleDefinition> = { | ||
| Heading1: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading1', | ||
| name: 'heading 1', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 360, after: 80 }, | ||
| outlineLvl: 0, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| asciiTheme: 'majorHAnsi', | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| hAnsiTheme: 'majorHAnsi', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| color: { val: '0F4761', themeColor: 'accent1', themeShade: 'BF' }, | ||
| fontSize: 40, | ||
| fontSizeCs: 40, | ||
| }, | ||
| }, | ||
|
|
||
| Heading2: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading2', | ||
| name: 'heading 2', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 160, after: 80 }, | ||
| outlineLvl: 1, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| asciiTheme: 'majorHAnsi', | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| hAnsiTheme: 'majorHAnsi', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| color: { val: '0F4761', themeColor: 'accent1', themeShade: 'BF' }, | ||
| fontSize: 32, | ||
| fontSizeCs: 32, | ||
| }, | ||
| }, | ||
|
|
||
| Heading3: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading3', | ||
| name: 'heading 3', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 160, after: 80 }, | ||
| outlineLvl: 2, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| color: { val: '0F4761', themeColor: 'accent1', themeShade: 'BF' }, | ||
| fontSize: 28, | ||
| fontSizeCs: 28, | ||
| }, | ||
| }, | ||
|
|
||
| Heading4: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading4', | ||
| name: 'heading 4', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 80, after: 40 }, | ||
| outlineLvl: 3, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| italic: true, | ||
| iCs: true, | ||
| color: { val: '0F4761', themeColor: 'accent1', themeShade: 'BF' }, | ||
| fontSize: 24, | ||
| fontSizeCs: 24, | ||
| }, | ||
| }, | ||
|
|
||
| Heading5: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading5', | ||
| name: 'heading 5', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 80, after: 40 }, | ||
| outlineLvl: 4, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| color: { val: '0F4761', themeColor: 'accent1', themeShade: 'BF' }, | ||
| fontSize: 22, | ||
| fontSizeCs: 22, | ||
| }, | ||
| }, | ||
|
|
||
| Heading6: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading6', | ||
| name: 'heading 6', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 80, after: 40 }, | ||
| outlineLvl: 5, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| italic: true, | ||
| iCs: true, | ||
| color: { val: '0F4761', themeColor: 'accent1', themeShade: 'BF' }, | ||
| fontSize: 22, | ||
| fontSizeCs: 22, | ||
| }, | ||
| }, | ||
|
|
||
| Heading7: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading7', | ||
| name: 'heading 7', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 80, after: 40 }, | ||
| outlineLvl: 6, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| color: { val: '595959', themeColor: 'text1', themeTint: 'A6' }, | ||
| fontSize: 22, | ||
| fontSizeCs: 22, | ||
| }, | ||
| }, | ||
|
|
||
| Heading8: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading8', | ||
| name: 'heading 8', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 80, after: 40 }, | ||
| outlineLvl: 7, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| italic: true, | ||
| iCs: true, | ||
| color: { val: '595959', themeColor: 'text1', themeTint: 'A6' }, | ||
| fontSize: 22, | ||
| fontSizeCs: 22, | ||
| }, | ||
| }, | ||
|
|
||
| Heading9: { | ||
| type: 'paragraph', | ||
| styleId: 'Heading9', | ||
| name: 'heading 9', | ||
| basedOn: 'Normal', | ||
| next: 'Normal', | ||
| qFormat: true, | ||
| uiPriority: 9, | ||
| paragraphProperties: { | ||
| keepNext: true, | ||
| keepLines: true, | ||
| spacing: { before: 80, after: 40 }, | ||
| outlineLvl: 8, | ||
| }, | ||
| runProperties: { | ||
| fontFamily: { | ||
| eastAsiaTheme: 'majorEastAsia', | ||
| cstheme: 'majorBidi', | ||
| }, | ||
| color: { val: '595959', themeColor: 'text1', themeTint: 'A6' }, | ||
| fontSize: 21, | ||
| fontSizeCs: 21, | ||
| }, | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.