Skip to content

Commit 9cb6bc1

Browse files
committed
🐛(export) fix heading 4 5 6 in PDF
Heading 4 5 6 in PDF were not correctly mapped to their corresponding styles in the exported document. The new export is now different than the regression pdf, we need to update the regression PDF to match the new correct export.
1 parent 59bf101 commit 9cb6bc1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Binary file not shown.

src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/headingPDF.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Derivated from Blockquote PDF mapping
3+
* @see: https://github.com/TypeCellOS/BlockNote/blob/main/packages/xl-pdf-exporter/src/pdf/defaultSchema/blocks.tsx
4+
*/
15
import { Text } from '@react-pdf/renderer';
26

37
import { DocsExporterPDF } from '../types';
@@ -30,6 +34,15 @@ export const blockMappingHeadingPDF: DocsExporterPDF['mappings']['blockMapping']
3034
const fontSizeEM =
3135
block.props.level === 1 ? 2 : block.props.level === 2 ? 1.5 : 1.17;
3236

37+
const levelFontSizeEM = {
38+
1: 2,
39+
2: 1.5,
40+
3: 1.17,
41+
4: 1,
42+
5: 0.83,
43+
6: 0.67,
44+
}[block.props.level as 1 | 2 | 3 | 4 | 5 | 6];
45+
3346
// Extract plain text for bookmark title
3447
const bookmarkTitle =
3548
extractTextFromBlockContent(block.content) || 'Untitled';
@@ -42,7 +55,7 @@ export const blockMappingHeadingPDF: DocsExporterPDF['mappings']['blockMapping']
4255
title: bookmarkTitle,
4356
}}
4457
style={{
45-
fontSize: fontSizeEM * FONT_SIZE * PIXELS_PER_POINT,
58+
fontSize: levelFontSizeEM * FONT_SIZE * PIXELS_PER_POINT,
4659
fontWeight: 700,
4760
marginTop: `${fontSizeEM * MERGE_RATIO}px`,
4861
marginBottom: `${fontSizeEM * MERGE_RATIO}px`,

0 commit comments

Comments
 (0)