Skip to content

Commit bd79f84

Browse files
ZouicheOmarAntoLC
authored andcommitted
✨(frontend) adapt export to callout block
Adapt modal export to include PDF and Docx export for the callout block.
1 parent a070f56 commit bd79f84

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Paragraph, TextRun } from 'docx';
2+
3+
import { DocsExporterDocx } from '../types';
4+
import { docxBlockPropsToStyles } from '../utils';
5+
6+
export const blockMappingCalloutDocx: DocsExporterDocx['mappings']['blockMapping']['callout'] =
7+
(block, exporter) => {
8+
return new Paragraph({
9+
...docxBlockPropsToStyles(block.props, exporter.options.colors),
10+
spacing: { before: 10, after: 10 },
11+
children: [
12+
new TextRun({
13+
text: ' ',
14+
break: 1,
15+
}),
16+
new TextRun(' ' + block.props.emoji + ' '),
17+
...exporter.transformInlineContent(block.content),
18+
new TextRun({
19+
text: ' ',
20+
break: 1,
21+
}),
22+
],
23+
});
24+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { StyleSheet, Text, View } from '@react-pdf/renderer';
2+
3+
import { DocsExporterPDF } from '../types';
4+
5+
const styles = StyleSheet.create({
6+
wrapper: {
7+
width: '100%',
8+
display: 'flex',
9+
flexDirection: 'row',
10+
padding: 8,
11+
gap: 4,
12+
},
13+
emoji: {
14+
fontSize: 16,
15+
},
16+
text: {
17+
maxWidth: '94%',
18+
paddingTop: 2,
19+
},
20+
});
21+
22+
export const blockMappingCalloutPDF: DocsExporterPDF['mappings']['blockMapping']['callout'] =
23+
(block, exporter) => {
24+
return (
25+
<View wrap={false} style={styles.wrapper}>
26+
<Text debug={false} style={styles.emoji}>
27+
{block.props.emoji}
28+
</Text>
29+
<Text debug={false} style={styles.text}>
30+
{' '}
31+
{exporter.transformInlineContent(block.content)}{' '}
32+
</Text>
33+
</View>
34+
);
35+
};

src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export * from './calloutDocx';
2+
export * from './calloutPDF';
13
export * from './dividerDocx';
24
export * from './dividerPDF';
35
export * from './headingPDF';

src/frontend/apps/impress/src/features/docs/doc-export/mappingDocx.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { docxDefaultSchemaMappings } from '@blocknote/xl-docx-exporter';
22

33
import {
4+
blockMappingCalloutDocx,
45
blockMappingDividerDocx,
56
blockMappingImageDocx,
67
blockMappingQuoteDocx,
@@ -11,6 +12,7 @@ export const docxDocsSchemaMappings: DocsExporterDocx['mappings'] = {
1112
...docxDefaultSchemaMappings,
1213
blockMapping: {
1314
...docxDefaultSchemaMappings.blockMapping,
15+
callout: blockMappingCalloutDocx,
1416
divider: blockMappingDividerDocx,
1517
quote: blockMappingQuoteDocx,
1618
image: blockMappingImageDocx,

src/frontend/apps/impress/src/features/docs/doc-export/mappingPDF.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { pdfDefaultSchemaMappings } from '@blocknote/xl-pdf-exporter';
22

33
import {
4+
blockMappingCalloutPDF,
45
blockMappingDividerPDF,
56
blockMappingHeadingPDF,
67
blockMappingImagePDF,
@@ -14,6 +15,7 @@ export const pdfDocsSchemaMappings: DocsExporterPDF['mappings'] = {
1415
...pdfDefaultSchemaMappings,
1516
blockMapping: {
1617
...pdfDefaultSchemaMappings.blockMapping,
18+
callout: blockMappingCalloutPDF,
1719
heading: blockMappingHeadingPDF,
1820
image: blockMappingImagePDF,
1921
paragraph: blockMappingParagraphPDF,

0 commit comments

Comments
 (0)