blocksuite icon indicating copy to clipboard operation
blocksuite copied to clipboard

Remove a page from workspace crashes the application

Open davidliudev opened this issue 1 year ago • 3 comments

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:

image

Here is the code sandbox for it: https://codesandbox.io/p/sandbox/festive-visvesvaraya-v834v7?file=%2Findex.html

davidliudev avatar Dec 21 '23 12:12 davidliudev

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.

doodlewind avatar Dec 21 '23 23:12 doodlewind

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.....

davidliudev avatar Dec 22 '23 02:12 davidliudev

Actually what I want to do is basic editor setup:

  1. Save and Load from Disk
  2. Add and delete page
  3. Detect Modified State if file is modified

davidliudev avatar Dec 22 '23 02:12 davidliudev