Skip to content

Instantly share code, notes, and snippets.

@pengx17
Last active December 26, 2023 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pengx17/ef92c305ac23123803a1a6a20e31f822 to your computer and use it in GitHub Desktop.
Save pengx17/ef92c305ac23123803a1a6a20e31f822 to your computer and use it in GitHub Desktop.
export current workspace snapshot in affine
(async () => {
// make sure ZipTransformer is imported and attached to window
const { ZipTransformer } = window;
await Promise.all([...currentWorkspace.blockSuiteWorkspace.pages.values()].map(p => p.load()));
// wait for a few more seconds
await new Promise(resolve => setTimeout(resolve, 5000));
const zipblob = await ZipTransformer.exportPages(currentWorkspace.blockSuiteWorkspace, [...currentWorkspace.blockSuiteWorkspace.pages.values()]);
const url = URL.createObjectURL(zipblob);
const a = document.createElement('a');
a.setAttribute('href', url);
a.setAttribute('download', `${currentWorkspace.id}.affine.zip`);
a.click();
a.remove();
URL.revokeObjectURL(url);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment