Skip to content

Commit e2d3fcf

Browse files
committed
🐛(export) fix export unsupported colors
Some colors bind to a text style are not supported. If it is the case, we fallback to the default color.
1 parent 0bfe580 commit e2d3fcf

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
);

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,26 @@ 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+
return {
48+
shading: {
49+
fill:
50+
exporter.options.colors?.[val]?.background?.slice(1) || '#ffffff',
51+
},
52+
};
53+
},
54+
// If the color is not defined, we fall back to default colors
55+
textColor: (val, exporter) => {
56+
if (!val) {
57+
return {};
58+
}
59+
return {
60+
color: exporter.options.colors?.[val]?.text?.slice(1) || '#3c3b38',
61+
};
62+
},
4263
},
4364
};

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,25 @@ 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+
return {
49+
color: exporter.options.colors?.[val]?.text || '#3c3b38',
50+
};
51+
},
52+
// If the color is not defined, we fall back to default colors
53+
backgroundColor: (val, exporter) => {
54+
if (!val) {
55+
return {};
56+
}
57+
return {
58+
backgroundColor:
59+
exporter.options.colors?.[val]?.background || '#ffffff',
60+
};
61+
},
4262
},
4363
};

0 commit comments

Comments
 (0)