blocksuite
blocksuite copied to clipboard
Remove a page from workspace crashes the application
Reproduce method:
const schema = new Schema().register(AffineSchemas);
const workspace = new Workspace({ schema });
const page = workspace.createPage();
page.load(() => {
page.addBlock('affine:page', {});
});
const container = new AffineEditorContainer();
const job = new Job({ workspace });
container.page = page;
...
...
// Try remove the page
console.log('Remove page');
workspace.removePage(page.id);
It crashed with the following screenshot:
Here is the code sandbox for it: https://codesandbox.io/p/sandbox/festive-visvesvaraya-v834v7?file=%2Findex.html
I think if the page is attached to an editor, it's inappropriate to remove it. The workspace API is actually not required for using BlockSuite, I'll rewrite the corresponding doc (and more basic tutorials, so as to expose our newly polished API surface) next week.
Hihi thanks for your reply. @doodlewind Looking forward to the basic tutorials!
Meanwhile if I want to serialize the content to JSON, I need to use Job and it has a complusory parameter of workspace? No? That is why I created this workspace object.....
Actually what I want to do is basic editor setup:
- Save and Load from Disk
- Add and delete page
- Detect Modified State if file is modified