Comments (3)
You can try the snapshot API: https://blocksuite.io/guide/data-synchronization.html#snapshot-api
from blocksuite.
You can try the snapshot API: https://blocksuite.io/guide/data-synchronization.html#snapshot-api
Thanks for the answer!
One problem here is that I am doing const json = await job.docToSnapshot(doc);
to store json in sql. I will do it again the next time I retrieve it.
const schema = new Schema().register(AffineSchemas); const collection = new DocCollection({ schema }); const job = new Job({ collection }); const doc = await job.snapshotToDoc(docSnapshot); doc.load();
Such an operation is not allowed because doc.meta.tags is not in the new collection instance. In this case, should I store it twice? That is
const collectionSnapshot = await job.collectionInfoToSnapshot();
Do it first the next time you use it
const schema = new Schema().register(AffineSchemas); const collection = new DocCollection({ schema }); const job = new Job({ collection }); job.snapshotToCollectionInfo(_collectionSnapshot); const doc = await job.snapshotToDoc(docSnapshot); doc.load();
from blocksuite.
Please re-open this issue, as I found it not to be straightforward to do JSON export-import with the Snapshot API.
In my case i applied the code like in the mentioned Snapshot API docs:
import { Job } from '@blocksuite/store';
const doc = createEmptyDoc().init();
const editor = new PageEditor();
editor.doc = doc;
const { collection } = doc;
const job = new Job({ collection });
const json = await job.docToSnapshot(doc);
const newDoc = await job.snapshotToDoc(json);
and it would throw me this:
text.js:19 Uncaught (in promise) TypeError: Cannot assign to read only property 'insert' of object '#<Object>' at new Text (text.js:19:34) at fromJSON (json.js:46:20) at eval (base.js:15:76) at Array.map (<anonymous>) at BaseBlockTransformer._propsFromSnapshot (base.js:14:61) at BaseBlockTransformer.fromSnapshot (base.js:26:28) at Job._snapshotToBlock (job.js:301:45) at Job._snapshotToBlock (job.js:308:24) at async Job._snapshotToBlock (job.js:308:13) at async Job.snapshotToBlock (job.js:60:27) at async Job.snapshotToDoc (job.js:95:13)
This error is caused by the job.snapshotToDoc(json)
- method. If i feed this method with a "emptyDefaultSnapshot"-object it did not throw this error.
So how is the proper way to get exported JSON back in?
from blocksuite.
Related Issues (20)
- Unable to select element after undo op HOT 1
- Usability Enhancement: Extend toggle points HOT 1
- Dragging shape in edgeless toolbar will be clipped
- Bump examples to latest version
- Unusable format bar in Safari
- In the Lit component, the `accessor` field in my local code results in syntax errors during compilation. How can I resolve this? HOT 4
- How to customize function buttons when using the editor HOT 5
- [code block] Is there any way to provide a custom shiki theme? HOT 1
- [bug] [edgeless] Changing text in shapes does not render in other tab by sync
- TypeError: Cannot read properties of undefined (reading 'toDelta')
- TypeError: this._getSelector is not a function
- BlockSuiteError: val does not exist
- [Bug Report] Unexpected behavior of moving cursor by "⬆️" arrow key between table and codeblock HOT 1
- [BUG] Cannot edit text block in frame HOT 1
- [BUG] Completely empty Edgeless mode HOT 1
- [Image block] throw "Error:Image blob is missing!" after Y.encodeStateAsUpdate(doc.spaceDoc)
- TypeError: Cannot read properties of undefined (reading 'spec')
- BlockSuiteError: val does not exist
- SyntaxError: "undefined" is not valid JSON
- TypeError: Cannot read properties of undefined (reading 'id')
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blocksuite.