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

@@ -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,
});