fix: dock to blocksuite latest API (#2219)

This commit is contained in:
Himself65
2023-05-03 18:57:59 -05:00
committed by GitHub
parent 9096ac2960
commit 86988bd6e8
15 changed files with 146 additions and 137 deletions

View File

@@ -19,11 +19,11 @@
"@affine/jotai": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/workspace": "workspace:*",
"@blocksuite/blocks": "0.0.0-20230501021333-90d9a4af-nightly",
"@blocksuite/editor": "0.0.0-20230501021333-90d9a4af-nightly",
"@blocksuite/global": "0.0.0-20230501021333-90d9a4af-nightly",
"@blocksuite/blocks": "0.0.0-20230502232311-bfe52748-nightly",
"@blocksuite/editor": "0.0.0-20230502232311-bfe52748-nightly",
"@blocksuite/global": "0.0.0-20230502232311-bfe52748-nightly",
"@blocksuite/icons": "^2.1.15",
"@blocksuite/store": "0.0.0-20230501021333-90d9a4af-nightly",
"@blocksuite/store": "0.0.0-20230502232311-bfe52748-nightly",
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@emotion/cache": "^11.10.8",
@@ -66,14 +66,14 @@
"dotenv": "^16.0.3",
"eslint": "^8.39.0",
"eslint-config-next": "^13.3.5-canary.3",
"next": "^13.3.5-canary.3",
"next": "^13.3.5-canary.7",
"next-debug-local": "^0.1.5",
"next-router-mock": "^0.9.3",
"raw-loader": "^4.0.2",
"redux": "^4.2.1",
"swc-plugin-coverage-instrument": "^0.0.18",
"typescript": "^5.0.4",
"webpack": "^5.81.0"
"webpack": "^5.82.0"
},
"stableVersion": "0.0.0"
}

View File

@@ -31,7 +31,7 @@ describe('currentWorkspace atom', () => {
'test',
WorkspaceFlavour.LOCAL
);
const page = workspace.createPage('page0');
const page = workspace.createPage({ id: 'page0' });
initPage(page);
const frameId = page.getBlockByFlavour('affine:frame').at(0)
?.id as string;

View File

@@ -16,7 +16,7 @@ const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
}
);
const page = blockSuiteWorkspace.createPage('page0');
const page = blockSuiteWorkspace.createPage({ id: 'page0' });
const Editor: React.FC<{
onInit: (page: Page, editor: Readonly<EditorContainer>) => void;

View File

@@ -92,9 +92,13 @@ beforeEach(async () => {
const frameId = page.addBlock('affine:frame', {}, pageBlockId);
page.addBlock('affine:paragraph', {}, frameId);
};
initPage(blockSuiteWorkspace.createPage('page0'));
initPage(blockSuiteWorkspace.createPage('page1'));
initPage(blockSuiteWorkspace.createPage('page2'));
initPage(
blockSuiteWorkspace.createPage({
id: 'page0',
})
);
initPage(blockSuiteWorkspace.createPage({ id: 'page1' }));
initPage(blockSuiteWorkspace.createPage({ id: 'page2' }));
});
describe('usePageMetas', async () => {

View File

@@ -32,7 +32,7 @@ export function useAppHelper() {
ws => ws.id === workspaceId
) as LocalWorkspace;
if (workspace && 'blockSuiteWorkspace' in workspace) {
workspace.blockSuiteWorkspace.createPage(pageId);
workspace.blockSuiteWorkspace.createPage({ id: pageId });
} else {
throw new Error('cannot create page. blockSuiteWorkspace not found');
}

View File

@@ -267,7 +267,9 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
if (currentWorkspace.blockSuiteWorkspace.isEmpty) {
// this is a new workspace, so we should redirect to the new page
const pageId = nanoid();
const page = currentWorkspace.blockSuiteWorkspace.createPage(pageId);
const page = currentWorkspace.blockSuiteWorkspace.createPage({
id: pageId,
});
assertEquals(page.id, pageId);
currentWorkspace.blockSuiteWorkspace.setPageMeta(page.id, {
init: true,

View File

@@ -52,7 +52,7 @@ const BroadcastPage: React.FC = () => {
data-testid="create-page"
onClick={() => {
logger.info('create page');
blockSuiteWorkspace.createPage(nanoid());
blockSuiteWorkspace.createPage({ id: nanoid() });
}}
>
Create Page

View File

@@ -32,7 +32,9 @@ export const LocalPlugin: WorkspacePlugin<WorkspaceFlavour.LOCAL> = {
WorkspaceFlavour.LOCAL
);
blockSuiteWorkspace.meta.setName(DEFAULT_WORKSPACE_NAME);
const page = blockSuiteWorkspace.createPage(DEFAULT_HELLO_WORLD_PAGE_ID);
const page = blockSuiteWorkspace.createPage({
id: DEFAULT_HELLO_WORLD_PAGE_ID,
});
blockSuiteWorkspace.setPageMeta(page.id, {
init: true,
});