✨(frontend) adapt export to divider block
We have a new block type, the divider block. We have to adapt the export to handle this new block type.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { Paragraph } from 'docx';
|
||||
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
|
||||
import { DocsExporterDocx } from '../types';
|
||||
|
||||
export const blockMappingDividerDocx: DocsExporterDocx['mappings']['blockMapping']['divider'] =
|
||||
() => {
|
||||
const { colorsTokens } = useCunninghamTheme.getState();
|
||||
|
||||
return new Paragraph({
|
||||
spacing: {
|
||||
before: 200,
|
||||
},
|
||||
border: {
|
||||
top: {
|
||||
color: colorsTokens()['greyscale-300'],
|
||||
size: 1,
|
||||
style: 'single',
|
||||
space: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Text } from '@react-pdf/renderer';
|
||||
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
|
||||
import { DocsExporterPDF } from '../types';
|
||||
|
||||
export const blockMappingDividerPDF: DocsExporterPDF['mappings']['blockMapping']['divider'] =
|
||||
() => {
|
||||
const { colorsTokens } = useCunninghamTheme.getState();
|
||||
|
||||
return (
|
||||
<Text
|
||||
style={{
|
||||
marginVertical: 10,
|
||||
backgroundColor: colorsTokens()['greyscale-300'],
|
||||
height: '2px',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
export * from './dividerDocx';
|
||||
export * from './dividerPDF';
|
||||
export * from './headingPDF';
|
||||
export * from './paragraphPDF';
|
||||
export * from './quoteDocx';
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import { docxDefaultSchemaMappings } from '@blocknote/xl-docx-exporter';
|
||||
|
||||
import { blockMappingQuoteDocx } from './blocks-mapping/';
|
||||
import {
|
||||
blockMappingDividerDocx,
|
||||
blockMappingQuoteDocx,
|
||||
} from './blocks-mapping/';
|
||||
import { DocsExporterDocx } from './types';
|
||||
|
||||
export const docxDocsSchemaMappings: DocsExporterDocx['mappings'] = {
|
||||
...docxDefaultSchemaMappings,
|
||||
blockMapping: {
|
||||
...docxDefaultSchemaMappings.blockMapping,
|
||||
divider: blockMappingDividerDocx,
|
||||
quote: blockMappingQuoteDocx,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { pdfDefaultSchemaMappings } from '@blocknote/xl-pdf-exporter';
|
||||
|
||||
import {
|
||||
blockMappingDividerPDF,
|
||||
blockMappingHeadingPDF,
|
||||
blockMappingParagraphPDF,
|
||||
blockMappingQuotePDF,
|
||||
@@ -14,6 +15,7 @@ export const pdfDocsSchemaMappings: DocsExporterPDF['mappings'] = {
|
||||
...pdfDefaultSchemaMappings.blockMapping,
|
||||
heading: blockMappingHeadingPDF,
|
||||
paragraph: blockMappingParagraphPDF,
|
||||
divider: blockMappingDividerPDF,
|
||||
quote: blockMappingQuotePDF,
|
||||
table: blockMappingTablePDF,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user