🎨(frontend) better conversion editor to pdf
A recent update from Blocknote provides us the alignment, the color and the background color of the different editor texts. We adapt our converter to adapt these new features to the pdf.
This commit is contained in:
@@ -104,7 +104,7 @@ export const ModalPDF = ({ onClose, doc }: ModalPDFProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
let body = await editor.blocksToHTMLLossy(editor.document);
|
||||
let body = await editor.blocksToFullHTML(editor.document);
|
||||
body = adaptBlockNoteHTML(body);
|
||||
|
||||
createPdf({
|
||||
|
||||
@@ -11,5 +11,15 @@ export function downloadFile(blob: Blob, filename: string) {
|
||||
}
|
||||
|
||||
export const adaptBlockNoteHTML = (html: string) => {
|
||||
return html.replaceAll('<p class="bn-inline-content"></p>', '<br/>');
|
||||
html = html.replaceAll('<p class="bn-inline-content"></p>', '<br/>');
|
||||
html = html.replaceAll(
|
||||
/data-text-alignment=\"([a-z]+)\"/g,
|
||||
'style="text-align: $1;"',
|
||||
);
|
||||
html = html.replaceAll(/data-text-color=\"([a-z]+)\"/g, 'style="color: $1;"');
|
||||
html = html.replaceAll(
|
||||
/data-background-color=\"([a-z]+)\"/g,
|
||||
'style="background-color: $1;"',
|
||||
);
|
||||
return html;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user