diff --git a/packages/app/package.json b/packages/app/package.json index ab9571a953..9dac686ae9 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@affine/datacenter": "workspace:*", - "@blocksuite/blocks": "0.3.1", - "@blocksuite/editor": "0.3.1", + "@blocksuite/blocks": "=0.3.1-20230106060050-1aad55d", + "@blocksuite/editor": "=0.3.1-20230106060050-1aad55d", "@blocksuite/icons": "^2.0.2", - "@blocksuite/store": "0.3.1", + "@blocksuite/store": "=0.3.1-20230106060050-1aad55d", "@emotion/css": "^11.10.0", "@emotion/react": "^11.10.4", "@emotion/server": "^11.10.0", diff --git a/packages/app/src/components/header/editor-header.tsx b/packages/app/src/components/header/editor-header.tsx index c1b52ec464..7f433de467 100644 --- a/packages/app/src/components/header/editor-header.tsx +++ b/packages/app/src/components/header/editor-header.tsx @@ -22,14 +22,14 @@ export const EditorHeader = () => { useEffect(() => { onPropsUpdated(editor => { - setTitle(editor.model?.title || 'Untitled'); + setTitle(editor.pageBlockModel?.title || 'Untitled'); }); }, [onPropsUpdated]); useEffect(() => { setTimeout(() => { // If first time in, need to wait for editor to be inserted into DOM - setTitle(editor?.model?.title || 'Untitled'); + setTitle(editor?.pageBlockModel?.title || 'Untitled'); }, 300); }, [editor]); diff --git a/packages/app/src/components/import/index.tsx b/packages/app/src/components/import/index.tsx index 7387cb5de6..96a383dad2 100644 --- a/packages/app/src/components/import/index.tsx +++ b/packages/app/src/components/import/index.tsx @@ -31,9 +31,10 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => { setTimeout(() => { const editor = document.querySelector('editor-container'); if (editor) { - const groupId = page.addBlock({ flavour: 'affine:group' }, pageId); + page.addBlock({ flavour: 'affine:surface' }, null); + const frameId = page.addBlock({ flavour: 'affine:frame' }, pageId); // TODO blocksuite should offer a method to import markdown from store - editor.clipboard.importMarkdown(template.source, `${groupId}`); + editor.clipboard.importMarkdown(template.source, `${frameId}`); page.resetHistory(); editor.requestUpdate(); } diff --git a/packages/app/src/hooks/use-props-updated.ts b/packages/app/src/hooks/use-props-updated.ts index d76ada43d2..1bbd8d2cd4 100644 --- a/packages/app/src/hooks/use-props-updated.ts +++ b/packages/app/src/hooks/use-props-updated.ts @@ -17,7 +17,7 @@ export const usePropsUpdated: UsePropsUpdated = () => { return; } setTimeout(() => { - editor.model?.propsUpdated.on(() => { + editor.pageBlockModel?.propsUpdated.on(() => { callbackQueue.current.forEach(callback => { callback(editor); }); @@ -26,7 +26,7 @@ export const usePropsUpdated: UsePropsUpdated = () => { return () => { callbackQueue.current = []; - editor?.model?.propsUpdated.dispose(); + editor?.pageBlockModel?.propsUpdated?.dispose(); }; }, [editor]); diff --git a/packages/app/src/pages/playground/templates.tsx b/packages/app/src/pages/playground/templates.tsx index 0517498878..a83d25e516 100644 --- a/packages/app/src/pages/playground/templates.tsx +++ b/packages/app/src/pages/playground/templates.tsx @@ -43,12 +43,16 @@ const All = () => { if (page) { currentWorkspace?.setPageMeta(page.id, { title }); if (page && page.root === null) { - setTimeout(() => { + setTimeout(async () => { const editor = document.querySelector('editor-container'); if (editor) { - const groupId = page.addBlock({ flavour: 'affine:group' }, pageId); + page.addBlock({ flavour: 'affine:surface' }, null); + const frameId = page.addBlock({ flavour: 'affine:frame' }, pageId); // TODO blocksuite should offer a method to import markdown from store - editor.clipboard.importMarkdown(template.source, `${groupId}`); + await editor.clipboard.importMarkdown( + template.source, + `${frameId}` + ); page.resetHistory(); editor.requestUpdate(); } diff --git a/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsx b/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsx index 619f8e037e..998ec29941 100644 --- a/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsx +++ b/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsx @@ -55,14 +55,15 @@ const Page: NextPageWithLayout = () => { flavour: 'affine:page', title, }); - const groupId = currentPage!.addBlock( - { flavour: 'affine:group' }, + currentPage!.addBlock({ flavour: 'affine:surface' }, null); + const frameId = currentPage!.addBlock( + { flavour: 'affine:frame' }, pageId ); - currentPage!.addBlock({ flavour: 'affine:group' }, pageId); + currentPage!.addBlock({ flavour: 'affine:frame' }, pageId); // If this is a first page in workspace, init an introduction markdown if (isFirstPage) { - editor.clipboard.importMarkdown(exampleMarkdown, `${groupId}`); + editor.clipboard.importMarkdown(exampleMarkdown, `${frameId}`); currentWorkspace!.setPageMeta(currentPage!.id, { title }); } currentPage!.resetHistory(); diff --git a/packages/data-center/package.json b/packages/data-center/package.json index 5d0ebc843f..fe639b306e 100644 --- a/packages/data-center/package.json +++ b/packages/data-center/package.json @@ -26,8 +26,8 @@ "typescript": "^4.8.4" }, "dependencies": { - "@blocksuite/blocks": "^0.3.1", - "@blocksuite/store": "^0.3.1", + "@blocksuite/blocks": "=0.3.1-20230106060050-1aad55d", + "@blocksuite/store": "=0.3.1-20230106060050-1aad55d", "debug": "^4.3.4", "encoding": "^0.1.13", "firebase": "^9.15.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cbf408c5db..26f0cce6b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,10 +45,10 @@ importers: packages/app: specifiers: '@affine/datacenter': workspace:* - '@blocksuite/blocks': 0.3.1 - '@blocksuite/editor': 0.3.1 + '@blocksuite/blocks': '=0.3.1-20230106060050-1aad55d' + '@blocksuite/editor': '=0.3.1-20230106060050-1aad55d' '@blocksuite/icons': ^2.0.2 - '@blocksuite/store': 0.3.1 + '@blocksuite/store': '=0.3.1-20230106060050-1aad55d' '@emotion/css': ^11.10.0 '@emotion/react': ^11.10.4 '@emotion/server': ^11.10.0 @@ -87,10 +87,10 @@ importers: yjs: ^13.5.44 dependencies: '@affine/datacenter': link:../data-center - '@blocksuite/blocks': 0.3.1_yjs@13.5.44 - '@blocksuite/editor': 0.3.1_yjs@13.5.44 + '@blocksuite/blocks': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 + '@blocksuite/editor': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 '@blocksuite/icons': 2.0.4_w5j4k42lgipnm43s3brx6h3c34 - '@blocksuite/store': 0.3.1_yjs@13.5.44 + '@blocksuite/store': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 '@emotion/css': 11.10.0 '@emotion/react': 11.10.4_w5j4k42lgipnm43s3brx6h3c34 '@emotion/server': 11.10.0_@emotion+css@11.10.0 @@ -131,8 +131,8 @@ importers: packages/data-center: specifiers: - '@blocksuite/blocks': ^0.3.1 - '@blocksuite/store': ^0.3.1 + '@blocksuite/blocks': '=0.3.1-20230106060050-1aad55d' + '@blocksuite/store': '=0.3.1-20230106060050-1aad55d' '@playwright/test': ^1.29.1 '@types/debug': ^4.1.7 debug: ^4.3.4 @@ -148,8 +148,8 @@ importers: y-protocols: ^1.0.5 yjs: ^13.5.44 dependencies: - '@blocksuite/blocks': 0.3.1_yjs@13.5.44 - '@blocksuite/store': 0.3.1_yjs@13.5.44 + '@blocksuite/blocks': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 + '@blocksuite/store': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 debug: 4.3.4 encoding: 0.1.13 firebase: 9.15.0_encoding@0.1.13 @@ -1496,10 +1496,11 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true - /@blocksuite/blocks/0.3.1_yjs@13.5.44: - resolution: {integrity: sha512-b0dGz2MG4yIgngJPRumaMY58wAsd2FEVSZl3tpCXlagK9I0HD165Bq70PxcaRHVjBSV1Gf29ZVHUF6BVTYogPw==} + /@blocksuite/blocks/0.3.1-20230106060050-1aad55d_yjs@13.5.44: + resolution: {integrity: sha512-qRNXmhjw+GAGsV1mI2XXPxYTlHfsFHv9ttTCNQ6IIcxvc5Hh6lWmdwVibxvlpYUkgEc1zv3/GxOEsR/ngpZXzQ==} dependencies: - '@blocksuite/store': 0.3.1_yjs@13.5.44 + '@blocksuite/phasor': 0.3.1_yjs@13.5.44 + '@blocksuite/store': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 '@tldraw/intersect': 1.8.0 autosize: 5.0.2 highlight.js: 11.7.0 @@ -1515,11 +1516,11 @@ packages: - yjs dev: false - /@blocksuite/editor/0.3.1_yjs@13.5.44: - resolution: {integrity: sha512-ycKcyvPW6R8R2GZOFneGH1xNi5gJBx5WtWjW9YwcQslFzXVWMCCBips1Bud2uL4kkbWQoodyua6k2vsXxGAKLw==} + /@blocksuite/editor/0.3.1-20230106060050-1aad55d_yjs@13.5.44: + resolution: {integrity: sha512-wSlAF9XVxIkHFJ1qCzn7oQ/gwXybFYMrzRl35UTJV509D+DuWZefRZWvpdIDCOUJ24uQscr1HxwsON11ltfWgA==} dependencies: - '@blocksuite/blocks': 0.3.1_yjs@13.5.44 - '@blocksuite/store': 0.3.1_yjs@13.5.44 + '@blocksuite/blocks': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 + '@blocksuite/store': 0.3.1-20230106060050-1aad55d_yjs@13.5.44 lit: 2.5.0 marked: 4.2.5 turndown: 7.1.1 @@ -1540,8 +1541,16 @@ packages: react: 18.2.0 dev: false - /@blocksuite/store/0.3.1_yjs@13.5.44: - resolution: {integrity: sha512-kynVTDfNCSChz2JI2rtGHxRIV2YrLzvAgVajcbfDVCuXKG0siBoEjLasG1a0kvevbvW/FabrNAj+xaIplklioA==} + /@blocksuite/phasor/0.3.1_yjs@13.5.44: + resolution: {integrity: sha512-aJmAQn2qoF6HxFZWgq7xa/pWVyzg3MmD6dynIHAKdfN7rBdKk3PNA+lRX919QkD2e270N/zgHEGFFQI1Nj5xrA==} + peerDependencies: + yjs: ^13 + dependencies: + yjs: 13.5.44 + dev: false + + /@blocksuite/store/0.3.1-20230106060050-1aad55d_yjs@13.5.44: + resolution: {integrity: sha512-dRy+YzlWMwiYq0Im9NogK/NTkV+NKK+lgejYq56m6nH2m16/G9AMODqP0oQy/XeYFevUpL9i9RdV0rHsJ2gc0Q==} peerDependencies: yjs: ^13 dependencies: diff --git a/tests/quick-search.spec.ts b/tests/quick-search.spec.ts index 242e09bc51..1fd1b1efb9 100644 --- a/tests/quick-search.spec.ts +++ b/tests/quick-search.spec.ts @@ -7,10 +7,13 @@ loadPage(); const openQuickSearchByShortcut = async (page: Page) => await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 })); -async function assertTitleTexts(page: Page, texts: string[]) { - const actual = await page - .locator('.affine-default-page-block-title') - .allTextContents(); +async function assertTitleTexts(page: Page, texts: string) { + const actual = await page.evaluate(() => { + const titleElement = ( + document.querySelector('.affine-default-page-block-title') + ); + return titleElement.value; + }); expect(actual).toEqual(texts); } async function assertResultList(page: Page, texts: string[]) { @@ -55,7 +58,7 @@ test.describe('Add new page in quick search', () => { const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]'); await addNewPage.click(); await page.waitForTimeout(200); - await assertTitleTexts(page, ['']); + await assertTitleTexts(page, ''); }); test('Create a new page with keyword', async ({ page }) => { @@ -65,7 +68,7 @@ test.describe('Add new page in quick search', () => { const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]'); await addNewPage.click(); await page.waitForTimeout(200); - await assertTitleTexts(page, ['test123456']); + await assertTitleTexts(page, 'test123456'); }); }); @@ -81,6 +84,6 @@ test.describe('Search and select', () => { await page.keyboard.insertText('test123456'); await assertResultList(page, ['test123456']); await page.keyboard.press('Enter', { delay: 50 }); - await assertTitleTexts(page, ['test123456']); + await assertTitleTexts(page, 'test123456'); }); });