♻️(frontend) improve html for pdf
Blocknote json to html is not perfect, so we need to improve it to provide a better html for the pdf generation. It is the first step to improve the html, we will continue to improve it in the future. We have now the break line. It is e2e tested so if blocknote change the conversion we will know it.
This commit is contained in:
@@ -15,7 +15,7 @@ import { usePadStore } from '@/features/pads/pad-editor/';
|
||||
import { Pad } from '@/features/pads/pad-management';
|
||||
|
||||
import { useCreatePdf } from '../api/useCreatePdf';
|
||||
import { downloadFile } from '../utils';
|
||||
import { adaptBlockNoteHTML, downloadFile } from '../utils';
|
||||
|
||||
interface ModalPDFProps {
|
||||
onClose: () => void;
|
||||
@@ -84,7 +84,8 @@ export const ModalPDF = ({ onClose, templateOptions, pad }: ModalPDFProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const body = await editor.blocksToHTMLLossy(editor.document);
|
||||
let body = await editor.blocksToHTMLLossy(editor.document);
|
||||
body = adaptBlockNoteHTML(body);
|
||||
|
||||
createPdf({
|
||||
templateId: templateIdSelected,
|
||||
|
||||
@@ -9,3 +9,7 @@ export function downloadFile(blob: Blob, filename: string) {
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
export const adaptBlockNoteHTML = (html: string) => {
|
||||
return html.replaceAll('<p class="bn-inline-content"></p>', '<br/>');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user