You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constsaveJson=async()=>{constdoc=editor.doc;const{ collection }=doc;constjob=newJob({ collection });// Export current doc content to snapshot JSONconstjsonData=awaitjob.docToSnapshot(doc);localStorage.setItem(`pageInfo-${docId}`,JSON.stringify(jsonData));dispatchEvent(newEvent("storage"));};
Retrieving and Loading Snapshot to Editor:
useEffect(()=>{if(!editor)return;// Function to load document from snapshotconstloadDocument=async(dData: DocSnapshot,edgeLess: boolean)=>{editor.doc.clear();// Clear previous contentif(edgeLess){constdoc=createEmptyDoc().init();const{ collection }=doc;constjob=newJob({ collection });constnewDoc=awaitjob.snapshotToDoc(dData);editor.doc=newDoc;}else{constschema=newSchema().register(AffineSchemas);constcollection=newDocCollection({ schema });collection.meta.initialize();constjob=newJob({ collection });constnewDoc=awaitjob.snapshotToDoc(dData);editor.doc=newDoc;}};// Check localStorage for saved dataconstjsonDoc=localStorage.getItem(`pageInfo-${docId}`);constdData: DocSnapshot|null=jsonDoc ? JSON.parse(jsonDoc) : null;// Load data if existsif(dData!==null){loadDocument(dData,edgeLess);}else{// should be fetched from db//but must save editor data just after it loads on dom}// If there is an imported document, load itif(importedDoc!==null){loadDocument(importedDoc,edgeLess);}// Cleanup: dispose of the editor document on component unmountreturn()=>{localStorage.removeItem(`pageInfo-${docId}`);editor.doc.dispose();// Wait for dispose to complete,};},[collection,editor,edgeLess,docId,importedDoc]);
Error After Reloading:
The image that was previously uploaded is stuck in a loading state.
Here’s the error message and how the editor looks after reloading or retrieving the snapshot from localStorage:
and the editor looks like this:
Additional Context:
I’m new to BlockSuite, and the documentation seems to only cover the method attributes but lacks detailed explanations about implementations etc
Any guidance on how to persist images correctly or fix the blob manager error would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
abdurrahman720
changed the title
[Issue: Image not loading from localStorage after refreshing the page in BlockSuite ] throw error: BlockSuiteError: Blob not found in blob manager
[Issue: Image not loading from localStorage after refreshing the page in BlockSuite ] BlockSuiteError: Blob not found in blob manager
Oct 17, 2024
I’ve integrated BlockSuite into my Next.js TypeScript app, and the page and edgeless editors work fine until I add an image and refresh the page.
Problem:
BlockSuiteError: Blob ugvdz5OwUokGyUtWFLjUCqwaV4fHwOtIDPYht8IH1Hk= not found in blob manager
here's the relevant code:
1. Editor Initialization :
Error After Reloading:
and the editor looks like this:
Additional Context:
Any guidance on how to persist images correctly or fix the blob manager error would be greatly appreciated!
The text was updated successfully, but these errors were encountered: