Skip to content

Commit 739a18f

Browse files
committed
fix(super-editor): fallback to 10pt default when styles omit fontSize
1 parent f39f127 commit 739a18f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

packages/super-editor/src/editors/v1/document-api-adapters/plan-engine/blocks-wrappers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,17 @@ function extractTextPreview(node: ProseMirrorNode): string | null {
6767

6868
const HEADING_PATTERN = /^Heading(\d)$/;
6969

70+
/** OOXML implicit default font size when neither Normal style nor docDefaults specifies one. */
71+
const OOXML_DEFAULT_FONT_SIZE_PT = 10;
72+
7073
/**
7174
* Resolve the document's default font size (in points) from the style catalog.
72-
* Falls back through: Normal style rPr → docDefaults rPr → undefined.
75+
* Falls back through: Normal style rPr → docDefaults rPr → OOXML implicit default (10pt).
7376
* OOXML stores fontSize as half-points (w:sz val), so we divide by 2.
7477
*/
75-
function resolveDefaultFontSizePt(editor: Editor): number | undefined {
78+
function resolveDefaultFontSizePt(editor: Editor): number {
7679
const styleProps = readTranslatedLinkedStyles(editor);
77-
if (!styleProps) return undefined;
80+
if (!styleProps) return OOXML_DEFAULT_FONT_SIZE_PT;
7881

7982
// Try Normal style first
8083
const normalStyle = styleProps.styles?.['Normal'];
@@ -85,7 +88,7 @@ function resolveDefaultFontSizePt(editor: Editor): number | undefined {
8588
const defaultFontSize = styleProps.docDefaults?.runProperties?.fontSize;
8689
if (typeof defaultFontSize === 'number') return defaultFontSize / 2;
8790

88-
return undefined;
91+
return OOXML_DEFAULT_FONT_SIZE_PT;
8992
}
9093

9194
/**

0 commit comments

Comments
 (0)