mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat!: upgrade blocksuite version (#2833)
This commit is contained in:
@@ -33,7 +33,6 @@ describe('crud', () => {
|
||||
id: 'not_exist',
|
||||
flavour: WorkspaceFlavour.LOCAL,
|
||||
blockSuiteWorkspace: new Workspace({ id: 'test' }),
|
||||
providers: [],
|
||||
})
|
||||
).rejects.toThrowError();
|
||||
});
|
||||
@@ -42,12 +41,13 @@ describe('crud', () => {
|
||||
const workspace = new Workspace({ id: 'test' })
|
||||
.register(AffineSchemas)
|
||||
.register(__unstableSchemas);
|
||||
const page = workspace.createPage('test');
|
||||
const page = workspace.createPage({ id: 'page0' });
|
||||
await page.waitForLoaded();
|
||||
const pageBlockId = page.addBlock('affine:page', {
|
||||
title: new page.Text(''),
|
||||
});
|
||||
page.addBlock('affine:surface', {}, pageBlockId);
|
||||
const frameId = page.addBlock('affine:frame', {}, pageBlockId);
|
||||
const frameId = page.addBlock('affine:note', {}, pageBlockId);
|
||||
page.addBlock('affine:paragraph', {}, frameId);
|
||||
|
||||
const id = await CRUD.create(workspace);
|
||||
@@ -57,9 +57,12 @@ describe('crud', () => {
|
||||
const localWorkspace = list.at(0) as LocalWorkspace;
|
||||
expect(localWorkspace.id).toBe(id);
|
||||
expect(localWorkspace.flavour).toBe(WorkspaceFlavour.LOCAL);
|
||||
expect(
|
||||
Workspace.Y.encodeStateAsUpdate(localWorkspace.blockSuiteWorkspace.doc)
|
||||
).toEqual(Workspace.Y.encodeStateAsUpdate(workspace.doc));
|
||||
expect(localWorkspace.blockSuiteWorkspace.doc.toJSON()).toEqual({
|
||||
meta: expect.anything(),
|
||||
spaces: expect.objectContaining({
|
||||
'space:page0': expect.anything(),
|
||||
}),
|
||||
});
|
||||
|
||||
await CRUD.delete(localWorkspace);
|
||||
expect(await CRUD.get(id)).toBeNull();
|
||||
|
||||
@@ -6,7 +6,6 @@ import { createIndexedDBProvider } from '@toeverything/y-indexeddb';
|
||||
import { createJSONStorage } from 'jotai/utils';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { createLocalProviders } from '../providers';
|
||||
import { createEmptyBlockSuiteWorkspace } from '../utils';
|
||||
|
||||
const getStorage = () => createJSONStorage(() => localStorage);
|
||||
@@ -50,7 +49,6 @@ export const CRUD: WorkspaceCRUD<WorkspaceFlavour.LOCAL> = {
|
||||
id,
|
||||
flavour: WorkspaceFlavour.LOCAL,
|
||||
blockSuiteWorkspace: blockSuiteWorkspace,
|
||||
providers: [...createLocalProviders(blockSuiteWorkspace)],
|
||||
};
|
||||
return workspace;
|
||||
},
|
||||
@@ -59,13 +57,13 @@ export const CRUD: WorkspaceCRUD<WorkspaceFlavour.LOCAL> = {
|
||||
const storage = getStorage();
|
||||
!Array.isArray(storage.getItem(kStoreKey, [])) &&
|
||||
storage.setItem(kStoreKey, []);
|
||||
const binary = BlockSuiteWorkspace.Y.encodeStateAsUpdateV2(doc);
|
||||
const binary = BlockSuiteWorkspace.Y.encodeStateAsUpdate(doc);
|
||||
const id = nanoid();
|
||||
const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
|
||||
id,
|
||||
WorkspaceFlavour.LOCAL
|
||||
);
|
||||
BlockSuiteWorkspace.Y.applyUpdateV2(blockSuiteWorkspace.doc, binary);
|
||||
BlockSuiteWorkspace.Y.applyUpdate(blockSuiteWorkspace.doc, binary);
|
||||
const persistence = createIndexedDBProvider(blockSuiteWorkspace.doc);
|
||||
persistence.connect();
|
||||
await persistence.whenSynced.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user