File tree Expand file tree Collapse file tree 5 files changed +97
-4
lines changed
src/frontend/apps/impress/src/features/docs/doc-export Expand file tree Collapse file tree 5 files changed +97
-4
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,9 @@ export const blockMappingParagraphPDF: DocsExporterPDF['mappings']['blockMapping
2323 } ) ;
2424 }
2525 }
26+
2627 return (
27- < Text key = { block . id } >
28+ < Text key = { 'paragraph' + block . id } >
2829 { exporter . transformInlineContent ( block . content ) }
2930 </ Text >
3031 ) ;
Original file line number Diff line number Diff line change 22 * We use mainly the Blocknotes code, mixed with @ag-media/react-pdf-table
33 * to have a better Table support.
44 * See:
5- * https://github.com/TypeCellOS/BlockNote/blob/004c0bf720fe1415c497ad56449015c5f4dd7ba0 /packages/xl-pdf-exporter/src/pdf/util/table/Table.tsx
5+ * https://github.com/TypeCellOS/BlockNote/blob/main /packages/xl-pdf-exporter/src/pdf/util/table/Table.tsx
66 *
77 * We succeeded to manage the colspan, but rowspan is not supported yet.
88 */
@@ -92,11 +92,12 @@ export const blockMappingTablePDF: DocsExporterPDF['mappings']['blockMapping']['
9292 color :
9393 cellProps . textColor === 'default'
9494 ? undefined
95- : options . colors [ cellProps . textColor ] . text ,
95+ : options . colors ?. [ cellProps . textColor ] ? .text ,
9696 backgroundColor :
9797 cellProps . backgroundColor === 'default'
9898 ? undefined
99- : options . colors [ cellProps . backgroundColor ] . background ,
99+ : options . colors ?. [ cellProps . backgroundColor ]
100+ ?. background ,
100101 textAlign : cellProps . textAlignment ,
101102 } ,
102103 ] ;
Original file line number Diff line number Diff line change @@ -39,5 +39,39 @@ export const docxDocsSchemaMappings: DocsExporterDocx['mappings'] = {
3939 shading : { fill : 'DCDCDC' } ,
4040 }
4141 : { } ,
42+ // If the color is not defined, we fall back to default colors
43+ backgroundColor : ( val , exporter ) => {
44+ if ( ! val ) {
45+ return { } ;
46+ }
47+
48+ const backgroundColor = exporter . options . colors ?. [ val ] ?. background ;
49+
50+ if ( ! backgroundColor ) {
51+ return { } ;
52+ }
53+
54+ return {
55+ shading : {
56+ fill : backgroundColor . slice ( 1 ) ,
57+ } ,
58+ } ;
59+ } ,
60+ // If the color is not defined, we fall back to default colors
61+ textColor : ( val , exporter ) => {
62+ if ( ! val ) {
63+ return { } ;
64+ }
65+
66+ const color = exporter . options . colors ?. [ val ] ?. text ;
67+
68+ if ( ! color ) {
69+ return { } ;
70+ }
71+
72+ return {
73+ color : color . slice ( 1 ) ,
74+ } ;
75+ } ,
4276 } ,
4377} ;
Original file line number Diff line number Diff line change @@ -32,5 +32,30 @@ export const odtDocsSchemaMappings: DocsExporterODT['mappings'] = {
3232 } ,
3333 styleMapping : {
3434 ...odtDefaultSchemaMappings . styleMapping ,
35+ textColor : ( val , exporter ) : Record < string , string > => {
36+ if ( ! val ) {
37+ return { } ;
38+ }
39+ const color = exporter . options . colors ?. [ val ] ?. text ;
40+
41+ if ( ! color ) {
42+ return { } ;
43+ }
44+
45+ return { 'fo:color' : color } ;
46+ } ,
47+
48+ backgroundColor : ( val , exporter ) : Record < string , string > => {
49+ if ( ! val ) {
50+ return { } ;
51+ }
52+ const color = exporter . options . colors ?. [ val ] ?. background ;
53+
54+ if ( ! color ) {
55+ return { } ;
56+ }
57+
58+ return { 'fo:background-color' : color } ;
59+ } ,
3560 } ,
3661} ;
Original file line number Diff line number Diff line change @@ -39,5 +39,37 @@ export const pdfDocsSchemaMappings: DocsExporterPDF['mappings'] = {
3939 // that is not available in italics
4040 code : ( enabled ?: boolean ) =>
4141 enabled ? { fontFamily : 'Courier' , backgroundColor : '#dcdcdc' } : { } ,
42+ // If the color is not defined, we fall back to default colors
43+ textColor : ( val , exporter ) => {
44+ if ( ! val ) {
45+ return { } ;
46+ }
47+
48+ const color = exporter . options . colors ?. [ val ] ?. text ;
49+
50+ if ( ! color ) {
51+ return { } ;
52+ }
53+
54+ return {
55+ color,
56+ } ;
57+ } ,
58+ // If the color is not defined, we fall back to default colors
59+ backgroundColor : ( val , exporter ) => {
60+ if ( ! val ) {
61+ return { } ;
62+ }
63+
64+ const backgroundColor = exporter . options . colors ?. [ val ] ?. background ;
65+
66+ if ( ! backgroundColor ) {
67+ return { } ;
68+ }
69+
70+ return {
71+ backgroundColor,
72+ } ;
73+ } ,
4274 } ,
4375} ;
You can’t perform that action at this time.
0 commit comments