File tree Expand file tree Collapse file tree 5 files changed +65
-0
lines changed
src/frontend/apps/impress/src/features/docs/doc-export Expand file tree Collapse file tree 5 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change
1
+ export * from './calloutDocx' ;
2
+ export * from './calloutPDF' ;
1
3
export * from './dividerDocx' ;
2
4
export * from './dividerPDF' ;
3
5
export * from './headingPDF' ;
Original file line number Diff line number Diff line change 1
1
import { docxDefaultSchemaMappings } from '@blocknote/xl-docx-exporter' ;
2
2
3
3
import {
4
+ blockMappingCalloutDocx ,
4
5
blockMappingDividerDocx ,
5
6
blockMappingImageDocx ,
6
7
blockMappingQuoteDocx ,
@@ -11,6 +12,7 @@ export const docxDocsSchemaMappings: DocsExporterDocx['mappings'] = {
11
12
...docxDefaultSchemaMappings ,
12
13
blockMapping : {
13
14
...docxDefaultSchemaMappings . blockMapping ,
15
+ callout : blockMappingCalloutDocx ,
14
16
divider : blockMappingDividerDocx ,
15
17
quote : blockMappingQuoteDocx ,
16
18
image : blockMappingImageDocx ,
Original file line number Diff line number Diff line change 1
1
import { pdfDefaultSchemaMappings } from '@blocknote/xl-pdf-exporter' ;
2
2
3
3
import {
4
+ blockMappingCalloutPDF ,
4
5
blockMappingDividerPDF ,
5
6
blockMappingHeadingPDF ,
6
7
blockMappingImagePDF ,
@@ -14,6 +15,7 @@ export const pdfDocsSchemaMappings: DocsExporterPDF['mappings'] = {
14
15
...pdfDefaultSchemaMappings ,
15
16
blockMapping : {
16
17
...pdfDefaultSchemaMappings . blockMapping ,
18
+ callout : blockMappingCalloutPDF ,
17
19
heading : blockMappingHeadingPDF ,
18
20
image : blockMappingImagePDF ,
19
21
paragraph : blockMappingParagraphPDF ,
You can’t perform that action at this time.
0 commit comments