File tree Expand file tree Collapse file tree 2 files changed +318
-286
lines changed
examples/05-interoperability/05-converting-blocks-to-pdf/src Expand file tree Collapse file tree 2 files changed +318
-286
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,14 @@ import {
2525 withMultiColumn ,
2626} from "@blocknote/xl-multi-column" ;
2727import { PDFViewer } from "@react-pdf/renderer" ;
28- import { useEffect , useMemo , useState } from "react" ;
28+ import { useEffect , useMemo , useReducer , useState } from "react" ;
2929
3030import "./styles.css" ;
3131
3232export default function App ( ) {
3333 // Stores the editor's contents as HTML.
3434 const [ pdfDocument , setPDFDocument ] = useState < any > ( ) ;
35+ const [ renders , forceRerender ] = useReducer ( ( s ) => s + 1 , 0 ) ;
3536
3637 // Creates a new editor instance with some initial content.
3738 const editor = useCreateBlockNote ( {
@@ -396,6 +397,7 @@ export default function App() {
396397 // Converts the editor's contents from Block objects to HTML and store to state.
397398 const pdfDocument = await exporter . toReactPDFDocument ( editor . document ) ;
398399 setPDFDocument ( pdfDocument ) ;
400+ forceRerender ( ) ;
399401
400402 // const blob = await ReactPDF.pdf(pdfDocument).toBlob();
401403 } ;
@@ -417,7 +419,9 @@ export default function App() {
417419 </ BlockNoteView >
418420 </ div >
419421 < div className = "pdf" >
420- < PDFViewer width = { "100%" } > { pdfDocument } </ PDFViewer >
422+ < PDFViewer width = { "100%" } key = { renders } >
423+ { pdfDocument }
424+ </ PDFViewer >
421425 </ div >
422426 </ div >
423427 ) ;
You can’t perform that action at this time.
0 commit comments