diff --git a/packages/common/env/package.json b/packages/common/env/package.json index ef4ba190a4..89ddf62682 100644 --- a/packages/common/env/package.json +++ b/packages/common/env/package.json @@ -3,8 +3,8 @@ "private": true, "type": "module", "devDependencies": { - "@blocksuite/global": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/global": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "react": "18.2.0", "react-dom": "18.2.0", "vitest": "1.3.1" diff --git a/packages/common/infra/package.json b/packages/common/infra/package.json index 02f7542dd2..16d4ee441b 100644 --- a/packages/common/infra/package.json +++ b/packages/common/infra/package.json @@ -17,9 +17,9 @@ "@affine/debug": "workspace:*", "@affine/env": "workspace:*", "@affine/templates": "workspace:*", - "@blocksuite/blocks": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/global": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/blocks": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/global": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "foxact": "^0.2.31", "jotai": "^2.6.5", "jotai-effect": "^0.5.0", @@ -33,8 +33,8 @@ "devDependencies": { "@affine-test/fixtures": "workspace:*", "@affine/templates": "workspace:*", - "@blocksuite/lit": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/presets": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/lit": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/presets": "0.12.0-canary-202402271448-6d3a709", "@testing-library/react": "^14.2.1", "async-call-rpc": "^6.4.0", "react": "^18.2.0", diff --git a/packages/common/infra/src/blocksuite/migration/blocksuite.ts b/packages/common/infra/src/blocksuite/migration/blocksuite.ts index 7afe5ca74d..2fc17d9ac1 100644 --- a/packages/common/infra/src/blocksuite/migration/blocksuite.ts +++ b/packages/common/infra/src/blocksuite/migration/blocksuite.ts @@ -30,7 +30,7 @@ export async function migratePages( spaces.forEach((space: YDoc) => { try { // Catch page upgrade error to avoid blocking the whole workspace migration. - schema.upgradePage(0, oldVersions, space); + schema.upgradeDoc(0, oldVersions, space); } catch (e) { console.error(e); } diff --git a/packages/common/infra/src/blocksuite/migration/workspace.ts b/packages/common/infra/src/blocksuite/migration/workspace.ts index 0ba7564604..b19a7f7122 100644 --- a/packages/common/infra/src/blocksuite/migration/workspace.ts +++ b/packages/common/infra/src/blocksuite/migration/workspace.ts @@ -28,7 +28,7 @@ export function checkWorkspaceCompatibility( } // exit if no pages - if (!workspace.meta.pages?.length) { + if (!workspace.meta.docs?.length) { return null; } @@ -55,7 +55,7 @@ export function checkWorkspaceCompatibility( // TODO: Catch compatibility error from blocksuite to show upgrade page. // Temporarily follow the check logic of blocksuite. - if ((workspace.meta.pages?.length ?? 0) <= 1) { + if ((workspace.meta.docs?.length ?? 0) <= 1) { try { workspace.meta.validateVersion(workspace); } catch (e) { diff --git a/packages/common/infra/src/initialization/index.ts b/packages/common/infra/src/initialization/index.ts index 868c1a109f..8b77f876b1 100644 --- a/packages/common/infra/src/initialization/index.ts +++ b/packages/common/infra/src/initialization/index.ts @@ -1,8 +1,8 @@ import type { WorkspaceFlavour } from '@affine/env/workspace'; import type { + Doc, + DocSnapshot, JobMiddleware, - Page, - PageSnapshot, WorkspaceInfoSnapshot, } from '@blocksuite/store'; import { Job } from '@blocksuite/store'; @@ -13,7 +13,7 @@ import { PageRecordList } from '../page'; import type { WorkspaceManager } from '../workspace'; import { replaceIdMiddleware } from './middleware'; -export function initEmptyPage(page: Page, title?: string) { +export function initEmptyPage(page: Doc, title?: string) { page.load(() => { const pageBlockId = page.addBlock('affine:page', { title: new page.Text(title ?? ''), @@ -44,7 +44,7 @@ export async function buildShowcaseWorkspace( const migrationMiddleware: JobMiddleware = ({ slots, workspace }) => { slots.afterImport.on(payload => { if (payload.type === 'page') { - workspace.schema.upgradePage( + workspace.schema.upgradeDoc( info?.pageVersion ?? 0, {}, payload.page.spaceDoc @@ -65,15 +65,15 @@ export async function buildShowcaseWorkspace( // @ts-expect-error - rethinking API job._assetsManager.writeToBlob = async () => {}; - const pageSnapshots: PageSnapshot[] = Object.entries(onboarding) + const docSnapshots: DocSnapshot[] = Object.entries(onboarding) .filter(([key]) => { return key.endsWith('snapshot.json'); }) - .map(([_, value]) => value as unknown as PageSnapshot); + .map(([_, value]) => value as unknown as DocSnapshot); await Promise.all( - pageSnapshots.map(snapshot => { - return job.snapshotToPage(snapshot); + docSnapshots.map(snapshot => { + return job.snapshotToDoc(snapshot); }) ); diff --git a/packages/common/infra/src/page/context.ts b/packages/common/infra/src/page/context.ts index 646aa4b3d6..19cdebe444 100644 --- a/packages/common/infra/src/page/context.ts +++ b/packages/common/infra/src/page/context.ts @@ -1,10 +1,10 @@ -import type { Page as BlockSuitePage } from '@blocksuite/store'; +import type { Doc as BlockSuiteDoc } from '@blocksuite/store'; import { createIdentifier, type ServiceCollection } from '../di'; import type { PageRecord } from './record'; import { PageScope } from './service-scope'; -export const BlockSuitePageContext = createIdentifier( +export const BlockSuitePageContext = createIdentifier( 'BlockSuitePageContext' ); @@ -13,7 +13,7 @@ export const PageRecordContext = export function configurePageContext( services: ServiceCollection, - blockSuitePage: BlockSuitePage, + blockSuitePage: BlockSuiteDoc, pageRecord: PageRecord ) { services diff --git a/packages/common/infra/src/page/index.ts b/packages/common/infra/src/page/index.ts index be8e115ca9..ab5dbd6abd 100644 --- a/packages/common/infra/src/page/index.ts +++ b/packages/common/infra/src/page/index.ts @@ -9,7 +9,7 @@ import { CleanupService } from '../lifecycle'; import { Workspace, WorkspaceLocalState, WorkspaceScope } from '../workspace'; import { BlockSuitePageContext, PageRecordContext } from './context'; import { PageManager } from './manager'; -import { Page } from './page'; +import { Doc } from './page'; import { PageRecordList } from './record-list'; import { PageScope } from './service-scope'; @@ -22,5 +22,5 @@ export function configurePageServices(services: ServiceCollection) { services .scope(PageScope) .add(CleanupService) - .add(Page, [PageRecordContext, BlockSuitePageContext, ServiceProvider]); + .add(Doc, [PageRecordContext, BlockSuitePageContext, ServiceProvider]); } diff --git a/packages/common/infra/src/page/manager.ts b/packages/common/infra/src/page/manager.ts index 8ce8a10f2f..9725e7e9bc 100644 --- a/packages/common/infra/src/page/manager.ts +++ b/packages/common/infra/src/page/manager.ts @@ -3,11 +3,11 @@ import { ObjectPool } from '../utils/object-pool'; import type { Workspace } from '../workspace'; import type { PageRecordList } from '.'; import { configurePageContext } from './context'; -import { Page } from './page'; +import { Doc } from './page'; import { PageScope } from './service-scope'; export class PageManager { - pool = new ObjectPool({}); + pool = new ObjectPool({}); constructor( private readonly workspace: Workspace, @@ -20,7 +20,7 @@ export class PageManager { if (!pageRecord) { throw new Error('Page record not found'); } - const blockSuitePage = this.workspace.blockSuiteWorkspace.getPage(pageId); + const blockSuitePage = this.workspace.blockSuiteWorkspace.getDoc(pageId); if (!blockSuitePage) { throw new Error('Page not found'); } @@ -41,7 +41,7 @@ export class PageManager { this.serviceProvider ); - const page = provider.get(Page); + const page = provider.get(Doc); const { obj, release } = this.pool.put(pageId, page); diff --git a/packages/common/infra/src/page/page.ts b/packages/common/infra/src/page/page.ts index a390ea3a10..d291624393 100644 --- a/packages/common/infra/src/page/page.ts +++ b/packages/common/infra/src/page/page.ts @@ -1,12 +1,12 @@ -import type { Page as BlockSuitePage } from '@blocksuite/store'; +import type { Doc as BlockSuiteDoc } from '@blocksuite/store'; import type { ServiceProvider } from '@toeverything/infra/di'; import type { PageMode, PageRecord } from './record'; -export class Page { +export class Doc { constructor( public readonly record: PageRecord, - public readonly blockSuitePage: BlockSuitePage, + public readonly blockSuiteDoc: BlockSuiteDoc, public readonly services: ServiceProvider ) {} diff --git a/packages/common/infra/src/page/record-list.ts b/packages/common/infra/src/page/record-list.ts index 92d9686615..c27b359265 100644 --- a/packages/common/infra/src/page/record-list.ts +++ b/packages/common/infra/src/page/record-list.ts @@ -18,7 +18,7 @@ export class PageRecordList { new Observable(subscriber => { const emit = () => { subscriber.next( - this.workspace.blockSuiteWorkspace.meta.pageMetas.map( + this.workspace.blockSuiteWorkspace.meta.docMetas.map( v => new PageRecord(v.id, this.workspace, this.localState) ) ); @@ -27,9 +27,7 @@ export class PageRecordList { emit(); const dispose = - this.workspace.blockSuiteWorkspace.meta.pageMetasUpdated.on( - emit - ).dispose; + this.workspace.blockSuiteWorkspace.meta.docMetaUpdated.on(emit).dispose; return () => { dispose(); }; diff --git a/packages/common/infra/src/page/record.ts b/packages/common/infra/src/page/record.ts index 1777bed241..e6f109ae64 100644 --- a/packages/common/infra/src/page/record.ts +++ b/packages/common/infra/src/page/record.ts @@ -1,4 +1,4 @@ -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import { Observable } from 'rxjs'; import { LiveData } from '../livedata'; @@ -13,10 +13,10 @@ export class PageRecord { private readonly localState: WorkspaceLocalState ) {} - meta = LiveData.from( + meta = LiveData.from( new Observable(subscriber => { const emit = () => { - const meta = this.workspace.blockSuiteWorkspace.meta.pageMetas.find( + const meta = this.workspace.blockSuiteWorkspace.meta.docMetas.find( page => page.id === this.id ); if (meta === undefined) { @@ -28,9 +28,7 @@ export class PageRecord { emit(); const dispose = - this.workspace.blockSuiteWorkspace.meta.pageMetasUpdated.on( - emit - ).dispose; + this.workspace.blockSuiteWorkspace.meta.docMetaUpdated.on(emit).dispose; return () => { dispose(); }; @@ -43,8 +41,8 @@ export class PageRecord { } ); - setMeta(meta: Partial): void { - this.workspace.blockSuiteWorkspace.setPageMeta(this.id, meta); + setMeta(meta: Partial): void { + this.workspace.blockSuiteWorkspace.setDocMeta(this.id, meta); } mode: LiveData = LiveData.from( diff --git a/packages/common/infra/src/workspace/__tests__/workspace.spec.ts b/packages/common/infra/src/workspace/__tests__/workspace.spec.ts index aedb3a01b0..c0bcbe268c 100644 --- a/packages/common/infra/src/workspace/__tests__/workspace.spec.ts +++ b/packages/common/infra/src/workspace/__tests__/workspace.spec.ts @@ -22,7 +22,7 @@ describe('Workspace System', () => { expect(workspaceListService.workspaceList.value.length).toBe(1); - const page = workspace.blockSuiteWorkspace.createPage({ + const page = workspace.blockSuiteWorkspace.createDoc({ id: 'page0', }); page.load(); @@ -30,7 +30,7 @@ describe('Workspace System', () => { title: new page.Text('test-page'), }); - expect(workspace.blockSuiteWorkspace.pages.size).toBe(1); + expect(workspace.blockSuiteWorkspace.docs.size).toBe(1); expect( (page!.getBlockByFlavour('affine:page')[0] as any).title.toString() ).toBe('test-page'); diff --git a/packages/common/infra/src/workspace/engine/sync/__tests__/engine.spec.ts b/packages/common/infra/src/workspace/engine/sync/__tests__/engine.spec.ts index 773b5f91d3..1afea9137b 100644 --- a/packages/common/infra/src/workspace/engine/sync/__tests__/engine.spec.ts +++ b/packages/common/infra/src/workspace/engine/sync/__tests__/engine.spec.ts @@ -42,7 +42,7 @@ describe('SyncEngine', () => { ); syncEngine.start(); - const page = workspace.createPage({ + const page = workspace.createDoc({ id: 'page0', }); page.load(); diff --git a/packages/common/infra/src/workspace/engine/sync/__tests__/peer.spec.ts b/packages/common/infra/src/workspace/engine/sync/__tests__/peer.spec.ts index da2c406404..801e02de34 100644 --- a/packages/common/infra/src/workspace/engine/sync/__tests__/peer.spec.ts +++ b/packages/common/infra/src/workspace/engine/sync/__tests__/peer.spec.ts @@ -35,7 +35,7 @@ describe('SyncPeer', () => { ); await syncPeer.waitForLoaded(); - const page = workspace.createPage({ + const page = workspace.createDoc({ id: 'page0', }); page.load(); @@ -85,7 +85,7 @@ describe('SyncPeer', () => { await syncPeer.waitForSynced(); expect(syncPeer.status.step).toBe(SyncPeerStep.Synced); - const page = workspace.createPage({ + const page = workspace.createDoc({ id: 'page0', }); expect(syncPeer.status.step).toBe(SyncPeerStep.LoadingSubDoc); diff --git a/packages/common/y-indexeddb/package.json b/packages/common/y-indexeddb/package.json index cdbd1ddb21..ff8cdc84cd 100644 --- a/packages/common/y-indexeddb/package.json +++ b/packages/common/y-indexeddb/package.json @@ -32,14 +32,14 @@ } }, "dependencies": { - "@blocksuite/global": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/global": "0.12.0-canary-202402271448-6d3a709", "idb": "^8.0.0", "nanoid": "^5.0.6", "y-provider": "workspace:*" }, "devDependencies": { - "@blocksuite/blocks": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/blocks": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "fake-indexeddb": "^5.0.2", "vite": "^5.1.4", "vite-plugin-dts": "3.7.3", diff --git a/packages/common/y-indexeddb/src/__tests__/index.spec.ts b/packages/common/y-indexeddb/src/__tests__/index.spec.ts index 4ca121bd9f..0fa4086bcd 100644 --- a/packages/common/y-indexeddb/src/__tests__/index.spec.ts +++ b/packages/common/y-indexeddb/src/__tests__/index.spec.ts @@ -7,12 +7,12 @@ import { setTimeout } from 'node:timers/promises'; import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models'; import { assertExists } from '@blocksuite/global/utils'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import { Schema, Workspace } from '@blocksuite/store'; import { openDB } from 'idb'; import { nanoid } from 'nanoid'; import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'; -import { applyUpdate, Doc, encodeStateAsUpdate } from 'yjs'; +import { applyUpdate, Doc as YDoc, encodeStateAsUpdate } from 'yjs'; import type { WorkspacePersist } from '../index'; import { @@ -27,7 +27,7 @@ import { setMergeCount, } from '../index'; -function initEmptyPage(page: Page) { +function initEmptyPage(page: Doc) { const pageBlockId = page.addBlock('affine:page', { title: new page.Text(''), }); @@ -99,9 +99,9 @@ describe('indexeddb provider', () => { }, ], }); - const page = workspace.createPage({ id: 'page0' }); - page.waitForLoaded(); - const pageBlockId = page.addBlock('affine:page', { title: '' }); + const page = workspace.createDoc({ id: 'page0' }); + page.load(); + const pageBlockId = page.addBlock('affine:page', {}); const frameId = page.addBlock('affine:note', {}, pageBlockId); page.addBlock('affine:paragraph', {}, frameId); } @@ -129,7 +129,7 @@ describe('indexeddb provider', () => { | WorkspacePersist | undefined; assertExists(data); - testWorkspace.getPage('page0')?.waitForLoaded(); + testWorkspace.getDoc('page0')?.load(); data.updates.forEach(({ update }) => { Workspace.Y.applyUpdate(subPage, update); }); @@ -147,9 +147,9 @@ describe('indexeddb provider', () => { provider.disconnect(); expect(provider.connected).toBe(false); { - const page = workspace.createPage({ id: 'page0' }); - page.waitForLoaded(); - const pageBlockId = page.addBlock('affine:page', { title: '' }); + const page = workspace.createDoc({ id: 'page0' }); + page.load(); + const pageBlockId = page.addBlock('affine:page'); const frameId = page.addBlock('affine:note', {}, pageBlockId); page.addBlock('affine:paragraph', {}, frameId); } @@ -202,9 +202,9 @@ describe('indexeddb provider', () => { const provider = createIndexedDBProvider(workspace.doc, rootDBName); provider.connect(); { - const page = workspace.createPage({ id: 'page0' }); - page.waitForLoaded(); - const pageBlockId = page.addBlock('affine:page', { title: '' }); + const page = workspace.createDoc({ id: 'page0' }); + page.load(); + const pageBlockId = page.addBlock('affine:page'); const frameId = page.addBlock('affine:note', {}, pageBlockId); for (let i = 0; i < 99; i++) { page.addBlock('affine:paragraph', {}, frameId); @@ -250,7 +250,7 @@ describe('indexeddb provider', () => { expect(event).toBe('beforeunload'); return oldRemoveEventListener(event, fn, options); }); - const doc = new Doc({ + const doc = new YDoc({ guid: '1', }); const provider = createIndexedDBProvider(doc); @@ -270,7 +270,7 @@ describe('indexeddb provider', () => { describe('milestone', () => { test('milestone', async () => { - const doc = new Doc(); + const doc = new YDoc(); const map = doc.getMap('map'); const array = doc.getArray('array'); map.set('1', 1); @@ -281,7 +281,7 @@ describe('milestone', () => { expect(milestones).toBeDefined(); expect(Object.keys(milestones).length).toBe(1); expect(milestones.test1).toBeInstanceOf(Uint8Array); - const snapshot = new Doc(); + const snapshot = new YDoc(); applyUpdate(snapshot, milestones.test1); { const map = snapshot.getMap('map'); @@ -316,7 +316,7 @@ describe('milestone', () => { expect(fn).toBeCalled(); - const doc2 = new Doc(); + const doc2 = new YDoc(); applyUpdate(doc2, encodeStateAsUpdate(doc)); revertUpdate(doc2, milestones.test1, key => @@ -333,11 +333,11 @@ describe('subDoc', () => { test('basic', async () => { let json1: any, json2: any; { - const doc = new Doc({ + const doc = new YDoc({ guid: 'test', }); const map = doc.getMap(); - const subDoc = new Doc(); + const subDoc = new YDoc(); subDoc.load(); map.set('1', subDoc); map.set('2', 'test'); @@ -348,14 +348,14 @@ describe('subDoc', () => { json1 = doc.toJSON(); } { - const doc = new Doc({ + const doc = new YDoc({ guid: 'test', }); const provider = createIndexedDBProvider(doc); provider.connect(); await setTimeout(200); const map = doc.getMap(); - const subDoc = map.get('1') as Doc; + const subDoc = map.get('1') as YDoc; subDoc.load(); provider.disconnect(); json2 = doc.toJSON(); @@ -366,17 +366,17 @@ describe('subDoc', () => { }); test('blocksuite', async () => { - const page0 = workspace.createPage({ + const page0 = workspace.createDoc({ id: 'page0', }); - page0.waitForLoaded(); + page0.load(); const { paragraphBlockId: paragraphBlockIdPage1 } = initEmptyPage(page0); const provider = createIndexedDBProvider(workspace.doc, rootDBName); provider.connect(); - const page1 = workspace.createPage({ + const page1 = workspace.createDoc({ id: 'page1', }); - page1.waitForLoaded(); + page1.load(); const { paragraphBlockId: paragraphBlockIdPage2 } = initEmptyPage(page1); await setTimeout(200); provider.disconnect(); @@ -389,15 +389,15 @@ describe('subDoc', () => { const provider = createIndexedDBProvider(newWorkspace.doc, rootDBName); provider.connect(); await setTimeout(200); - const page0 = newWorkspace.getPage('page0') as Page; - page0.waitForLoaded(); + const page0 = newWorkspace.getDoc('page0') as Doc; + page0.load(); await setTimeout(200); { const block = page0.getBlockById(paragraphBlockIdPage1); assertExists(block); } - const page1 = newWorkspace.getPage('page1') as Page; - page1.waitForLoaded(); + const page1 = newWorkspace.getDoc('page1') as Doc; + page1.load(); await setTimeout(200); { const block = page1.getBlockById(paragraphBlockIdPage2); @@ -409,8 +409,8 @@ describe('subDoc', () => { describe('utils', () => { test('download binary', async () => { - const page = workspace.createPage({ id: 'page0' }); - page.waitForLoaded(); + const page = workspace.createDoc({ id: 'page0' }); + page.load(); initEmptyPage(page); const provider = createIndexedDBProvider(workspace.doc, rootDBName); provider.connect(); @@ -437,7 +437,7 @@ describe('utils', () => { }); test('overwrite binary', async () => { - const doc = new Doc(); + const doc = new YDoc(); const map = doc.getMap(); map.set('1', 1); await overwriteBinary('test', new Uint8Array(encodeStateAsUpdate(doc))); diff --git a/packages/common/y-provider/package.json b/packages/common/y-provider/package.json index 9595c346dc..90012ee09b 100644 --- a/packages/common/y-provider/package.json +++ b/packages/common/y-provider/package.json @@ -24,7 +24,7 @@ "build": "vite build" }, "devDependencies": { - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "vite": "^5.1.4", "vite-plugin-dts": "3.7.3", "vitest": "1.3.1", diff --git a/packages/frontend/component/package.json b/packages/frontend/component/package.json index 4ebc8e2a1c..72770981b3 100644 --- a/packages/frontend/component/package.json +++ b/packages/frontend/component/package.json @@ -72,12 +72,12 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@blocksuite/blocks": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/global": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/blocks": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/global": "0.12.0-canary-202402271448-6d3a709", "@blocksuite/icons": "2.1.44", - "@blocksuite/lit": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/presets": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/lit": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/presets": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "@storybook/addon-actions": "^7.6.17", "@storybook/addon-essentials": "^7.6.17", "@storybook/addon-interactions": "^7.6.17", diff --git a/packages/frontend/core/package.json b/packages/frontend/core/package.json index 96abdc46f3..12ae00e439 100644 --- a/packages/frontend/core/package.json +++ b/packages/frontend/core/package.json @@ -25,14 +25,14 @@ "@affine/i18n": "workspace:*", "@affine/templates": "workspace:*", "@affine/workspace-impl": "workspace:*", - "@blocksuite/block-std": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/blocks": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/global": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/block-std": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/blocks": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/global": "0.12.0-canary-202402271448-6d3a709", "@blocksuite/icons": "2.1.44", - "@blocksuite/inline": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/lit": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/presets": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/inline": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/lit": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/presets": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "@dnd-kit/core": "^6.1.0", "@dnd-kit/modifiers": "^7.0.0", "@dnd-kit/sortable": "^8.0.0", diff --git a/packages/frontend/core/src/bootstrap/first-app-data.ts b/packages/frontend/core/src/bootstrap/first-app-data.ts index a3a76c589c..b2a1300a9f 100644 --- a/packages/frontend/core/src/bootstrap/first-app-data.ts +++ b/packages/frontend/core/src/bootstrap/first-app-data.ts @@ -24,8 +24,8 @@ export async function createFirstAppData(workspaceManager: WorkspaceManager) { WorkspaceFlavour.LOCAL, async workspace => { workspace.meta.setName(DEFAULT_WORKSPACE_NAME); - const page = workspace.createPage(); - workspace.setPageMeta(page.id, { + const page = workspace.createDoc(); + workspace.setDocMeta(page.id, { jumpOnce: true, }); initEmptyPage(page); diff --git a/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx b/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx index 14b6c8df1e..02d10eb3ad 100644 --- a/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx +++ b/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx @@ -238,8 +238,8 @@ export const CreateWorkspaceModal = ({ workspaceFlavour, async workspace => { workspace.meta.setName(name); - const page = workspace.createPage(); - workspace.setPageMeta(page.id, { + const page = workspace.createDoc(); + workspace.setDocMeta(page.id, { jumpOnce: true, }); initEmptyPage(page); diff --git a/packages/frontend/core/src/components/affine/page-history-modal/data.ts b/packages/frontend/core/src/components/affine/page-history-modal/data.ts index fbb3ca10b0..6eb0f5f9a0 100644 --- a/packages/frontend/core/src/components/affine/page-history-modal/data.ts +++ b/packages/frontend/core/src/components/affine/page-history-modal/data.ts @@ -1,4 +1,4 @@ -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { useBlockSuiteWorkspacePage } from '@affine/core/hooks/use-block-suite-workspace-page'; import { timestampToLocalDate } from '@affine/core/utils'; import { DebugLogger } from '@affine/debug'; @@ -27,7 +27,7 @@ const logger = new DebugLogger('page-history'); type DocHistory = ListHistoryQuery['workspace']['histories'][number]; -export const usePageSnapshotList = (workspaceId: string, pageDocId: string) => { +export const useDocSnapshotList = (workspaceId: string, pageDocId: string) => { const pageSize = 10; const { data, loadingMore, loadMore } = useQueryInfinite({ query: listHistoryQuery, @@ -154,16 +154,16 @@ export const useSnapshotPage = ( } const pageId = pageDocId + '-' + ts; const historyShellWorkspace = getOrCreateShellWorkspace(workspace.id); - let page = historyShellWorkspace.getPage(pageId); + let page = historyShellWorkspace.getDoc(pageId); if (!page && snapshot) { - page = historyShellWorkspace.createPage({ + page = historyShellWorkspace.createDoc({ id: pageId, }); page.awarenessStore.setReadonly(page, true); const spaceDoc = page.spaceDoc; page.load(() => { applyUpdate(spaceDoc, new Uint8Array(snapshot)); - historyShellWorkspace.schema.upgradePage(0, {}, spaceDoc); + historyShellWorkspace.schema.upgradeDoc(0, {}, spaceDoc); }); // must load before applyUpdate } return page ?? undefined; @@ -197,7 +197,7 @@ export const useRestorePage = (workspace: Workspace, pageId: string) => { const { trigger: recover, isMutating } = useMutation({ mutation: recoverDocMutation, }); - const { getPageMeta, setPageTitle } = usePageMetaHelper(workspace); + const { getDocMeta, setDocTitle } = useDocMetaHelper(workspace); const onRestore = useMemo(() => { return async (version: string, update: Uint8Array) => { @@ -211,10 +211,10 @@ export const useRestorePage = (workspace: Workspace, pageId: string) => { }); // should also update the page title, since it may be changed in the history - const title = page.meta.title; + const title = page.meta?.title ?? ''; - if (getPageMeta(pageId)?.title !== title) { - setPageTitle(pageId, title); + if (getDocMeta(pageId)?.title !== title) { + setDocTitle(pageId, title); } await recover({ @@ -232,12 +232,12 @@ export const useRestorePage = (workspace: Workspace, pageId: string) => { logger.info('Page restored', pageDocId, version); }; }, [ - getPageMeta, + getDocMeta, mutateQueryResource, page, pageId, recover, - setPageTitle, + setDocTitle, workspace.id, ]); diff --git a/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx b/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx index 5784e63139..9efed36753 100644 --- a/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx +++ b/packages/frontend/core/src/components/affine/page-history-modal/history-modal.tsx @@ -10,11 +10,11 @@ import { useWorkspaceQuota } from '@affine/core/hooks/use-workspace-quota'; import { Trans } from '@affine/i18n'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { CloseIcon, ToggleCollapseIcon } from '@blocksuite/icons'; -import type { Page as BlockSuitePage } from '@blocksuite/store'; +import type { Doc as BlockSuiteDoc } from '@blocksuite/store'; import { type Workspace as BlockSuiteWorkspace } from '@blocksuite/store'; import * as Collapsible from '@radix-ui/react-collapsible'; import type { DialogContentProps } from '@radix-ui/react-dialog'; -import { Page, type PageMode, Workspace } from '@toeverything/infra'; +import { Doc, type PageMode, Workspace } from '@toeverything/infra'; import { useService } from '@toeverything/infra/di'; import { atom, useAtom, useSetAtom } from 'jotai'; import { @@ -39,7 +39,7 @@ import { import { AffineErrorBoundary } from '../affine-error-boundary'; import { historyListGroupByDay, - usePageSnapshotList, + useDocSnapshotList, useRestorePage, useSnapshotPage, } from './data'; @@ -90,7 +90,7 @@ const ModalContainer = ({ interface HistoryEditorPreviewProps { ts?: string; - snapshotPage?: BlockSuitePage; + snapshotPage?: BlockSuiteDoc; mode: PageMode; onModeChange: (mode: PageMode) => void; title: string; @@ -251,7 +251,7 @@ const PageHistoryList = ({ activeVersion?: string; onVersionChange: (version: string) => void; }) => { - const [historyList, loadMore, loadingMore] = usePageSnapshotList( + const [historyList, loadMore, loadingMore] = useDocSnapshotList( workspaceId, pageDocId ); @@ -425,7 +425,7 @@ const PageHistoryManager = ({ const [activeVersion, setActiveVersion] = useState(); const pageDocId = useMemo(() => { - return workspace.getPage(pageId)?.spaceDoc.guid ?? pageId; + return workspace.getDoc(pageId)?.spaceDoc.guid ?? pageId; }, [pageId, workspace]); const snapshotPage = useSnapshotPage(workspace, pageDocId, activeVersion); @@ -447,7 +447,7 @@ const PageHistoryManager = ({ [activeVersion, onClose, onRestore, snapshotPage] ); - const page = useService(Page); + const page = useService(Doc); const [mode, setMode] = useState(page.mode.value); const title = useBlockSuiteWorkspacePageTitle(workspace, pageId); diff --git a/packages/frontend/core/src/components/affine/page-properties/page-properties-manager.ts b/packages/frontend/core/src/components/affine/page-properties/page-properties-manager.ts index bbc173168a..3fc38b8de8 100644 --- a/packages/frontend/core/src/components/affine/page-properties/page-properties-manager.ts +++ b/packages/frontend/core/src/components/affine/page-properties/page-properties-manager.ts @@ -124,7 +124,7 @@ export class PagePropertiesMetaManager { // returns page schema properties -> related page getPropertyStatistics() { const mapping = new Map>(); - for (const page of this.adapter.workspace.blockSuiteWorkspace.pages.values()) { + for (const page of this.adapter.workspace.blockSuiteWorkspace.docs.values()) { const properties = this.adapter.getPageProperties(page.id); for (const id of Object.keys(properties.custom)) { if (!mapping.has(id)) mapping.set(id, new Set()); @@ -169,7 +169,7 @@ export class PagePropertiesManager { } get page() { - return this.adapter.workspace.blockSuiteWorkspace.getPage(this.pageId); + return this.adapter.workspace.blockSuiteWorkspace.getDoc(this.pageId); } get intrinsicMeta() { diff --git a/packages/frontend/core/src/components/affine/page-properties/property-row-value-renderer.tsx b/packages/frontend/core/src/components/affine/page-properties/property-row-value-renderer.tsx index f6a919002e..674d719daf 100644 --- a/packages/frontend/core/src/components/affine/page-properties/property-row-value-renderer.tsx +++ b/packages/frontend/core/src/components/affine/page-properties/property-row-value-renderer.tsx @@ -1,5 +1,5 @@ import { Checkbox, DatePicker, Menu } from '@affine/component'; -import { useAllBlockSuitePageMeta } from '@affine/core/hooks/use-all-block-suite-page-meta'; +import { useAllBlockSuiteDocMeta } from '@affine/core/hooks/use-all-block-suite-page-meta'; import { WorkspaceLegacyProperties } from '@affine/core/modules/workspace'; import type { PageInfoCustomProperty, @@ -9,7 +9,7 @@ import type { import { timestampToLocalDate } from '@affine/core/utils'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { assertExists } from '@blocksuite/global/utils'; -import { Page, useLiveData, useService, Workspace } from '@toeverything/infra'; +import { Doc, useLiveData, useService, Workspace } from '@toeverything/infra'; import { noop } from 'lodash-es'; import { type ChangeEventHandler, @@ -176,9 +176,9 @@ export const NumberValue = ({ property }: PropertyRowValueProps) => { export const TagsValue = () => { const workspace = useService(Workspace); - const page = useService(Page); + const page = useService(Doc); const blockSuiteWorkspace = workspace.blockSuiteWorkspace; - const pageMetas = useAllBlockSuitePageMeta(blockSuiteWorkspace); + const pageMetas = useAllBlockSuiteDocMeta(blockSuiteWorkspace); const legacyProperties = useService(WorkspaceLegacyProperties); const options = useLiveData(legacyProperties.tagOptions$); @@ -199,7 +199,7 @@ export const TagsValue = () => { placeholder={t['com.affine.page-properties.property-value-placeholder']()} value={tagIds} options={options} - readonly={page.blockSuitePage.readonly} + readonly={page.blockSuiteDoc.readonly} onChange={onChange} onOptionsChange={legacyProperties.updateTagOptions} /> diff --git a/packages/frontend/core/src/components/affine/page-properties/table.tsx b/packages/frontend/core/src/components/affine/page-properties/table.tsx index 3c3f5ab646..3d1a42ccce 100644 --- a/packages/frontend/core/src/components/affine/page-properties/table.tsx +++ b/packages/frontend/core/src/components/affine/page-properties/table.tsx @@ -27,7 +27,7 @@ import { ToggleExpandIcon, ViewIcon, } from '@blocksuite/icons'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import { DndContext, type DragEndEvent, @@ -1027,7 +1027,7 @@ const PagePropertiesTableInner = () => { ); }; -const usePagePropertiesManager = (page: Page) => { +const usePagePropertiesManager = (page: Doc) => { // the workspace properties adapter adapter is reactive, // which means it's reference will change when any of the properties change // also it will trigger a re-render of the component @@ -1040,7 +1040,7 @@ const usePagePropertiesManager = (page: Page) => { // this is the main component that renders the page properties table at the top of the page below // the page title -export const PagePropertiesTable = ({ page }: { page: Page }) => { +export const PagePropertiesTable = ({ page }: { page: Doc }) => { const manager = usePagePropertiesManager(page); // if the given page is not in the current workspace, then we don't render anything diff --git a/packages/frontend/core/src/components/affine/reference-link/index.tsx b/packages/frontend/core/src/components/affine/reference-link/index.tsx index 5357c571d1..d5dca25162 100644 --- a/packages/frontend/core/src/components/affine/reference-link/index.tsx +++ b/packages/frontend/core/src/components/affine/reference-link/index.tsx @@ -1,4 +1,4 @@ -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { useJournalHelper } from '@affine/core/hooks/use-journal'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { LinkedPageIcon, TodayIcon } from '@blocksuite/icons'; @@ -10,7 +10,7 @@ import * as styles from './styles.css'; export interface PageReferenceRendererOptions { pageId: string; - pageMetaHelper: ReturnType; + pageMetaHelper: ReturnType; journalHelper: ReturnType; t: ReturnType; } @@ -22,7 +22,7 @@ export function pageReferenceRenderer({ t, }: PageReferenceRendererOptions) { const { isPageJournal, getLocalizedJournalDateString } = journalHelper; - const referencedPage = pageMetaHelper.getPageMeta(pageId); + const referencedPage = pageMetaHelper.getDocMeta(pageId); let title = referencedPage?.title ?? t['com.affine.editor.reference-not-found'](); let icon = ; @@ -35,7 +35,9 @@ export function pageReferenceRenderer({ return ( <> {icon} - {title} + + {title ? title : 'Untitled'} + ); } @@ -49,7 +51,7 @@ export function AffinePageReference({ pageId: string; wrapper?: React.ComponentType; }) { - const pageMetaHelper = usePageMetaHelper(workspace); + const pageMetaHelper = useDocMetaHelper(workspace); const journalHelper = useJournalHelper(workspace); const t = useAFFiNEI18N(); const el = pageReferenceRenderer({ diff --git a/packages/frontend/core/src/components/affine/share-page-modal/index.tsx b/packages/frontend/core/src/components/affine/share-page-modal/index.tsx index 2f67cb3678..73330ac3a1 100644 --- a/packages/frontend/core/src/components/affine/share-page-modal/index.tsx +++ b/packages/frontend/core/src/components/affine/share-page-modal/index.tsx @@ -1,6 +1,6 @@ import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks'; import { WorkspaceFlavour } from '@affine/env/workspace'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import { type Workspace, WorkspaceManager } from '@toeverything/infra'; import { useService } from '@toeverything/infra'; import { useState } from 'react'; @@ -11,7 +11,7 @@ import { ShareMenu } from './share-menu'; type SharePageModalProps = { workspace: Workspace; - page: Page; + page: Doc; isJournal?: boolean; }; diff --git a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-export.tsx b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-export.tsx index 2e192a386d..7e22856c7e 100644 --- a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-export.tsx +++ b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-export.tsx @@ -4,7 +4,7 @@ import { ExportMenuItems } from '@affine/core/components/page-list'; import { WorkspaceFlavour } from '@affine/env/workspace'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { LinkIcon } from '@blocksuite/icons'; -import { Page, useLiveData } from '@toeverything/infra'; +import { Doc, useLiveData } from '@toeverything/infra'; import { useService } from '@toeverything/infra/di'; import { useExportPage } from '../../../../hooks/affine/use-export-page'; @@ -17,7 +17,7 @@ export const ShareExport = ({ currentPage, }: ShareMenuProps) => { const t = useAFFiNEI18N(); - const page = useService(Page); + const page = useService(Doc); const workspaceId = workspace.id; const pageId = currentPage.id; const { sharingUrl, onClickCopyLink } = useSharingUrl({ diff --git a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx index 26ea51be2e..feab7fb4f7 100644 --- a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx +++ b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-menu.tsx @@ -4,7 +4,7 @@ import { Menu } from '@affine/component/ui/menu'; import { WorkspaceFlavour } from '@affine/env/workspace'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { WebIcon } from '@blocksuite/icons'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import type { WorkspaceMetadata } from '@toeverything/infra'; import clsx from 'clsx'; @@ -15,7 +15,7 @@ import { SharePage } from './share-page'; export interface ShareMenuProps { workspaceMetadata: WorkspaceMetadata; - currentPage: Page; + currentPage: Doc; isJournal?: boolean; onEnableAffineCloud: () => void; } diff --git a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-page.tsx b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-page.tsx index 82af849a08..b0d03ba216 100644 --- a/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-page.tsx +++ b/packages/frontend/core/src/components/affine/share-page-modal/share-menu/share-page.tsx @@ -15,7 +15,7 @@ import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { ArrowRightSmallIcon } from '@blocksuite/icons'; import { useService } from '@toeverything/infra'; import { useLiveData } from '@toeverything/infra'; -import { Page, type PageMode } from '@toeverything/infra'; +import { Doc, type PageMode } from '@toeverything/infra'; import { useMemo, useState } from 'react'; import { useCallback } from 'react'; @@ -56,7 +56,7 @@ export const AffineSharePage = (props: ShareMenuProps) => { currentPage, } = props; const pageId = currentPage.id; - const page = useService(Page); + const page = useService(Doc); const [showDisable, setShowDisable] = useState(false); const { isSharedPage, diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx index 0c83d953f3..f2140edc16 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx @@ -1,10 +1,10 @@ import type { BlockElement } from '@blocksuite/lit'; import type { AffineEditorContainer, - DocEditor, EdgelessEditor, + PageEditor, } from '@blocksuite/presets'; -import { type Page, Slot } from '@blocksuite/store'; +import { type Doc, Slot } from '@blocksuite/store'; import type { PageMode } from '@toeverything/infra'; import clsx from 'clsx'; import type React from 'react'; @@ -37,7 +37,7 @@ function forwardSlot>>( } interface BlocksuiteEditorContainerProps { - page: Page; + page: Doc; mode: PageMode; className?: string; style?: React.CSSProperties; @@ -48,7 +48,7 @@ interface BlocksuiteEditorContainerProps { // mimic the interface of the webcomponent and expose slots & host type BlocksuiteEditorContainerRef = Pick< (typeof AffineEditorContainer)['prototype'], - 'mode' | 'page' | 'slots' | 'host' + 'mode' | 'doc' | 'slots' | 'host' > & HTMLDivElement; @@ -100,14 +100,14 @@ export const BlocksuiteEditorContainer = forwardRef< ref ) { const rootRef = useRef(null); - const docRef = useRef(null); + const docRef = useRef(null); const edgelessRef = useRef(null); const slots: BlocksuiteEditorContainerRef['slots'] = useMemo(() => { return { - pageLinkClicked: new Slot(), - pageModeSwitched: new Slot(), - pageUpdated: new Slot(), + docLinkClicked: new Slot(), + editorModeSwitched: new Slot(), + docUpdated: new Slot(), tagClicked: new Slot(), }; }, []); @@ -115,11 +115,10 @@ export const BlocksuiteEditorContainer = forwardRef< // forward the slot to the webcomponent useLayoutEffect(() => { requestAnimationFrame(() => { - const docPage = rootRef.current?.querySelector('affine-doc-page'); + const docPage = rootRef.current?.querySelector('affine-page-root'); const edgelessPage = rootRef.current?.querySelector( - 'affine-edgeless-page' + 'affine-edgeless-root' ); - ('affine-edgeless-page'); if (docPage) { forwardSlot(docPage.slots, slots); } @@ -131,12 +130,12 @@ export const BlocksuiteEditorContainer = forwardRef< }, [page, slots]); useLayoutEffect(() => { - slots.pageUpdated.emit({ newPageId: page.id }); - }, [page, slots.pageUpdated]); + slots.docUpdated.emit({ newDocId: page.id }); + }, [page, slots.docUpdated]); useLayoutEffect(() => { - slots.pageModeSwitched.emit(mode); - }, [mode, slots.pageModeSwitched]); + slots.editorModeSwitched.emit(mode); + }, [mode, slots.editorModeSwitched]); /** * mimic an AffineEditorContainer using proxy diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx index ef1f8c75c0..38d209f27d 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx @@ -1,10 +1,10 @@ import { EditorLoading } from '@affine/component/page-detail-skeleton'; -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { useJournalHelper } from '@affine/core/hooks/use-journal'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { assertExists } from '@blocksuite/global/utils'; import type { AffineEditorContainer } from '@blocksuite/presets'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import { use } from 'foxact/use'; import type { CSSProperties, ReactElement } from 'react'; import { @@ -30,7 +30,7 @@ export type ErrorBoundaryProps = { }; export type EditorProps = { - page: Page; + page: Doc; mode: 'page' | 'edgeless'; defaultSelectedBlockId?: string; // on Editor instance instantiated @@ -39,7 +39,7 @@ export type EditorProps = { className?: string; }; -function usePageRoot(page: Page) { +function usePageRoot(page: Doc) { if (!page.ready) { page.load(); } @@ -81,7 +81,7 @@ const customRenderersFactory: ( * TODO: Define error to unexpected state together in the future. */ export class NoPageRootError extends Error { - constructor(public page: Page) { + constructor(public page: Doc) { super('Page root not found when render editor!'); // Log info to let sentry collect more message @@ -138,7 +138,7 @@ const BlockSuiteEditorImpl = forwardRef( }; }, []); - const pageMetaHelper = usePageMetaHelper(page.workspace); + const pageMetaHelper = useDocMetaHelper(page.workspace); const journalHelper = useJournalHelper(page.workspace); const t = useAFFiNEI18N(); diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/journal-doc-title.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/journal-doc-title.tsx index bb9cf58b56..aca27a2463 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/journal-doc-title.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/journal-doc-title.tsx @@ -1,10 +1,10 @@ import { useJournalInfoHelper } from '@affine/core/hooks/use-journal'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import * as styles from './styles.css'; -export const BlocksuiteEditorJournalDocTitle = ({ page }: { page: Page }) => { +export const BlocksuiteEditorJournalDocTitle = ({ page }: { page: Doc }) => { const { localizedJournalDate, isTodayJournal, journalDate } = useJournalInfoHelper(page.workspace, page.id); const t = useAFFiNEI18N(); diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx index 507bb5fe1d..ee0ee6dd64 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx @@ -1,14 +1,13 @@ import { createReactComponentFromLit } from '@affine/component'; import { useJournalInfoHelper } from '@affine/core/hooks/use-journal'; -import type { DocPageService } from '@blocksuite/blocks'; import { BiDirectionalLinkPanel, - DocEditor, + DocMetaTags, DocTitle, EdgelessEditor, - PageMetaTags, + PageEditor, } from '@blocksuite/presets'; -import { type Page } from '@blocksuite/store'; +import { type Doc } from '@blocksuite/store'; import clsx from 'clsx'; import React, { forwardRef, @@ -32,7 +31,7 @@ import * as styles from './styles.css'; const adapted = { DocEditor: createReactComponentFromLit({ react: React, - elementClass: DocEditor, + elementClass: PageEditor, }), DocTitle: createReactComponentFromLit({ react: React, @@ -40,7 +39,7 @@ const adapted = { }), PageMetaTags: createReactComponentFromLit({ react: React, - elementClass: PageMetaTags, + elementClass: DocMetaTags, }), EdgelessEditor: createReactComponentFromLit({ react: React, @@ -53,23 +52,23 @@ const adapted = { }; interface BlocksuiteDocEditorProps { - page: Page; + page: Doc; customRenderers?: InlineRenderers; // todo: add option to replace docTitle with custom component (e.g., for journal page) } export const BlocksuiteDocEditor = forwardRef< - DocEditor, + PageEditor, BlocksuiteDocEditorProps >(function BlocksuiteDocEditor({ page, customRenderers }, ref) { const titleRef = useRef(null); - const docRef = useRef(null); + const docRef = useRef(null); const [docPage, setDocPage] = - useState(); + useState(); const { isJournal } = useJournalInfoHelper(page.workspace, page.id); const onDocRef = useCallback( - (el: DocEditor) => { + (el: PageEditor) => { docRef.current = el; if (ref) { if (typeof ref === 'function') { @@ -89,7 +88,7 @@ export const BlocksuiteDocEditor = forwardRef< useEffect(() => { // auto focus the title setTimeout(() => { - const docPage = docRef.current?.querySelector('affine-doc-page'); + const docPage = docRef.current?.querySelector('affine-page-root'); if (docPage) { setDocPage(docPage); } @@ -105,11 +104,11 @@ export const BlocksuiteDocEditor = forwardRef< return (
{!isJournal ? ( - + ) : ( )} @@ -117,7 +116,7 @@ export const BlocksuiteDocEditor = forwardRef< @@ -125,14 +124,12 @@ export const BlocksuiteDocEditor = forwardRef<
{ - ( - docPage.std.spec.getService('affine:page') as DocPageService - ).appendParagraph(); + docPage.std.spec.getService('affine:page').appendParagraph(); }} >
) : null} {docPage ? ( - + ) : null}
@@ -146,5 +143,5 @@ export const BlocksuiteEdgelessEditor = forwardRef< const specs = useMemo(() => { return patchSpecs(edgelessModeSpecs, customRenderers); }, [customRenderers]); - return ; + return ; }); diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.ts index 284543530c..c54b1a1321 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.ts +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.ts @@ -1,12 +1,12 @@ import type { BlockSpec } from '@blocksuite/block-std'; -import type { PageService, ParagraphService } from '@blocksuite/blocks'; +import type { ParagraphService, RootService } from '@blocksuite/blocks'; import { AttachmentService, CanvasTextFonts, - DocEditorBlockSpecs, - DocPageService, EdgelessEditorBlockSpecs, - EdgelessPageService, + EdgelessRootService, + PageEditorBlockSpecs, + PageRootService, } from '@blocksuite/blocks'; import bytes from 'bytes'; import { html, unsafeStatic } from 'lit/static-html.js'; @@ -20,7 +20,7 @@ class CustomAttachmentService extends AttachmentService { } } -function customLoadFonts(service: PageService): void { +function customLoadFonts(service: RootService): void { const officialDomains = new Set(['app.affine.pro', 'affine.fail']); if (!officialDomains.has(window.location.host)) { const fonts = CanvasTextFonts.map(font => ({ @@ -34,12 +34,12 @@ function customLoadFonts(service: PageService): void { } } -class CustomDocPageService extends DocPageService { +class CustomDocPageService extends PageRootService { override loadFonts(): void { customLoadFonts(this); } } -class CustomEdgelessPageService extends EdgelessPageService { +class CustomEdgelessPageService extends EdgelessRootService { override loadFonts(): void { customLoadFonts(this); } @@ -97,7 +97,7 @@ export function patchSpecs( return newSpecs; } -export const docModeSpecs = DocEditorBlockSpecs.map(spec => { +export const docModeSpecs = PageEditorBlockSpecs.map(spec => { if (spec.schema.model.flavour === 'affine:attachment') { return { ...spec, diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/styles.css.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/styles.css.ts index 97289d4e32..406b88f8de 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/styles.css.ts +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/styles.css.ts @@ -5,7 +5,7 @@ export const docEditorRoot = style({ background: cssVar('backgroundPrimaryColor'), }); -// brings styles of .affine-doc-viewport from blocksuite +// brings styles of .affine-page-viewport from blocksuite export const affineDocViewport = style({ display: 'flex', flexDirection: 'column', diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/favorite/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/favorite/index.tsx index b0c3f38b91..51094b88fb 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-header/favorite/index.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/favorite/index.tsx @@ -1,6 +1,6 @@ import { FavoriteTag } from '@affine/core/components/page-list'; import { useBlockSuiteMetaHelper } from '@affine/core/hooks/affine/use-block-suite-meta-helper'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { toast } from '@affine/core/utils'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { assertExists } from '@blocksuite/global/utils'; @@ -16,10 +16,10 @@ export const useFavorite = (pageId: string) => { const t = useAFFiNEI18N(); const workspace = useService(Workspace); const blockSuiteWorkspace = workspace.blockSuiteWorkspace; - const currentPage = blockSuiteWorkspace.getPage(pageId); + const currentPage = blockSuiteWorkspace.getDoc(pageId); assertExists(currentPage); - const pageMeta = useBlockSuitePageMeta(blockSuiteWorkspace).find( + const pageMeta = useBlockSuiteDocMeta(blockSuiteWorkspace).find( meta => meta.id === pageId ); const favorite = pageMeta?.favorite ?? false; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/journal/date-picker.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/journal/date-picker.tsx index fc497078cb..bc9eed453d 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-header/journal/date-picker.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/journal/date-picker.tsx @@ -4,13 +4,13 @@ import { useJournalRouteHelper, } from '@affine/core/hooks/use-journal'; import type { BlockSuiteWorkspace } from '@affine/core/shared'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import dayjs from 'dayjs'; import { useEffect, useRef, useState } from 'react'; export interface JournalWeekDatePickerProps { workspace: BlockSuiteWorkspace; - page: Page; + page: Doc; } const weekStyle = { maxWidth: 800, width: '100%' }; diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx index 76f1719c43..de507462e2 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx @@ -11,7 +11,7 @@ import { Export, MoveToTrash } from '@affine/core/components/page-list'; import { useBlockSuiteMetaHelper } from '@affine/core/hooks/affine/use-block-suite-meta-helper'; import { useExportPage } from '@affine/core/hooks/affine/use-export-page'; import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { WorkspaceFlavour } from '@affine/env/workspace'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { assertExists } from '@blocksuite/global/utils'; @@ -25,7 +25,7 @@ import { ImportIcon, PageIcon, } from '@blocksuite/icons'; -import { Page, useLiveData, useService, Workspace } from '@toeverything/infra'; +import { Doc, useLiveData, useService, Workspace } from '@toeverything/infra'; import { useSetAtom } from 'jotai'; import { useCallback, useState } from 'react'; @@ -48,13 +48,13 @@ export const PageHeaderMenuButton = ({ const workspace = useService(Workspace); const blockSuiteWorkspace = workspace.blockSuiteWorkspace; - const currentPage = blockSuiteWorkspace.getPage(pageId); + const currentPage = blockSuiteWorkspace.getDoc(pageId); assertExists(currentPage); - const pageMeta = useBlockSuitePageMeta(blockSuiteWorkspace).find( + const pageMeta = useBlockSuiteDocMeta(blockSuiteWorkspace).find( meta => meta.id === pageId ); - const page = useService(Page); + const page = useService(Doc); const currentMode = useLiveData(page.mode); const { favorite, toggleFavorite } = useFavorite(pageId); diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx index b55a64b507..e1aa2b9950 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/title/index.tsx @@ -1,7 +1,7 @@ import { InlineEdit, type InlineEditProps } from '@affine/component'; import { - useBlockSuitePageMeta, - usePageMetaHelper, + useBlockSuiteDocMeta, + useDocMetaHelper, } from '@affine/core/hooks/use-block-suite-page-meta'; import type { BlockSuiteWorkspace } from '@affine/core/shared'; import type { HTMLAttributes } from 'react'; @@ -27,18 +27,18 @@ export const BlocksuiteHeaderTitle = (props: BlockSuiteHeaderTitleProps) => { isPublic, inputHandleRef, } = props; - const currentPage = workspace.getPage(pageId); - const pageMeta = useBlockSuitePageMeta(workspace).find( + const currentPage = workspace.getDoc(pageId); + const pageMeta = useBlockSuiteDocMeta(workspace).find( meta => meta.id === currentPage?.id ); const title = pageMeta?.title; - const { setPageTitle } = usePageMetaHelper(workspace); + const { setDocTitle } = useDocMetaHelper(workspace); const onChange = useCallback( (v: string) => { - setPageTitle(currentPage?.id || '', v); + setDocTitle(currentPage?.id || '', v); }, - [currentPage?.id, setPageTitle] + [currentPage?.id, setDocTitle] ); return ( diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/index.tsx index 0237354561..fd26ba350a 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/index.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/index.tsx @@ -1,8 +1,8 @@ import { Tooltip } from '@affine/component/ui/tooltip'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { - Page, + Doc, type PageMode, useLiveData, useService, @@ -42,11 +42,11 @@ export const EditorModeSwitch = ({ publicMode, }: EditorModeSwitchProps) => { const t = useAFFiNEI18N(); - const pageMeta = useBlockSuitePageMeta(blockSuiteWorkspace).find( + const pageMeta = useBlockSuiteDocMeta(blockSuiteWorkspace).find( meta => meta.id === pageId ); const trash = pageMeta?.trash ?? false; - const page = useService(Page); + const page = useService(Doc); const currentMode = useLiveData(page.mode); diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx index 5dcf82e1d5..10ec1533f8 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-page-list/utils.tsx @@ -1,6 +1,6 @@ import { toast } from '@affine/component'; import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks'; -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { useBlockSuiteWorkspaceHelper } from '@affine/core/hooks/use-block-suite-workspace-helper'; import { WorkspaceSubPath } from '@affine/core/shared'; import { useService } from '@toeverything/infra'; @@ -13,8 +13,8 @@ import type { BlockSuiteWorkspace } from '../../../shared'; export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => { const { openPage, jumpToSubPath } = useNavigateHelper(); - const { createPage } = useBlockSuiteWorkspaceHelper(blockSuiteWorkspace); - const { setPageMeta } = usePageMetaHelper(blockSuiteWorkspace); + const { createDoc } = useBlockSuiteWorkspaceHelper(blockSuiteWorkspace); + const { setDocMeta } = useDocMetaHelper(blockSuiteWorkspace); const pageRecordList = useService(PageRecordList); const isPreferredEdgeless = useCallback( @@ -25,13 +25,13 @@ export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => { const createPageAndOpen = useCallback( (mode?: 'page' | 'edgeless') => { - const page = createPage(); + const page = createDoc(); initEmptyPage(page); pageRecordList.record(page.id).value?.setMode(mode || 'page'); openPage(blockSuiteWorkspace.id, page.id); return page; }, - [blockSuiteWorkspace.id, createPage, openPage, pageRecordList] + [blockSuiteWorkspace.id, createDoc, openPage, pageRecordList] ); const createEdgelessAndOpen = useCallback(() => { @@ -64,7 +64,7 @@ export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => { async (pageId: string) => { const page = createPageAndOpen(); page.load(); - const parentPage = blockSuiteWorkspace.getPage(pageId); + const parentPage = blockSuiteWorkspace.getDoc(pageId); if (parentPage) { parentPage.load(); const text = parentPage.Text.fromDelta([ @@ -80,10 +80,10 @@ export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => { ]); const [frame] = parentPage.getBlockByFlavour('affine:note'); frame && parentPage.addBlock('affine:paragraph', { text }, frame.id); - setPageMeta(page.id, {}); + setDocMeta(page.id, {}); } }, - [blockSuiteWorkspace, createPageAndOpen, setPageMeta] + [blockSuiteWorkspace, createPageAndOpen, setDocMeta] ); return useMemo(() => { diff --git a/packages/frontend/core/src/components/cloud/share-header-right-item/present.tsx b/packages/frontend/core/src/components/cloud/share-header-right-item/present.tsx index 4b8044d0a6..1db94b4764 100644 --- a/packages/frontend/core/src/components/cloud/share-header-right-item/present.tsx +++ b/packages/frontend/core/src/components/cloud/share-header-right-item/present.tsx @@ -1,7 +1,7 @@ import { Button } from '@affine/component/ui/button'; import { useActiveBlocksuiteEditor } from '@affine/core/hooks/use-block-suite-editor'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { EdgelessPageService } from '@blocksuite/blocks'; +import type { EdgelessRootService } from '@blocksuite/blocks'; import { PresentationIcon } from '@blocksuite/icons'; import { useCallback, useEffect, useState } from 'react'; @@ -18,18 +18,18 @@ export const PresentButton = () => { // TODO: use surfaceService subAtom const enterPresentationMode = () => { - const edgelessPageService = editorHost.spec.getService( + const edgelessRootService = editorHost.spec.getService( 'affine:page' - ) as EdgelessPageService; + ) as EdgelessRootService; if ( - !edgelessPageService || - edgelessPageService.tool.edgelessTool.type === 'frameNavigator' + !edgelessRootService || + edgelessRootService.tool.edgelessTool.type === 'frameNavigator' ) { return; } - edgelessPageService.tool.setEdgelessTool({ type: 'frameNavigator' }); + edgelessRootService.tool.setEdgelessTool({ type: 'frameNavigator' }); }; enterPresentationMode(); @@ -42,7 +42,7 @@ export const PresentButton = () => { const editorHost = editor?.host; if (!editorHost) return; - const edgelessPage = editorHost?.querySelector('affine-edgeless-page'); + const edgelessPage = editorHost?.querySelector('affine-edgeless-root'); if (!edgelessPage) return; edgelessPage.slots.edgelessToolUpdated.on(() => { diff --git a/packages/frontend/core/src/components/image-preview/index.tsx b/packages/frontend/core/src/components/image-preview/index.tsx index bc81976909..3c9aca8e91 100644 --- a/packages/frontend/core/src/components/image-preview/index.tsx +++ b/packages/frontend/core/src/components/image-preview/index.tsx @@ -96,7 +96,7 @@ const ImagePreviewModalImpl = ( if (!hasPlayedAnimation) { setHasPlayedAnimation(true); } - const page = workspace.getPage(props.pageId); + const page = workspace.getDoc(props.pageId); assertExists(page); const block = page.getBlockById(blockId); assertExists(block); @@ -116,7 +116,7 @@ const ImagePreviewModalImpl = ( (blockId: string | null) => { assertExists(blockId); const workspace = props.workspace; - const page = workspace.getPage(props.pageId); + const page = workspace.getDoc(props.pageId); assertExists(page); const block = page.getBlockById(blockId); assertExists(block); @@ -137,7 +137,7 @@ const ImagePreviewModalImpl = ( (blockId: string) => { const { pageId, workspace, onClose } = props; - const page = workspace.getPage(pageId); + const page = workspace.getDoc(pageId); assertExists(page); const block = page.getBlockById(blockId); assertExists(block); @@ -186,7 +186,7 @@ const ImagePreviewModalImpl = ( const downloadHandler = useCallback( async (blockId: string | null) => { const workspace = props.workspace; - const page = workspace.getPage(props.pageId); + const page = workspace.getDoc(props.pageId); assertExists(page); if (typeof blockId === 'string') { const block = page.getBlockById(blockId) as ImageBlockModel; @@ -240,14 +240,14 @@ const ImagePreviewModalImpl = ( [props.pageId, props.workspace] ); const [caption, setCaption] = useState(() => { - const page = props.workspace.getPage(props.pageId); + const page = props.workspace.getDoc(props.pageId); assertExists(page); const block = page.getBlockById(props.blockId) as ImageBlockModel; assertExists(block); return block?.caption; }); useEffect(() => { - const page = props.workspace.getPage(props.pageId); + const page = props.workspace.getDoc(props.pageId); assertExists(page); const block = page.getBlockById(props.blockId) as ImageBlockModel; assertExists(block); @@ -257,7 +257,7 @@ const ImagePreviewModalImpl = ( ['workspace', 'image', props.pageId, props.blockId], { fetcher: ([_, __, pageId, blockId]) => { - const page = props.workspace.getPage(pageId); + const page = props.workspace.getDoc(pageId); assertExists(page); const block = page.getBlockById(blockId) as ImageBlockModel; assertExists(block); @@ -510,7 +510,7 @@ export const ImagePreviewModal = ( const workspace = props.workspace; - const page = workspace.getPage(props.pageId); + const page = workspace.getDoc(props.pageId); assertExists(page); const block = page.getBlockById(blockId); assertExists(block); diff --git a/packages/frontend/core/src/components/page-detail-editor.css.ts b/packages/frontend/core/src/components/page-detail-editor.css.ts index 664319998c..db445ca9ba 100644 --- a/packages/frontend/core/src/components/page-detail-editor.css.ts +++ b/packages/frontend/core/src/components/page-detail-editor.css.ts @@ -11,7 +11,7 @@ export const editor = style({ }, }); globalStyle( - `${editor} .affine-doc-viewport:not(.affine-embed-synced-doc-editor)`, + `${editor} .affine-page-viewport:not(.affine-embed-synced-doc-editor)`, { paddingBottom: '150px', } diff --git a/packages/frontend/core/src/components/page-detail-editor.tsx b/packages/frontend/core/src/components/page-detail-editor.tsx index 51f0328b47..8149285008 100644 --- a/packages/frontend/core/src/components/page-detail-editor.tsx +++ b/packages/frontend/core/src/components/page-detail-editor.tsx @@ -5,9 +5,9 @@ import { useBlockSuiteWorkspacePage } from '@affine/core/hooks/use-block-suite-w import { assertExists, DisposableGroup } from '@blocksuite/global/utils'; import type { AffineEditorContainer } from '@blocksuite/presets'; import type { Workspace } from '@blocksuite/store'; -import type { Page as BlockSuitePage } from '@blocksuite/store'; +import type { Doc as BlockSuiteDoc } from '@blocksuite/store'; import { - Page, + Doc, type PageMode, useLiveData, useService, @@ -28,7 +28,7 @@ declare global { } export type OnLoadEditor = ( - page: BlockSuitePage, + page: BlockSuiteDoc, editor: AffineEditorContainer ) => () => void; @@ -49,8 +49,8 @@ const PageDetailEditorMain = memo(function PageDetailEditorMain({ onLoad, isPublic, publishMode, -}: PageDetailEditorProps & { page: BlockSuitePage }) { - const currentMode = useLiveData(useService(Page).mode); +}: PageDetailEditorProps & { page: BlockSuiteDoc }) { + const currentMode = useLiveData(useService(Doc).mode); const mode = useMemo(() => { const shareMode = publishMode || currentMode; @@ -81,7 +81,7 @@ const PageDetailEditorMain = memo(function PageDetailEditorMain({ const disposableGroup = new DisposableGroup(); disposableGroup.add( page.slots.blockUpdated.once(() => { - page.workspace.setPageMeta(page.id, { + page.workspace.setDocMeta(page.id, { updatedDate: Date.now(), }); }) diff --git a/packages/frontend/core/src/components/page-list/__tests__/use-block-suite-page-preview.spec.ts b/packages/frontend/core/src/components/page-list/__tests__/use-block-suite-page-preview.spec.ts index e36be557e9..4615dd3492 100644 --- a/packages/frontend/core/src/components/page-list/__tests__/use-block-suite-page-preview.spec.ts +++ b/packages/frontend/core/src/components/page-list/__tests__/use-block-suite-page-preview.spec.ts @@ -5,7 +5,7 @@ import 'fake-indexeddb/auto'; import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models'; import { assertExists } from '@blocksuite/global/utils'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import { Schema, Workspace as BlockSuiteWorkspace } from '@blocksuite/store'; import { renderHook } from '@testing-library/react'; import { useAtomValue } from 'jotai'; @@ -21,8 +21,8 @@ schema.register(AffineSchemas).register(__unstableSchemas); beforeEach(async () => { vi.useFakeTimers({ toFake: ['requestIdleCallback'] }); blockSuiteWorkspace = new BlockSuiteWorkspace({ id: 'test', schema }); - const initPage = async (page: Page) => { - page.waitForLoaded(); + const initPage = async (page: Doc) => { + page.load(); expect(page).not.toBeNull(); assertExists(page); const pageBlockId = page.addBlock('affine:page', { @@ -31,12 +31,12 @@ beforeEach(async () => { const frameId = page.addBlock('affine:note', {}, pageBlockId); page.addBlock('affine:paragraph', {}, frameId); }; - await initPage(blockSuiteWorkspace.createPage({ id: 'page0' })); + await initPage(blockSuiteWorkspace.createDoc({ id: 'page0' })); }); describe('useBlockSuitePagePreview', () => { test('basic', async () => { - const page = blockSuiteWorkspace.getPage('page0') as Page; + const page = blockSuiteWorkspace.getDoc('page0') as Doc; const id = page.addBlock( 'affine:paragraph', { diff --git a/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx b/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx index 377666cff2..0fd3e44d97 100644 --- a/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx +++ b/packages/frontend/core/src/components/page-list/docs/virtualized-page-list.tsx @@ -1,11 +1,11 @@ import { toast } from '@affine/component'; import { useBlockSuiteMetaHelper } from '@affine/core/hooks/affine/use-block-suite-meta-helper'; import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import type { Collection, Filter } from '@affine/env/filter'; import { Trans } from '@affine/i18n'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { PageMeta, Tag } from '@blocksuite/store'; +import type { DocMeta, Tag } from '@blocksuite/store'; import { useService } from '@toeverything/infra'; import { Workspace } from '@toeverything/infra'; import { useCallback, useMemo, useRef, useState } from 'react'; @@ -37,7 +37,7 @@ const usePageOperationsRenderer = () => { const t = useAFFiNEI18N(); const pageOperationsRenderer = useCallback( - (page: PageMeta) => { + (page: DocMeta) => { const onDisablePublicSharing = () => { toast('Successfully disabled', { portal: document.body, @@ -90,14 +90,14 @@ export const VirtualizedPageList = ({ collection?: Collection; filters?: Filter[]; config?: AllPageListConfig; - listItem?: PageMeta[]; + listItem?: DocMeta[]; setHideHeaderCreateNewPage?: (hide: boolean) => void; }) => { const listRef = useRef(null); const [showFloatingToolbar, setShowFloatingToolbar] = useState(false); const [selectedPageIds, setSelectedPageIds] = useState([]); const currentWorkspace = useService(Workspace); - const pageMetas = useBlockSuitePageMeta(currentWorkspace.blockSuiteWorkspace); + const pageMetas = useBlockSuiteDocMeta(currentWorkspace.blockSuiteWorkspace); const pageOperations = usePageOperationsRenderer(); const { isPreferredEdgeless } = usePageHelper( currentWorkspace.blockSuiteWorkspace @@ -125,7 +125,7 @@ export const VirtualizedPageList = ({ const pageOperationRenderer = useCallback( (item: ListItem) => { - const page = item as PageMeta; + const page = item as DocMeta; return pageOperations(page); }, [pageOperations] diff --git a/packages/frontend/core/src/components/page-list/page-group.tsx b/packages/frontend/core/src/components/page-list/page-group.tsx index b3f81948ef..4f29af48f7 100644 --- a/packages/frontend/core/src/components/page-list/page-group.tsx +++ b/packages/frontend/core/src/components/page-list/page-group.tsx @@ -10,7 +10,7 @@ import { ToggleCollapseIcon, ViewLayersIcon, } from '@blocksuite/icons'; -import type { PageMeta, Workspace } from '@blocksuite/store'; +import type { DocMeta, Workspace } from '@blocksuite/store'; import * as Collapsible from '@radix-ui/react-collapsible'; import clsx from 'clsx'; import { selectAtom } from 'jotai/utils'; @@ -223,7 +223,7 @@ const listsPropsAtom = selectAtom( export const PageListItemRenderer = (item: ListItem) => { const props = useAtomValue(listsPropsAtom); const { selectionActive } = useAtomValue(selectionStateAtom); - const page = item as PageMeta; + const page = item as DocMeta; return ( + item: DocMeta, + props: RequiredProps ): PageListItemProps { const toggleSelection = props.onSelectedIdsChange ? () => { diff --git a/packages/frontend/core/src/components/page-list/types.ts b/packages/frontend/core/src/components/page-list/types.ts index e820c96c2c..0b871ef675 100644 --- a/packages/frontend/core/src/components/page-list/types.ts +++ b/packages/frontend/core/src/components/page-list/types.ts @@ -1,9 +1,9 @@ import type { Collection, Tag } from '@affine/env/filter'; -import type { PageMeta, Workspace } from '@blocksuite/store'; +import type { DocMeta, Workspace } from '@blocksuite/store'; import type { PropsWithChildren, ReactNode } from 'react'; import type { To } from 'react-router-dom'; -export type ListItem = PageMeta | CollectionMeta | TagMeta; +export type ListItem = DocMeta | CollectionMeta | TagMeta; export interface CollectionMeta extends Collection { title: string; diff --git a/packages/frontend/core/src/components/page-list/use-block-suite-page-preview.ts b/packages/frontend/core/src/components/page-list/use-block-suite-page-preview.ts index e9230eb171..641bfa4c2c 100644 --- a/packages/frontend/core/src/components/page-list/use-block-suite-page-preview.ts +++ b/packages/frontend/core/src/components/page-list/use-block-suite-page-preview.ts @@ -1,13 +1,13 @@ -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import type { Atom } from 'jotai'; import { atom } from 'jotai'; const MAX_PREVIEW_LENGTH = 150; const MAX_SEARCH_BLOCK_COUNT = 30; -const weakMap = new WeakMap>(); +const weakMap = new WeakMap>(); -export const getPagePreviewText = (page: Page) => { +export const getPagePreviewText = (page: Doc) => { const pageRoot = page.root; if (!pageRoot) { return ''; @@ -56,7 +56,7 @@ export const getPagePreviewText = (page: Page) => { const emptyAtom = atom(''); -export function useBlockSuitePagePreview(page: Page | null): Atom { +export function useBlockSuitePagePreview(page: Doc | null): Atom { if (page === null) { return emptyAtom; } else if (weakMap.has(page)) { diff --git a/packages/frontend/core/src/components/page-list/use-block-suite-workspace-page.ts b/packages/frontend/core/src/components/page-list/use-block-suite-workspace-page.ts index d375a566c5..21e940182a 100644 --- a/packages/frontend/core/src/components/page-list/use-block-suite-workspace-page.ts +++ b/packages/frontend/core/src/components/page-list/use-block-suite-workspace-page.ts @@ -1,26 +1,26 @@ import { DisposableGroup } from '@blocksuite/global/utils'; -import type { Page, Workspace } from '@blocksuite/store'; +import type { Doc, Workspace } from '@blocksuite/store'; import { useEffect, useState } from 'react'; export function useBlockSuiteWorkspacePage( blockSuiteWorkspace: Workspace, pageId: string | null -): Page | null { +): Doc | null { const [page, setPage] = useState( - pageId ? blockSuiteWorkspace.getPage(pageId) : null + pageId ? blockSuiteWorkspace.getDoc(pageId) : null ); useEffect(() => { const group = new DisposableGroup(); group.add( - blockSuiteWorkspace.slots.pageAdded.on(id => { + blockSuiteWorkspace.slots.docAdded.on(id => { if (pageId === id) { - setPage(blockSuiteWorkspace.getPage(id)); + setPage(blockSuiteWorkspace.getDoc(id)); } }) ); group.add( - blockSuiteWorkspace.slots.pageRemoved.on(id => { + blockSuiteWorkspace.slots.docRemoved.on(id => { if (pageId === id) { setPage(null); } @@ -39,7 +39,7 @@ export function useBlockSuiteWorkspacePage( useEffect(() => { if (page?.id !== pageId) { - setPage(pageId ? blockSuiteWorkspace.getPage(pageId) : null); + setPage(pageId ? blockSuiteWorkspace.getDoc(pageId) : null); } }, [blockSuiteWorkspace, page?.id, pageId]); diff --git a/packages/frontend/core/src/components/page-list/use-collection-manager.ts b/packages/frontend/core/src/components/page-list/use-collection-manager.ts index d7207cc01f..ad82f1e5cd 100644 --- a/packages/frontend/core/src/components/page-list/use-collection-manager.ts +++ b/packages/frontend/core/src/components/page-list/use-collection-manager.ts @@ -1,5 +1,5 @@ import type { Collection, Filter, VariableMap } from '@affine/env/filter'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import { evalFilterList } from './filter'; @@ -20,7 +20,7 @@ export const filterByFilterList = (filterList: Filter[], varMap: VariableMap) => evalFilterList(filterList, varMap); export type PageDataForFilter = { - meta: PageMeta; + meta: DocMeta; publicMode: undefined | 'page' | 'edgeless'; }; diff --git a/packages/frontend/core/src/components/page-list/use-filtered-page-metas.tsx b/packages/frontend/core/src/components/page-list/use-filtered-page-metas.tsx index af4ef3e1b6..92346d0d60 100644 --- a/packages/frontend/core/src/components/page-list/use-filtered-page-metas.tsx +++ b/packages/frontend/core/src/components/page-list/use-filtered-page-metas.tsx @@ -1,5 +1,5 @@ import type { Collection, Filter } from '@affine/env/filter'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import type { Workspace } from '@toeverything/infra'; import { useMemo } from 'react'; @@ -8,7 +8,7 @@ import { filterPage, filterPageByRules } from './use-collection-manager'; export const useFilteredPageMetas = ( workspace: Workspace, - pageMetas: PageMeta[], + pageMetas: DocMeta[], options: { trash?: boolean; filters?: Filter[]; diff --git a/packages/frontend/core/src/components/page-list/use-tag-metas.ts b/packages/frontend/core/src/components/page-list/use-tag-metas.ts index 4e08f22bf1..4d720973ba 100644 --- a/packages/frontend/core/src/components/page-list/use-tag-metas.ts +++ b/packages/frontend/core/src/components/page-list/use-tag-metas.ts @@ -1,14 +1,11 @@ -import type { PageMeta, Tag, Workspace } from '@blocksuite/store'; +import type { DocMeta, Tag, Workspace } from '@blocksuite/store'; import { useCallback, useMemo } from 'react'; interface TagUsageCounts { [key: string]: number; } -export function useTagMetas( - currentWorkspace: Workspace, - pageMetas: PageMeta[] -) { +export function useTagMetas(currentWorkspace: Workspace, pageMetas: DocMeta[]) { const tags = useMemo(() => { return currentWorkspace.meta.properties.tags?.options || []; }, [currentWorkspace]); diff --git a/packages/frontend/core/src/components/page-list/view/edit-collection/edit-collection.tsx b/packages/frontend/core/src/components/page-list/view/edit-collection/edit-collection.tsx index eec39d4379..4840b7c5fe 100644 --- a/packages/frontend/core/src/components/page-list/view/edit-collection/edit-collection.tsx +++ b/packages/frontend/core/src/components/page-list/view/edit-collection/edit-collection.tsx @@ -6,7 +6,7 @@ import { } from '@affine/component'; import type { Collection } from '@affine/env/filter'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { PageMeta, Workspace } from '@blocksuite/store'; +import type { DocMeta, Workspace } from '@blocksuite/store'; import type { DialogContentProps } from '@radix-ui/react-dialog'; import { type ReactNode, useCallback, useMemo, useState } from 'react'; @@ -198,13 +198,13 @@ export const EditCollection = ({ }; export type AllPageListConfig = { - allPages: PageMeta[]; + allPages: DocMeta[]; workspace: Workspace; isEdgeless: (id: string) => boolean; /** * Return `undefined` if the page is not public */ getPublicMode: (id: string) => undefined | 'page' | 'edgeless'; - getPage: (id: string) => PageMeta | undefined; - favoriteRender: (page: PageMeta) => ReactNode; + getPage: (id: string) => DocMeta | undefined; + favoriteRender: (page: DocMeta) => ReactNode; }; diff --git a/packages/frontend/core/src/components/page-list/view/edit-collection/pages-mode.tsx b/packages/frontend/core/src/components/page-list/view/edit-collection/pages-mode.tsx index 69e5f56329..9eca9e40ac 100644 --- a/packages/frontend/core/src/components/page-list/view/edit-collection/pages-mode.tsx +++ b/packages/frontend/core/src/components/page-list/view/edit-collection/pages-mode.tsx @@ -2,7 +2,7 @@ import { Menu } from '@affine/component'; import type { Collection } from '@affine/env/filter'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { FilterIcon } from '@blocksuite/icons'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import clsx from 'clsx'; import { type ReactNode, useCallback } from 'react'; @@ -56,7 +56,7 @@ export const PagesMode = ({ }, [collection, updateCollection]); const pageOperationsRenderer = useCallback( (item: ListItem) => { - const page = item as PageMeta; + const page = item as DocMeta; return allPageListConfig.favoriteRender(page); }, [allPageListConfig] diff --git a/packages/frontend/core/src/components/page-list/view/edit-collection/rules-mode.tsx b/packages/frontend/core/src/components/page-list/view/edit-collection/rules-mode.tsx index 8cbdf65922..b60d937549 100644 --- a/packages/frontend/core/src/components/page-list/view/edit-collection/rules-mode.tsx +++ b/packages/frontend/core/src/components/page-list/view/edit-collection/rules-mode.tsx @@ -8,7 +8,7 @@ import { PlusIcon, ToggleCollapseIcon, } from '@blocksuite/icons'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import clsx from 'clsx'; import { type ReactNode, useCallback, useEffect, useState } from 'react'; @@ -38,8 +38,8 @@ export const RulesMode = ({ }) => { const t = useAFFiNEI18N(); const [showPreview, setShowPreview] = useState(true); - const allowListPages: PageMeta[] = []; - const rulesPages: PageMeta[] = []; + const allowListPages: DocMeta[] = []; + const rulesPages: DocMeta[] = []; const [showTips, setShowTips] = useState(false); useEffect(() => { setShowTips(!localStorage.getItem('hide-rules-mode-include-page-tips')); @@ -85,7 +85,7 @@ export const RulesMode = ({ ); const operationsRenderer = useCallback( (item: ListItem) => { - const page = item as PageMeta; + const page = item as DocMeta; return allPageListConfig.favoriteRender(page); }, [allPageListConfig] diff --git a/packages/frontend/core/src/components/page-list/view/edit-collection/select-page.tsx b/packages/frontend/core/src/components/page-list/view/edit-collection/select-page.tsx index f64b709303..3b189839a1 100644 --- a/packages/frontend/core/src/components/page-list/view/edit-collection/select-page.tsx +++ b/packages/frontend/core/src/components/page-list/view/edit-collection/select-page.tsx @@ -2,7 +2,7 @@ import { Button, Menu } from '@affine/component'; import { Trans } from '@affine/i18n'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { FilterIcon } from '@blocksuite/icons'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import clsx from 'clsx'; import { useCallback, useState } from 'react'; @@ -53,7 +53,7 @@ export const SelectPage = ({ const operationsRenderer = useCallback( (item: ListItem) => { - const page = item as PageMeta; + const page = item as DocMeta; return allPageListConfig.favoriteRender(page); }, [allPageListConfig] diff --git a/packages/frontend/core/src/components/page-list/view/edit-collection/use-search.tsx b/packages/frontend/core/src/components/page-list/view/edit-collection/use-search.tsx index 55e63e8ec1..dd70c8fa77 100644 --- a/packages/frontend/core/src/components/page-list/view/edit-collection/use-search.tsx +++ b/packages/frontend/core/src/components/page-list/view/edit-collection/use-search.tsx @@ -1,7 +1,7 @@ -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import { useState } from 'react'; -export const useSearch = (list: PageMeta[]) => { +export const useSearch = (list: DocMeta[]) => { const [value, onChange] = useState(''); return { searchText: value, diff --git a/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsx b/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsx index 3f37e1c684..d9dd666948 100644 --- a/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsx +++ b/packages/frontend/core/src/components/pure/cmdk/data-hooks.tsx @@ -1,6 +1,6 @@ import { - useBlockSuitePageMeta, - usePageMetaHelper, + useBlockSuiteDocMeta, + useDocMetaHelper, } from '@affine/core/hooks/use-block-suite-page-meta'; import { useGetBlockSuiteWorkspacePageTitle } from '@affine/core/hooks/use-block-suite-workspace-page-title'; import { useJournalHelper } from '@affine/core/hooks/use-journal'; @@ -14,9 +14,9 @@ import { TodayIcon, ViewLayersIcon, } from '@blocksuite/icons'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import { - Page, + Doc, PageRecordList, useLiveData, Workspace, @@ -79,7 +79,7 @@ function getAllCommand(context: CommandContext) { const useWorkspacePages = () => { const workspace = useService(Workspace); - const pages = useBlockSuitePageMeta(workspace.blockSuiteWorkspace); + const pages = useBlockSuiteDocMeta(workspace.blockSuiteWorkspace); return pages; }; @@ -92,13 +92,13 @@ const useRecentPages = () => { const page = pages.find(page => page.id === pageId); return page; }) - .filter((p): p is PageMeta => !!p); + .filter((p): p is DocMeta => !!p); }, [recentPageIds, pages]); }; export const pageToCommand = ( category: CommandCategory, - page: PageMeta, + page: DocMeta, navigationHelper: ReturnType, getPageTitle: ReturnType, isPageJournal: (pageId: string) => boolean, @@ -152,7 +152,7 @@ export const usePageCommands = () => { const pages = useWorkspacePages(); const workspace = useService(Workspace); const pageHelper = usePageHelper(workspace.blockSuiteWorkspace); - const pageMetaHelper = usePageMetaHelper(workspace.blockSuiteWorkspace); + const pageMetaHelper = useDocMetaHelper(workspace.blockSuiteWorkspace); const query = useAtomValue(cmdkQueryAtom); const navigationHelper = useNavigateHelper(); const journalHelper = useJournalHelper(workspace.blockSuiteWorkspace); @@ -260,7 +260,7 @@ export const usePageCommands = () => { run: async () => { const page = pageHelper.createPage(); page.load(); - pageMetaHelper.setPageTitle(page.id, query); + pageMetaHelper.setDocTitle(page.id, query); }, icon: , }); @@ -275,7 +275,7 @@ export const usePageCommands = () => { run: async () => { const page = pageHelper.createEdgeless(); page.load(); - pageMetaHelper.setPageTitle(page.id, query); + pageMetaHelper.setDocTitle(page.id, query); }, icon: , }); @@ -357,7 +357,7 @@ export const useCMDKCommandGroups = () => { const pageCommands = usePageCommands(); const collectionCommands = useCollectionsCommands(); - const currentPage = useServiceOptional(Page); + const currentPage = useServiceOptional(Doc); const currentPageMode = useLiveData(currentPage?.mode); const affineCommands = useMemo(() => { return getAllCommand({ diff --git a/packages/frontend/core/src/components/pure/cmdk/main.tsx b/packages/frontend/core/src/components/pure/cmdk/main.tsx index 626ceb8615..e3cdbed3fb 100644 --- a/packages/frontend/core/src/components/pure/cmdk/main.tsx +++ b/packages/frontend/core/src/components/pure/cmdk/main.tsx @@ -3,7 +3,7 @@ import { formatDate } from '@affine/core/components/page-list'; import { useSyncEngineStatus } from '@affine/core/hooks/affine/use-sync-engine-status'; import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import { SyncEngineStep } from '@toeverything/infra'; import type { CommandCategory } from '@toeverything/infra/command'; import clsx from 'clsx'; @@ -155,7 +155,7 @@ export const CMDKContainer = ({ open: boolean; className?: string; query: string; - pageMeta?: PageMeta; + pageMeta?: DocMeta; groups: ReturnType; onQueryChange: (query: string) => void; }>) => { @@ -235,7 +235,7 @@ const CMDKQuickSearchModalInner = ({ pageMeta, open, ...props -}: CMDKModalProps & { pageMeta?: PageMeta }) => { +}: CMDKModalProps & { pageMeta?: DocMeta }) => { const [query, setQuery] = useAtom(cmdkQueryAtom); useLayoutEffect(() => { if (open) { @@ -261,7 +261,7 @@ export const CMDKQuickSearchModal = ({ pageMeta, open, ...props -}: CMDKModalProps & { pageMeta?: PageMeta }) => { +}: CMDKModalProps & { pageMeta?: DocMeta }) => { return ( }> diff --git a/packages/frontend/core/src/components/pure/help-island/index.tsx b/packages/frontend/core/src/components/pure/help-island/index.tsx index 325f927c05..5fad3de39c 100644 --- a/packages/frontend/core/src/components/pure/help-island/index.tsx +++ b/packages/frontend/core/src/components/pure/help-island/index.tsx @@ -2,7 +2,7 @@ import { Tooltip } from '@affine/component/ui/tooltip'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { CloseIcon, NewIcon } from '@blocksuite/icons'; import { useLiveData, useServiceOptional } from '@toeverything/infra'; -import { Page } from '@toeverything/infra'; +import { Doc } from '@toeverything/infra'; import { useSetAtom } from 'jotai/react'; import { useCallback, useState } from 'react'; @@ -28,7 +28,7 @@ type IslandItemNames = 'whatNew' | 'contact' | 'shortcuts'; const showList = environment.isDesktop ? DESKTOP_SHOW_LIST : DEFAULT_SHOW_LIST; export const HelpIsland = () => { - const page = useServiceOptional(Page); + const page = useServiceOptional(Doc); const pageId = page?.id; const mode = useLiveData(page?.mode); const setOpenSettingModalAtom = useSetAtom(openSettingModalAtom); diff --git a/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx b/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx index c02bd05ffd..815d780086 100644 --- a/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx +++ b/packages/frontend/core/src/components/pure/trash-page-footer/index.tsx @@ -1,7 +1,7 @@ import { Button } from '@affine/component/ui/button'; import { ConfirmModal } from '@affine/component/ui/modal'; import { Tooltip } from '@affine/component/ui/tooltip'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { assertExists } from '@blocksuite/global/utils'; import { DeleteIcon, ResetIcon } from '@blocksuite/icons'; @@ -23,7 +23,7 @@ export const TrashPageFooter = ({ pageId }: { pageId: string }) => { ); assertExists(workspace); const blockSuiteWorkspace = workspace.blockSuiteWorkspace; - const pageMeta = useBlockSuitePageMeta(blockSuiteWorkspace).find( + const pageMeta = useBlockSuiteDocMeta(blockSuiteWorkspace).find( meta => meta.id === pageId ); assertExists(pageMeta); @@ -45,7 +45,7 @@ export const TrashPageFooter = ({ pageId }: { pageId: string }) => { const onConfirmDelete = useCallback(() => { jumpToSubPath(workspace.id, WorkspaceSubPath.ALL); - blockSuiteWorkspace.removePage(pageId); + blockSuiteWorkspace.removeDoc(pageId); toast(t['com.affine.toastMessage.permanentlyDeleted']()); }, [blockSuiteWorkspace, jumpToSubPath, pageId, workspace.id, t]); diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/collections-list.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/collections-list.tsx index 911e3ee03f..242ce86d00 100644 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/collections-list.tsx +++ b/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/collections-list.tsx @@ -11,7 +11,7 @@ import { CollectionService } from '@affine/core/modules/collection'; import type { Collection, DeleteCollectionInfo } from '@affine/env/filter'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { MoreHorizontalIcon, ViewLayersIcon } from '@blocksuite/icons'; -import type { PageMeta, Workspace } from '@blocksuite/store'; +import type { DocMeta, Workspace } from '@blocksuite/store'; import { useDroppable } from '@dnd-kit/core'; import * as Collapsible from '@radix-ui/react-collapsible'; import { useService } from '@toeverything/infra'; @@ -20,7 +20,7 @@ import { useCallback, useMemo, useState } from 'react'; import { useAllPageListConfig } from '../../../../hooks/affine/use-all-page-list-config'; import { getDropItemId } from '../../../../hooks/affine/use-sidebar-drag'; -import { useBlockSuitePageMeta } from '../../../../hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '../../../../hooks/use-block-suite-page-meta'; import { Workbench } from '../../../../modules/workbench'; import { WorkbenchLink } from '../../../../modules/workbench/workbench-link'; import type { CollectionsListProps } from '../index'; @@ -34,7 +34,7 @@ const CollectionRenderer = ({ info, }: { collection: Collection; - pages: PageMeta[]; + pages: DocMeta[]; workspace: Workspace; info: DeleteCollectionInfo; }) => { @@ -173,7 +173,7 @@ export const CollectionsList = ({ info, onCreate, }: CollectionsListProps) => { - const metas = useBlockSuitePageMeta(workspace); + const metas = useBlockSuiteDocMeta(workspace); const collections = useLiveData(useService(CollectionService).collections); const t = useAFFiNEI18N(); if (collections.length === 0) { diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/page.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/page.tsx index dee7c8fc3b..5f82e6e7ef 100644 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/page.tsx +++ b/packages/frontend/core/src/components/pure/workspace-slider-bar/collections/page.tsx @@ -2,7 +2,7 @@ import { MenuItem as CollectionItem } from '@affine/component/app-sidebar'; import { useBlockSuitePageReferences } from '@affine/core/hooks/use-block-suite-page-references'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { EdgelessIcon, PageIcon } from '@blocksuite/icons'; -import type { PageMeta, Workspace } from '@blocksuite/store'; +import type { DocMeta, Workspace } from '@blocksuite/store'; import { useDraggable } from '@dnd-kit/core'; import * as Collapsible from '@radix-ui/react-collapsible'; import { PageRecordList, useLiveData, useService } from '@toeverything/infra'; @@ -23,11 +23,11 @@ export const Page = ({ inAllowList, removeFromAllowList, }: { - page: PageMeta; + page: DocMeta; inAllowList: boolean; removeFromAllowList: (id: string) => void; workspace: Workspace; - allPageMeta: Record; + allPageMeta: Record; }) => { const [collapsed, setCollapsed] = React.useState(true); const params = useParams(); diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/components/postfix-item.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/components/postfix-item.tsx index 9f8198b764..d4999b92f6 100644 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/components/postfix-item.tsx +++ b/packages/frontend/core/src/components/pure/workspace-slider-bar/components/postfix-item.tsx @@ -1,6 +1,6 @@ import { toast } from '@affine/component'; import { RenameModal } from '@affine/component/rename-modal'; -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import type { Workspace } from '@blocksuite/store'; import { useCallback, useState } from 'react'; @@ -23,15 +23,15 @@ export const PostfixItem = ({ ...props }: PostfixItemProps) => { const { workspace, pageId, pageTitle } = props; const t = useAFFiNEI18N(); const [open, setOpen] = useState(false); - const { setPageTitle } = usePageMetaHelper(workspace); + const { setDocTitle } = useDocMetaHelper(workspace); const handleRename = useCallback( (newName: string) => { - setPageTitle(pageId, newName); + setDocTitle(pageId, newName); setOpen(false); toast(t['com.affine.toastMessage.rename']()); }, - [pageId, setPageTitle, t] + [pageId, setDocTitle, t] ); return ( diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx index 5a0737b83e..a47710d8d8 100644 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx +++ b/packages/frontend/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx @@ -2,7 +2,7 @@ import { MenuLinkItem } from '@affine/component/app-sidebar'; import { useBlockSuitePageReferences } from '@affine/core/hooks/use-block-suite-page-references'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { EdgelessIcon, PageIcon } from '@blocksuite/icons'; -import { type PageMeta, type Workspace } from '@blocksuite/store'; +import { type DocMeta, type Workspace } from '@blocksuite/store'; import * as Collapsible from '@radix-ui/react-collapsible'; import { PageRecordList, useLiveData, useService } from '@toeverything/infra'; import { useMemo, useState } from 'react'; @@ -13,7 +13,7 @@ import { PostfixItem } from './postfix-item'; export interface ReferencePageProps { workspace: Workspace; pageId: string; - metaMapping: Record; + metaMapping: Record; parentIds: Set; } diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/add-favourite-button.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/add-favourite-button.tsx index feb1311775..fb13fc9549 100644 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/add-favourite-button.tsx +++ b/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/add-favourite-button.tsx @@ -1,6 +1,6 @@ import { IconButton } from '@affine/component/ui/button'; import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks'; -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { PlusIcon } from '@blocksuite/icons'; import type { Workspace } from '@blocksuite/store'; @@ -16,7 +16,7 @@ export const AddFavouriteButton = ({ pageId, }: AddFavouriteButtonProps) => { const { createPage, createLinkedPage } = usePageHelper(workspace); - const { setPageMeta } = usePageMetaHelper(workspace); + const { setDocMeta } = useDocMetaHelper(workspace); const handleAddFavorite = useAsyncCallback( async e => { if (pageId) { @@ -26,10 +26,10 @@ export const AddFavouriteButton = ({ } else { const page = createPage(); page.load(); - setPageMeta(page.id, { favorite: true }); + setDocMeta(page.id, { favorite: true }); } }, - [pageId, createLinkedPage, createPage, setPageMeta] + [pageId, createLinkedPage, createPage, setDocMeta] ); return ( diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/favorite-list.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/favorite-list.tsx index 04e7a3ece0..189cc6092f 100644 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/favorite-list.tsx +++ b/packages/frontend/core/src/components/pure/workspace-slider-bar/favorite/favorite-list.tsx @@ -1,5 +1,5 @@ -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; -import type { PageMeta } from '@blocksuite/store'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import type { DocMeta } from '@blocksuite/store'; import { useDroppable } from '@dnd-kit/core'; import { useMemo } from 'react'; @@ -12,7 +12,7 @@ import * as styles from './styles.css'; const emptyPageIdSet = new Set(); export const FavoriteList = ({ workspace }: FavoriteListProps) => { - const metas = useBlockSuitePageMeta(workspace); + const metas = useBlockSuiteDocMeta(workspace); const dropItemId = getDropItemId('favorites'); const favoriteList = useMemo( @@ -27,7 +27,7 @@ export const FavoriteList = ({ workspace }: FavoriteListProps) => { acc[meta.id] = meta; return acc; }, - {} as Record + {} as Record ), [metas] ); diff --git a/packages/frontend/core/src/components/root-app-sidebar/index.tsx b/packages/frontend/core/src/components/root-app-sidebar/index.tsx index 6227f40a77..f2e5a92138 100644 --- a/packages/frontend/core/src/components/root-app-sidebar/index.tsx +++ b/packages/frontend/core/src/components/root-app-sidebar/index.tsx @@ -17,7 +17,7 @@ import { CollectionService } from '@affine/core/modules/collection'; import { apis, events } from '@affine/electron-api'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { FolderIcon, SettingsIcon } from '@blocksuite/icons'; -import { type Page } from '@blocksuite/store'; +import { type Doc } from '@blocksuite/store'; import { useDroppable } from '@dnd-kit/core'; import { useLiveData, useService, type Workspace } from '@toeverything/infra'; import { useAtom, useAtomValue } from 'jotai'; @@ -57,7 +57,7 @@ export type RootAppSidebarProps = { onOpenSettingModal: () => void; currentWorkspace: Workspace; openPage: (pageId: string) => void; - createPage: () => Page; + createPage: () => Doc; paths: { all: (workspaceId: string) => string; trash: (workspaceId: string) => string; @@ -114,7 +114,7 @@ export const RootAppSidebar = ({ const onClickNewPage = useAsyncCallback(async () => { const page = createPage(); - page.waitForLoaded(); + page.load(); openPage(page.id); }, [createPage, openPage]); diff --git a/packages/frontend/core/src/components/root-app-sidebar/journal-button.tsx b/packages/frontend/core/src/components/root-app-sidebar/journal-button.tsx index 09a02aa309..09e6ac9dee 100644 --- a/packages/frontend/core/src/components/root-app-sidebar/journal-button.tsx +++ b/packages/frontend/core/src/components/root-app-sidebar/journal-button.tsx @@ -6,7 +6,7 @@ import { import type { BlockSuiteWorkspace } from '@affine/core/shared'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { TodayIcon, TomorrowIcon, YesterdayIcon } from '@blocksuite/icons'; -import { Page, useServiceOptional } from '@toeverything/infra'; +import { Doc, useServiceOptional } from '@toeverything/infra'; import { useParams } from 'react-router-dom'; interface AppSidebarJournalButtonProps { @@ -17,7 +17,7 @@ export const AppSidebarJournalButton = ({ workspace, }: AppSidebarJournalButtonProps) => { const t = useAFFiNEI18N(); - const currentPage = useServiceOptional(Page); + const currentPage = useServiceOptional(Doc); const { openToday } = useJournalRouteHelper(workspace); const { journalDate, isJournal } = useJournalInfoHelper( workspace, diff --git a/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-helper.spec.tsx b/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-helper.spec.tsx index 33d470807f..724297eccd 100644 --- a/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-helper.spec.tsx +++ b/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-helper.spec.tsx @@ -10,16 +10,15 @@ import { initEmptyPage, ServiceProviderContext } from '@toeverything/infra'; import type { PropsWithChildren } from 'react'; import { beforeEach, describe, expect, test, vi } from 'vitest'; -import { useBlockSuitePageMeta } from '../use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '../use-block-suite-page-meta'; import { useBlockSuiteWorkspaceHelper } from '../use-block-suite-workspace-helper'; const configureTestingWorkspace = async () => { const { workspace } = await configureTestingEnvironment(); const blockSuiteWorkspace = workspace.blockSuiteWorkspace; - // await initEmptyPage(blockSuiteWorkspace.createPage({ id: 'page-0' })); - initEmptyPage(blockSuiteWorkspace.createPage({ id: 'page1' })); - initEmptyPage(blockSuiteWorkspace.createPage({ id: 'page2' })); + initEmptyPage(blockSuiteWorkspace.createDoc({ id: 'page1' })); + initEmptyPage(blockSuiteWorkspace.createDoc({ id: 'page2' })); return workspace; }; @@ -43,7 +42,7 @@ describe('useBlockSuiteWorkspaceHelper', () => { const blockSuiteWorkspace = workspace.blockSuiteWorkspace; const Wrapper = getWrapper(workspace); - expect(blockSuiteWorkspace.meta.pageMetas.length).toBe(3); + expect(blockSuiteWorkspace.meta.docMetas.length).toBe(3); const helperHook = renderHook( () => useBlockSuiteWorkspaceHelper(blockSuiteWorkspace), { @@ -51,17 +50,17 @@ describe('useBlockSuiteWorkspaceHelper', () => { } ); const pageMetaHook = renderHook( - () => useBlockSuitePageMeta(blockSuiteWorkspace), + () => useBlockSuiteDocMeta(blockSuiteWorkspace), { wrapper: Wrapper, } ); await new Promise(resolve => setTimeout(resolve)); expect(pageMetaHook.result.current.length).toBe(3); - expect(blockSuiteWorkspace.meta.pageMetas.length).toBe(3); - const page = helperHook.result.current.createPage('page4'); + expect(blockSuiteWorkspace.meta.docMetas.length).toBe(3); + const page = helperHook.result.current.createDoc('page4'); expect(page.id).toBe('page4'); - expect(blockSuiteWorkspace.meta.pageMetas.length).toBe(4); + expect(blockSuiteWorkspace.meta.docMetas.length).toBe(4); pageMetaHook.rerender(); expect(pageMetaHook.result.current.length).toBe(4); }); diff --git a/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-page-title.spec.tsx b/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-page-title.spec.tsx index 86a42b3a7e..d638dc6857 100644 --- a/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-page-title.spec.tsx +++ b/packages/frontend/core/src/hooks/__tests__/use-block-suite-workspace-page-title.spec.tsx @@ -43,7 +43,7 @@ describe('useBlockSuiteWorkspacePageTitle', () => { ); expect(await findByText('title: Untitled')).toBeDefined(); - workspace.blockSuiteWorkspace.setPageMeta(page.id, { title: '1' }); + workspace.blockSuiteWorkspace.setDocMeta(page.id, { title: '1' }); rerender( diff --git a/packages/frontend/core/src/hooks/affine/use-all-page-list-config.tsx b/packages/frontend/core/src/hooks/affine/use-all-page-list-config.tsx index e83ab7673f..73818ed627 100644 --- a/packages/frontend/core/src/hooks/affine/use-all-page-list-config.tsx +++ b/packages/frontend/core/src/hooks/affine/use-all-page-list-config.tsx @@ -3,9 +3,9 @@ import { type AllPageListConfig, FavoriteTag, } from '@affine/core/components/page-list'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import { Workspace } from '@toeverything/infra'; import { useService } from '@toeverything/infra/di'; import { useCallback, useMemo } from 'react'; @@ -18,7 +18,7 @@ export const useAllPageListConfig = () => { const currentWorkspace = useService(Workspace); const { getPublicMode } = usePublicPages(currentWorkspace); const workspace = currentWorkspace.blockSuiteWorkspace; - const pageMetas = useBlockSuitePageMeta(workspace); + const pageMetas = useBlockSuiteDocMeta(workspace); const { isPreferredEdgeless } = usePageHelper(workspace); const pageMap = useMemo( () => Object.fromEntries(pageMetas.map(page => [page.id, page])), @@ -29,7 +29,7 @@ export const useAllPageListConfig = () => { ); const t = useAFFiNEI18N(); const onToggleFavoritePage = useCallback( - (page: PageMeta) => { + (page: DocMeta) => { const status = page.favorite; toggleFavorite(page.id); toast( diff --git a/packages/frontend/core/src/hooks/affine/use-block-suite-meta-helper.ts b/packages/frontend/core/src/hooks/affine/use-block-suite-meta-helper.ts index 7ba11a0aca..23cd9fd84b 100644 --- a/packages/frontend/core/src/hooks/affine/use-block-suite-meta-helper.ts +++ b/packages/frontend/core/src/hooks/affine/use-block-suite-meta-helper.ts @@ -1,5 +1,5 @@ import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks'; -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { useBlockSuiteWorkspaceHelper } from '@affine/core/hooks/use-block-suite-workspace-helper'; import { CollectionService } from '@affine/core/modules/collection'; import { PageRecordList, useService } from '@toeverything/infra'; @@ -13,76 +13,76 @@ import { useReferenceLinkHelper } from './use-reference-link-helper'; export function useBlockSuiteMetaHelper( blockSuiteWorkspace: BlockSuiteWorkspace ) { - const { setPageMeta, getPageMeta, setPageReadonly, setPageTitle } = - usePageMetaHelper(blockSuiteWorkspace); + const { setDocMeta, getDocMeta, setDocReadonly, setDocTitle } = + useDocMetaHelper(blockSuiteWorkspace); const { addReferenceLink } = useReferenceLinkHelper(blockSuiteWorkspace); - const { createPage } = useBlockSuiteWorkspaceHelper(blockSuiteWorkspace); + const { createDoc } = useBlockSuiteWorkspaceHelper(blockSuiteWorkspace); const { openPage } = useNavigateHelper(); const collectionService = useService(CollectionService); const pageRecordList = useService(PageRecordList); const addToFavorite = useCallback( (pageId: string) => { - setPageMeta(pageId, { + setDocMeta(pageId, { favorite: true, }); }, - [setPageMeta] + [setDocMeta] ); const removeFromFavorite = useCallback( (pageId: string) => { - setPageMeta(pageId, { + setDocMeta(pageId, { favorite: false, }); }, - [setPageMeta] + [setDocMeta] ); const toggleFavorite = useCallback( (pageId: string) => { - const { favorite } = getPageMeta(pageId) ?? {}; - setPageMeta(pageId, { + const { favorite } = getDocMeta(pageId) ?? {}; + setDocMeta(pageId, { favorite: !favorite, }); }, - [getPageMeta, setPageMeta] + [getDocMeta, setDocMeta] ); // TODO-Doma // "Remove" may cause ambiguity here. Consider renaming as "moveToTrash". const removeToTrash = useCallback( (pageId: string) => { - setPageMeta(pageId, { + setDocMeta(pageId, { trash: true, trashDate: Date.now(), trashRelate: undefined, }); - setPageReadonly(pageId, true); + setDocReadonly(pageId, true); collectionService.deletePagesFromCollections([pageId]); }, - [collectionService, setPageMeta, setPageReadonly] + [collectionService, setDocMeta, setDocReadonly] ); const restoreFromTrash = useCallback( (pageId: string) => { - const { trashRelate } = getPageMeta(pageId) ?? {}; + const { trashRelate } = getDocMeta(pageId) ?? {}; if (trashRelate) { addReferenceLink(trashRelate, pageId); } - setPageMeta(pageId, { + setDocMeta(pageId, { trash: false, trashDate: undefined, trashRelate: undefined, }); - setPageReadonly(pageId, false); + setDocReadonly(pageId, false); }, - [addReferenceLink, getPageMeta, setPageMeta, setPageReadonly] + [addReferenceLink, getDocMeta, setDocMeta, setDocReadonly] ); const permanentlyDeletePage = useCallback( (pageId: string) => { - blockSuiteWorkspace.removePage(pageId); + blockSuiteWorkspace.removeDoc(pageId); }, [blockSuiteWorkspace] ); @@ -92,11 +92,11 @@ export function useBlockSuiteMetaHelper( */ const publicPage = useCallback( (pageId: string) => { - setPageMeta(pageId, { + setDocMeta(pageId, { isPublic: true, }); }, - [setPageMeta] + [setDocMeta] ); /** @@ -104,21 +104,21 @@ export function useBlockSuiteMetaHelper( */ const cancelPublicPage = useCallback( (pageId: string) => { - setPageMeta(pageId, { + setDocMeta(pageId, { isPublic: false, }); }, - [setPageMeta] + [setDocMeta] ); const duplicate = useAsyncCallback( async (pageId: string, openPageAfterDuplication: boolean = true) => { const currentPageMode = pageRecordList.record(pageId).value?.mode.value; - const currentPageMeta = getPageMeta(pageId); - const newPage = createPage(); - const currentPage = blockSuiteWorkspace.getPage(pageId); + const currentPageMeta = getDocMeta(pageId); + const newPage = createDoc(); + const currentPage = blockSuiteWorkspace.getDoc(pageId); - newPage.waitForLoaded(); + newPage.load(); if (!currentPageMeta || !currentPage) { return; } @@ -126,7 +126,7 @@ export function useBlockSuiteMetaHelper( const update = encodeStateAsUpdate(currentPage.spaceDoc); applyUpdate(newPage.spaceDoc, update); - setPageMeta(newPage.id, { + setDocMeta(newPage.id, { tags: currentPageMeta.tags, favorite: currentPageMeta.favorite, }); @@ -141,17 +141,17 @@ export function useBlockSuiteMetaHelper( pageRecordList .record(newPage.id) .value?.setMode(currentPageMode || 'page'); - setPageTitle(newPage.id, newPageTitle); + setDocTitle(newPage.id, newPageTitle); openPageAfterDuplication && openPage(blockSuiteWorkspace.id, newPage.id); }, [ blockSuiteWorkspace, - createPage, - getPageMeta, + createDoc, + getDocMeta, openPage, pageRecordList, - setPageMeta, - setPageTitle, + setDocMeta, + setDocTitle, ] ); diff --git a/packages/frontend/core/src/hooks/affine/use-export-page.ts b/packages/frontend/core/src/hooks/affine/use-export-page.ts index 56a5b1c9b1..fb8417cad9 100644 --- a/packages/frontend/core/src/hooks/affine/use-export-page.ts +++ b/packages/frontend/core/src/hooks/affine/use-export-page.ts @@ -5,13 +5,13 @@ import { import { pushNotificationAtom } from '@affine/component/notification-center'; import { apis } from '@affine/electron-api'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { PageService } from '@blocksuite/blocks'; +import type { PageRootService } from '@blocksuite/blocks'; import { HtmlTransformer, MarkdownTransformer, - type PageBlockModel, + type RootBlockModel, } from '@blocksuite/blocks'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import { useSetAtom } from 'jotai'; import { nanoid } from 'nanoid'; import { useCallback } from 'react'; @@ -19,27 +19,27 @@ import { useCallback } from 'react'; type ExportType = 'pdf' | 'html' | 'png' | 'markdown'; interface ExportHandlerOptions { - page: Page; + page: Doc; type: ExportType; } async function exportHandler({ page, type }: ExportHandlerOptions) { const editorRoot = document.querySelector('editor-host'); - let pageService: PageService | null = null; + let pageService: PageRootService | null = null; if (editorRoot) { - pageService = editorRoot.spec.getService('affine:page') as PageService; + pageService = editorRoot.spec.getService('affine:page'); } switch (type) { case 'html': - await HtmlTransformer.exportPage(page); + await HtmlTransformer.exportDoc(page); break; case 'markdown': - await MarkdownTransformer.exportPage(page); + await MarkdownTransformer.exportDoc(page); break; case 'pdf': - if (environment.isDesktop && page.meta.mode === 'page') { + if (environment.isDesktop && page.meta?.mode === 'page') { await apis?.export.savePDFFileAs( - (page.root as PageBlockModel).title.toString() + (page.root as RootBlockModel).title.toString() ); } else { if (!pageService) return; @@ -54,7 +54,7 @@ async function exportHandler({ page, type }: ExportHandlerOptions) { } } -export const useExportPage = (page: Page) => { +export const useExportPage = (page: Doc) => { const pushNotification = useSetAtom(pushNotificationAtom); const pushGlobalLoadingEvent = useSetAtom(pushGlobalLoadingEventAtom); const resolveGlobalLoadingEvent = useSetAtom(resolveGlobalLoadingEventAtom); diff --git a/packages/frontend/core/src/hooks/affine/use-reference-link-helper.ts b/packages/frontend/core/src/hooks/affine/use-reference-link-helper.ts index 81b914e4e4..6067c906a1 100644 --- a/packages/frontend/core/src/hooks/affine/use-reference-link-helper.ts +++ b/packages/frontend/core/src/hooks/affine/use-reference-link-helper.ts @@ -7,7 +7,7 @@ export function useReferenceLinkHelper( ) { const addReferenceLink = useCallback( (pageId: string, referenceId: string) => { - const page = blockSuiteWorkspace?.getPage(pageId); + const page = blockSuiteWorkspace?.getDoc(pageId); if (!page) { return; } diff --git a/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsx b/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsx index 2f71774444..f3919ea2b4 100644 --- a/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsx +++ b/packages/frontend/core/src/hooks/affine/use-register-blocksuite-editor-commands.tsx @@ -1,10 +1,10 @@ import { toast } from '@affine/component'; -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { WorkspaceFlavour } from '@affine/env/workspace'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { assertExists } from '@blocksuite/global/utils'; import { EdgelessIcon, HistoryIcon, PageIcon } from '@blocksuite/icons'; -import { Page, useLiveData, Workspace } from '@toeverything/infra'; +import { Doc, useLiveData, Workspace } from '@toeverything/infra'; import { PreconditionStrategy, registerAffineCommand, @@ -19,16 +19,16 @@ import { useExportPage } from './use-export-page'; import { useTrashModalHelper } from './use-trash-modal-helper'; export function useRegisterBlocksuiteEditorCommands() { - const page = useService(Page); + const page = useService(Doc); const pageId = page.id; const mode = useLiveData(page.mode); const t = useAFFiNEI18N(); const workspace = useService(Workspace); const blockSuiteWorkspace = workspace.blockSuiteWorkspace; - const { getPageMeta } = usePageMetaHelper(blockSuiteWorkspace); - const currentPage = blockSuiteWorkspace.getPage(pageId); + const { getDocMeta } = useDocMetaHelper(blockSuiteWorkspace); + const currentPage = blockSuiteWorkspace.getDoc(pageId); assertExists(currentPage); - const pageMeta = getPageMeta(pageId); + const pageMeta = getDocMeta(pageId); assertExists(pageMeta); const favorite = pageMeta.favorite ?? false; const trash = pageMeta.trash ?? false; diff --git a/packages/frontend/core/src/hooks/affine/use-sidebar-drag.ts b/packages/frontend/core/src/hooks/affine/use-sidebar-drag.ts index 8ceb1e5850..a671985e98 100644 --- a/packages/frontend/core/src/hooks/affine/use-sidebar-drag.ts +++ b/packages/frontend/core/src/hooks/affine/use-sidebar-drag.ts @@ -1,6 +1,6 @@ import { toast } from '@affine/component'; import type { DraggableTitleCellData } from '@affine/core/components/page-list'; -import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import type { DragEndEvent, UniqueIdentifier } from '@dnd-kit/core'; import { Workspace } from '@toeverything/infra'; @@ -74,7 +74,7 @@ export const useSidebarDrag = () => { const { setTrashModal } = useTrashModalHelper(workspace); const { addToFavorite, removeFromFavorite } = useBlockSuiteMetaHelper(workspace); - const { getPageMeta } = usePageMetaHelper(workspace); + const { getDocMeta } = useDocMetaHelper(workspace); const isDropArea = useCallback( (id: UniqueIdentifier | undefined, prefix: string) => { @@ -109,7 +109,7 @@ export const useSidebarDrag = () => { const processMoveToTrashDrag = useCallback( (e: DragEndEvent) => { const { pageId } = e.active.data.current as DraggableTitleCellData; - const pageTitle = getPageMeta(pageId)?.title ?? t['Untitled'](); + const pageTitle = getDocMeta(pageId)?.title ?? t['Untitled'](); processDrag(e, DropPrefix.SidebarTrash, pageId => { setTrashModal({ open: true, @@ -118,13 +118,13 @@ export const useSidebarDrag = () => { }); }); }, - [getPageMeta, processDrag, setTrashModal, t] + [getDocMeta, processDrag, setTrashModal, t] ); const processFavouritesDrag = useCallback( (e: DragEndEvent) => { const { pageId } = e.active.data.current as DraggableTitleCellData; - const isFavourited = getPageMeta(pageId)?.favorite; + const isFavourited = getDocMeta(pageId)?.favorite; const isFavouriteDrag = String(e.over?.id).startsWith( DropPrefix.SidebarFavorites ); @@ -136,7 +136,7 @@ export const useSidebarDrag = () => { toast(t['com.affine.cmdk.affine.editor.add-to-favourites']()); }); }, - [getPageMeta, processDrag, addToFavorite, t] + [getDocMeta, processDrag, addToFavorite, t] ); const processRemoveDrag = useCallback( diff --git a/packages/frontend/core/src/hooks/use-affine-adapter.ts b/packages/frontend/core/src/hooks/use-affine-adapter.ts index f055a71b35..d69af330c5 100644 --- a/packages/frontend/core/src/hooks/use-affine-adapter.ts +++ b/packages/frontend/core/src/hooks/use-affine-adapter.ts @@ -20,7 +20,7 @@ const useReactiveAdapter = (adapter: WorkspacePropertiesAdapter) => { } const disposables: (() => void)[] = []; disposables.push( - adapter.workspace.blockSuiteWorkspace.meta.pageMetasUpdated.on(observe) + adapter.workspace.blockSuiteWorkspace.meta.docMetaUpdated.on(observe) .dispose ); adapter.properties.observeDeep(observe); diff --git a/packages/frontend/core/src/hooks/use-all-block-suite-page-meta.ts b/packages/frontend/core/src/hooks/use-all-block-suite-page-meta.ts index 3869ce85fd..a775a22552 100644 --- a/packages/frontend/core/src/hooks/use-all-block-suite-page-meta.ts +++ b/packages/frontend/core/src/hooks/use-all-block-suite-page-meta.ts @@ -1,25 +1,25 @@ -import type { PageMeta, Workspace } from '@blocksuite/store'; +import type { DocMeta, Workspace } from '@blocksuite/store'; import type { Atom } from 'jotai'; import { atom, useAtomValue } from 'jotai'; -const weakMap = new WeakMap>(); +const weakMap = new WeakMap>(); // this hook is extracted from './use-block-suite-page-meta.ts' to avoid circular dependency -export function useAllBlockSuitePageMeta( +export function useAllBlockSuiteDocMeta( blockSuiteWorkspace: Workspace -): PageMeta[] { +): DocMeta[] { if (!weakMap.has(blockSuiteWorkspace)) { - const baseAtom = atom(blockSuiteWorkspace.meta.pageMetas); + const baseAtom = atom(blockSuiteWorkspace.meta.docMetas); weakMap.set(blockSuiteWorkspace, baseAtom); baseAtom.onMount = set => { - set(blockSuiteWorkspace.meta.pageMetas); - const dispose = blockSuiteWorkspace.meta.pageMetasUpdated.on(() => { - set(blockSuiteWorkspace.meta.pageMetas); + set(blockSuiteWorkspace.meta.docMetas); + const dispose = blockSuiteWorkspace.meta.docMetaUpdated.on(() => { + set(blockSuiteWorkspace.meta.docMetas); }); return () => { dispose.dispose(); }; }; } - return useAtomValue(weakMap.get(blockSuiteWorkspace) as Atom); + return useAtomValue(weakMap.get(blockSuiteWorkspace) as Atom); } diff --git a/packages/frontend/core/src/hooks/use-block-suite-page-backlinks.ts b/packages/frontend/core/src/hooks/use-block-suite-page-backlinks.ts index 6affab9acd..9e2bcda3c6 100644 --- a/packages/frontend/core/src/hooks/use-block-suite-page-backlinks.ts +++ b/packages/frontend/core/src/hooks/use-block-suite-page-backlinks.ts @@ -1,17 +1,17 @@ -import type { Page, Workspace } from '@blocksuite/store'; +import type { Doc, Workspace } from '@blocksuite/store'; import { type Atom, atom, useAtomValue } from 'jotai'; import { useBlockSuiteWorkspacePage } from './use-block-suite-workspace-page'; -const weakMap = new WeakMap>(); -function getPageBacklinks(page: Page): string[] { +const weakMap = new WeakMap>(); +function getPageBacklinks(page: Doc): string[] { return page.workspace.indexer.backlink .getBacklink(page.id) .map(linkNode => linkNode.pageId) .filter(id => id !== page.id); } -const getPageBacklinksAtom = (page: Page | null) => { +const getPageBacklinksAtom = (page: Doc | null) => { if (!page) { return atom([]); } diff --git a/packages/frontend/core/src/hooks/use-block-suite-page-meta.ts b/packages/frontend/core/src/hooks/use-block-suite-page-meta.ts index 06fd7d2a8c..df943935f9 100644 --- a/packages/frontend/core/src/hooks/use-block-suite-page-meta.ts +++ b/packages/frontend/core/src/hooks/use-block-suite-page-meta.ts @@ -1,9 +1,9 @@ -import type { PageBlockModel } from '@blocksuite/blocks'; +import type { RootBlockModel } from '@blocksuite/blocks'; import { assertExists } from '@blocksuite/global/utils'; -import type { PageMeta, Workspace } from '@blocksuite/store'; +import type { DocMeta, Workspace } from '@blocksuite/store'; import { useMemo } from 'react'; -import { useAllBlockSuitePageMeta } from './use-all-block-suite-page-meta'; +import { useAllBlockSuiteDocMeta } from './use-all-block-suite-page-meta'; import { useJournalHelper } from './use-journal'; /** @@ -11,8 +11,8 @@ import { useJournalHelper } from './use-journal'; * If you want to get all pageMetas, use `useAllBlockSuitePageMeta` instead * @returns */ -export function useBlockSuitePageMeta(blocksuiteWorkspace: Workspace) { - const pageMetas = useAllBlockSuitePageMeta(blocksuiteWorkspace); +export function useBlockSuiteDocMeta(blocksuiteWorkspace: Workspace) { + const pageMetas = useAllBlockSuiteDocMeta(blocksuiteWorkspace); const { isPageJournal } = useJournalHelper(blocksuiteWorkspace); return useMemo( () => @@ -23,32 +23,32 @@ export function useBlockSuitePageMeta(blocksuiteWorkspace: Workspace) { ); } -export function usePageMetaHelper(blockSuiteWorkspace: Workspace) { +export function useDocMetaHelper(blockSuiteWorkspace: Workspace) { return useMemo( () => ({ - setPageTitle: (pageId: string, newTitle: string) => { - const page = blockSuiteWorkspace.getPage(pageId); + setDocTitle: (docId: string, newTitle: string) => { + const page = blockSuiteWorkspace.getDoc(docId); assertExists(page); const pageBlock = page .getBlockByFlavour('affine:page') - .at(0) as PageBlockModel; + .at(0) as RootBlockModel; assertExists(pageBlock); page.transact(() => { pageBlock.title.delete(0, pageBlock.title.length); pageBlock.title.insert(newTitle, 0); }); - blockSuiteWorkspace.meta.setPageMeta(pageId, { title: newTitle }); + blockSuiteWorkspace.meta.setDocMeta(docId, { title: newTitle }); }, - setPageReadonly: (pageId: string, readonly: boolean) => { - const page = blockSuiteWorkspace.getPage(pageId); + setDocReadonly: (docId: string, readonly: boolean) => { + const page = blockSuiteWorkspace.getDoc(docId); assertExists(page); page.awarenessStore.setReadonly(page, readonly); }, - setPageMeta: (pageId: string, pageMeta: Partial) => { - blockSuiteWorkspace.meta.setPageMeta(pageId, pageMeta); + setDocMeta: (docId: string, docMeta: Partial) => { + blockSuiteWorkspace.meta.setDocMeta(docId, docMeta); }, - getPageMeta: (pageId: string) => { - return blockSuiteWorkspace.meta.getPageMeta(pageId); + getDocMeta: (docId: string) => { + return blockSuiteWorkspace.meta.getDocMeta(docId); }, }), [blockSuiteWorkspace] diff --git a/packages/frontend/core/src/hooks/use-block-suite-page-references.ts b/packages/frontend/core/src/hooks/use-block-suite-page-references.ts index 1c81d420db..f86fd47f60 100644 --- a/packages/frontend/core/src/hooks/use-block-suite-page-references.ts +++ b/packages/frontend/core/src/hooks/use-block-suite-page-references.ts @@ -1,16 +1,16 @@ -import type { Page, Workspace } from '@blocksuite/store'; +import type { Doc, Workspace } from '@blocksuite/store'; import { type Atom, atom, useAtomValue } from 'jotai'; import { useBlockSuiteWorkspacePage } from './use-block-suite-workspace-page'; -const weakMap = new WeakMap>(); -function getPageReferences(page: Page): string[] { +const weakMap = new WeakMap>(); +function getPageReferences(page: Doc): string[] { return Object.values( page.workspace.indexer.backlink.linkIndexMap[page.id] ?? {} ).flatMap(linkNodes => linkNodes.map(linkNode => linkNode.pageId)); } -const getPageReferencesAtom = (page: Page | null) => { +const getPageReferencesAtom = (page: Doc | null) => { if (!page) { return atom([]); } diff --git a/packages/frontend/core/src/hooks/use-block-suite-workspace-helper.ts b/packages/frontend/core/src/hooks/use-block-suite-workspace-helper.ts index 3695884435..17faf3bec4 100644 --- a/packages/frontend/core/src/hooks/use-block-suite-workspace-helper.ts +++ b/packages/frontend/core/src/hooks/use-block-suite-workspace-helper.ts @@ -1,11 +1,11 @@ -import type { Page, Workspace } from '@blocksuite/store'; +import type { Doc, Workspace } from '@blocksuite/store'; import { useMemo } from 'react'; export function useBlockSuiteWorkspaceHelper(blockSuiteWorkspace: Workspace) { return useMemo( () => ({ - createPage: (pageId?: string): Page => { - return blockSuiteWorkspace.createPage({ id: pageId }); + createDoc: (pageId?: string): Doc => { + return blockSuiteWorkspace.createDoc({ id: pageId }); }, }), [blockSuiteWorkspace] diff --git a/packages/frontend/core/src/hooks/use-block-suite-workspace-page-title.ts b/packages/frontend/core/src/hooks/use-block-suite-workspace-page-title.ts index f2ffd13547..c4f6d915ce 100644 --- a/packages/frontend/core/src/hooks/use-block-suite-workspace-page-title.ts +++ b/packages/frontend/core/src/hooks/use-block-suite-workspace-page-title.ts @@ -15,11 +15,11 @@ function getAtom(w: Workspace, pageId: string): Atom { const map = weakMap.get(w); assertExists(map); if (!map.has(pageId)) { - const baseAtom = atom(w.getPage(pageId)?.meta.title || 'Untitled'); + const baseAtom = atom(w.getDoc(pageId)?.meta?.title || 'Untitled'); baseAtom.onMount = set => { - const disposable = w.meta.pageMetasUpdated.on(() => { - const page = w.getPage(pageId); - set(page?.meta.title || 'Untitled'); + const disposable = w.meta.docMetaUpdated.on(() => { + const page = w.getDoc(pageId); + set(page?.meta?.title || 'Untitled'); }); return () => { disposable.dispose(); @@ -56,7 +56,7 @@ export function useGetBlockSuiteWorkspacePageTitle( (pageId: string) => { return ( getLocalizedJournalDateString(pageId) || - blockSuiteWorkspace.getPage(pageId)?.meta.title + blockSuiteWorkspace.getDoc(pageId)?.meta?.title ); }, [blockSuiteWorkspace, getLocalizedJournalDateString] diff --git a/packages/frontend/core/src/hooks/use-block-suite-workspace-page.ts b/packages/frontend/core/src/hooks/use-block-suite-workspace-page.ts index 3d889ef762..c6f2a4785d 100644 --- a/packages/frontend/core/src/hooks/use-block-suite-workspace-page.ts +++ b/packages/frontend/core/src/hooks/use-block-suite-workspace-page.ts @@ -1,26 +1,26 @@ import { DisposableGroup } from '@blocksuite/global/utils'; -import type { Page, Workspace } from '@blocksuite/store'; +import type { Doc, Workspace } from '@blocksuite/store'; import { useEffect, useState } from 'react'; export function useBlockSuiteWorkspacePage( blockSuiteWorkspace: Workspace, pageId: string | null -): Page | null { +): Doc | null { const [page, setPage] = useState( - pageId ? blockSuiteWorkspace.getPage(pageId) : null + pageId ? blockSuiteWorkspace.getDoc(pageId) : null ); useEffect(() => { const group = new DisposableGroup(); group.add( - blockSuiteWorkspace.slots.pageAdded.on(id => { + blockSuiteWorkspace.slots.docAdded.on(id => { if (pageId === id) { - setPage(blockSuiteWorkspace.getPage(id)); + setPage(blockSuiteWorkspace.getDoc(id)); } }) ); group.add( - blockSuiteWorkspace.slots.pageRemoved.on(id => { + blockSuiteWorkspace.slots.docRemoved.on(id => { if (pageId === id) { setPage(null); } diff --git a/packages/frontend/core/src/hooks/use-journal.ts b/packages/frontend/core/src/hooks/use-journal.ts index b8dd998b29..c169a6a96e 100644 --- a/packages/frontend/core/src/hooks/use-journal.ts +++ b/packages/frontend/core/src/hooks/use-journal.ts @@ -32,9 +32,9 @@ export const useJournalHelper = (workspace: BlockSuiteWorkspace) => { const _createJournal = useCallback( (maybeDate: MaybeDate) => { const title = dayjs(maybeDate).format(JOURNAL_DATE_FORMAT); - const page = bsWorkspaceHelper.createPage(); + const page = bsWorkspaceHelper.createDoc(); // set created date to match the journal date - page.workspace.setPageMeta(page.id, { + page.workspace.setDocMeta(page.id, { createDate: dayjs(maybeDate).toDate().getTime(), }); initEmptyPage(page, title); @@ -57,16 +57,16 @@ export const useJournalHelper = (workspace: BlockSuiteWorkspace) => { const getJournalsByDate = useCallback( (maybeDate: MaybeDate) => { const day = dayjs(maybeDate); - return Array.from(workspace.pages.values()).filter(page => { + return Array.from(workspace.docs.values()).filter(page => { const pageId = page.id; if (!isPageJournal(pageId)) return false; - if (page.meta.trash) return false; + if (page.meta?.trash) return false; const journalDate = adapter.getJournalPageDateString(page.id); if (!journalDate) return false; return day.isSame(journalDate, 'day'); }); }, - [adapter, isPageJournal, workspace.pages] + [adapter, isPageJournal, workspace.docs] ); /** diff --git a/packages/frontend/core/src/layouts/workspace-layout.tsx b/packages/frontend/core/src/layouts/workspace-layout.tsx index 2e69fc47fd..71d266057b 100644 --- a/packages/frontend/core/src/layouts/workspace-layout.tsx +++ b/packages/frontend/core/src/layouts/workspace-layout.tsx @@ -3,7 +3,7 @@ import { appSidebarResizingAtom, } from '@affine/component/app-sidebar'; import { MainContainer, WorkspaceFallback } from '@affine/component/workspace'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useWorkspaceStatus } from '@affine/core/hooks/use-workspace-status'; import { assertExists } from '@blocksuite/global/utils'; import { @@ -58,7 +58,7 @@ export const QuickSearch = () => { const currentWorkspace = useService(Workspace); const { pageId } = useParams(); const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace; - const pageMeta = useBlockSuitePageMeta( + const pageMeta = useBlockSuiteDocMeta( currentWorkspace.blockSuiteWorkspace ).find(meta => meta.id === pageId); diff --git a/packages/frontend/core/src/modules/workspace/properties/legacy-properties.ts b/packages/frontend/core/src/modules/workspace/properties/legacy-properties.ts index 501210a701..58b2a541f3 100644 --- a/packages/frontend/core/src/modules/workspace/properties/legacy-properties.ts +++ b/packages/frontend/core/src/modules/workspace/properties/legacy-properties.ts @@ -1,4 +1,4 @@ -import type { PagesPropertiesMeta, Tag } from '@blocksuite/store'; +import type { DocsPropertiesMeta, Tag } from '@blocksuite/store'; import { LiveData } from '@toeverything/infra/livedata'; import type { Workspace } from '@toeverything/infra/workspace'; import { Observable } from 'rxjs'; @@ -20,18 +20,18 @@ export class WorkspaceLegacyProperties { return this.properties.tags?.options ?? []; } - updateProperties = (properties: PagesPropertiesMeta) => { + updateProperties = (properties: DocsPropertiesMeta) => { this.workspace.blockSuiteWorkspace.meta.setProperties(properties); }; subscribe(cb: () => void) { const disposable = - this.workspace.blockSuiteWorkspace.meta.pageMetasUpdated.on(cb); + this.workspace.blockSuiteWorkspace.meta.docMetaUpdated.on(cb); return disposable.dispose; } properties$ = LiveData.from( - new Observable(sub => { + new Observable(sub => { return this.subscribe(() => sub.next(this.properties)); }), this.properties @@ -61,11 +61,11 @@ export class WorkspaceLegacyProperties { this.workspace.blockSuiteWorkspace.doc.transact(() => { this.updateTagOptions(this.tagOptions.filter(o => o.id !== id)); // need to remove tag from all pages - this.workspace.blockSuiteWorkspace.pages.forEach(page => { - const tags = page.meta.tags ?? []; + this.workspace.blockSuiteWorkspace.docs.forEach(doc => { + const tags = doc.meta?.tags ?? []; if (tags.includes(id)) { this.updatePageTags( - page.id, + doc.id, tags.filter(t => t !== id) ); } @@ -74,7 +74,7 @@ export class WorkspaceLegacyProperties { }; updatePageTags = (pageId: string, tags: string[]) => { - this.workspace.blockSuiteWorkspace.setPageMeta(pageId, { + this.workspace.blockSuiteWorkspace.setDocMeta(pageId, { tags, }); }; diff --git a/packages/frontend/core/src/pages/share/share-detail-page.tsx b/packages/frontend/core/src/pages/share/share-detail-page.tsx index 90a6430e2e..87e341017e 100644 --- a/packages/frontend/core/src/pages/share/share-detail-page.tsx +++ b/packages/frontend/core/src/pages/share/share-detail-page.tsx @@ -10,7 +10,7 @@ import { StaticBlobStorage, } from '@affine/workspace-impl'; import { Logo1Icon } from '@blocksuite/icons'; -import type { Page } from '@toeverything/infra'; +import type { Doc } from '@toeverything/infra'; import { EmptyBlobStorage, LocalBlobStorage, @@ -130,7 +130,7 @@ export const Component = () => { const currentWorkspace = useService(CurrentWorkspaceService); const t = useAFFiNEI18N(); - const [page, setPage] = useState(null); + const [page, setPage] = useState(null); useEffect(() => { // create a workspace for share page @@ -163,7 +163,7 @@ export const Component = () => { const { page } = workspace.services.get(PageManager).open(pageId); workspace.blockSuiteWorkspace.awarenessStore.setReadonly( - page.blockSuitePage, + page.blockSuiteDoc, true ); @@ -200,14 +200,14 @@ export const Component = () => { noop} /> diff --git a/packages/frontend/core/src/pages/workspace/all-page/all-page.tsx b/packages/frontend/core/src/pages/workspace/all-page/all-page.tsx index 9e10b219ec..74500c7b69 100644 --- a/packages/frontend/core/src/pages/workspace/all-page/all-page.tsx +++ b/packages/frontend/core/src/pages/workspace/all-page/all-page.tsx @@ -4,7 +4,7 @@ import { useFilteredPageMetas, VirtualizedPageList, } from '@affine/core/components/page-list'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper'; import { performanceRenderLogger } from '@affine/core/shared'; import type { Filter } from '@affine/env/filter'; @@ -18,7 +18,7 @@ import { AllPageHeader } from './all-page-header'; export const AllPage = () => { const currentWorkspace = useService(Workspace); - const pageMetas = useBlockSuitePageMeta(currentWorkspace.blockSuiteWorkspace); + const pageMetas = useBlockSuiteDocMeta(currentWorkspace.blockSuiteWorkspace); const [hideHeaderCreateNew, setHideHeaderCreateNew] = useState(true); const [filters, setFilters] = useState([]); @@ -58,10 +58,10 @@ export const Component = () => { useEffect(() => { function checkJumpOnce() { - for (const [pageId] of currentWorkspace.blockSuiteWorkspace.pages) { - const page = currentWorkspace.blockSuiteWorkspace.getPage(pageId); - if (page && page.meta.jumpOnce) { - currentWorkspace.blockSuiteWorkspace.meta.setPageMeta(page.id, { + for (const [pageId] of currentWorkspace.blockSuiteWorkspace.docs) { + const page = currentWorkspace.blockSuiteWorkspace.getDoc(pageId); + if (page && page.meta?.jumpOnce) { + currentWorkspace.blockSuiteWorkspace.meta.setDocMeta(page.id, { jumpOnce: false, }); navigateHelper.jumpToPage(currentWorkspace.id, pageId); @@ -69,7 +69,7 @@ export const Component = () => { } } checkJumpOnce(); - return currentWorkspace.blockSuiteWorkspace.slots.pagesUpdated.on( + return currentWorkspace.blockSuiteWorkspace.slots.docUpdated.on( checkJumpOnce ).dispose; }, [ diff --git a/packages/frontend/core/src/pages/workspace/all-tag/index.tsx b/packages/frontend/core/src/pages/workspace/all-tag/index.tsx index bca4a3f3f3..296fa874ba 100644 --- a/packages/frontend/core/src/pages/workspace/all-tag/index.tsx +++ b/packages/frontend/core/src/pages/workspace/all-tag/index.tsx @@ -4,7 +4,7 @@ import { TagListHeader, VirtualizedTagList, } from '@affine/core/components/page-list/tags'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useService } from '@toeverything/infra'; import { Workspace } from '@toeverything/infra'; @@ -14,7 +14,7 @@ import { AllTagHeader } from './header'; export const AllTag = () => { const currentWorkspace = useService(Workspace); - const pageMetas = useBlockSuitePageMeta(currentWorkspace.blockSuiteWorkspace); + const pageMetas = useBlockSuiteDocMeta(currentWorkspace.blockSuiteWorkspace); const { tags, tagMetas, deleteTags } = useTagMetas( currentWorkspace.blockSuiteWorkspace, diff --git a/packages/frontend/core/src/pages/workspace/detail-page/detail-page-header.tsx b/packages/frontend/core/src/pages/workspace/detail-page/detail-page-header.tsx index e4277a59ff..1e4b543a53 100644 --- a/packages/frontend/core/src/pages/workspace/detail-page/detail-page-header.tsx +++ b/packages/frontend/core/src/pages/workspace/detail-page/detail-page-header.tsx @@ -12,7 +12,7 @@ import { PageHeaderMenuButton } from '@affine/core/components/blocksuite/block-s import { EditorModeSwitch } from '@affine/core/components/blocksuite/block-suite-mode-switch'; import { useJournalInfoHelper } from '@affine/core/hooks/use-journal'; import { RightSidebarIcon } from '@blocksuite/icons'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import type { Workspace } from '@toeverything/infra'; import { useAtomValue, useSetAtom } from 'jotai'; import { useCallback, useRef } from 'react'; @@ -104,7 +104,7 @@ function Header({ } interface PageHeaderProps { - page: Page; + page: Doc; workspace: Workspace; showSidebarSwitch?: boolean; } @@ -178,7 +178,7 @@ export function NormalPageHeader({ export function DetailPageHeader(props: PageHeaderProps) { const { page } = props; const { isJournal } = useJournalInfoHelper(page.workspace, page.id); - const isInTrash = page.meta.trash; + const isInTrash = page.meta?.trash; return isJournal && !isInTrash ? ( @@ -189,7 +189,7 @@ export function DetailPageHeader(props: PageHeaderProps) { interface SidebarHeaderProps { workspace: Workspace; - page: Page; + page: Doc; } function WindowsSidebarHeader(props: SidebarHeaderProps) { return ( diff --git a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx index baced4e03a..97acb4aed2 100644 --- a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx +++ b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx @@ -1,8 +1,7 @@ import { Scrollable } from '@affine/component'; import { PageDetailSkeleton } from '@affine/component/page-detail-skeleton'; import { ResizePanel } from '@affine/component/resize-panel'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; -import type { PageService } from '@blocksuite/blocks'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { BookmarkService, customImageProxyMiddleware, @@ -12,10 +11,10 @@ import { ImageService, } from '@blocksuite/blocks'; import type { AffineEditorContainer } from '@blocksuite/presets'; -import type { Page as BlockSuitePage } from '@blocksuite/store'; +import type { Doc as BlockSuiteDoc } from '@blocksuite/store'; import { + Doc, globalBlockSuiteSchema, - Page, PageManager, PageRecordList, ServiceProviderContext, @@ -109,14 +108,14 @@ const DetailPageLayout = ({ }; const DetailPageImpl = memo(function DetailPageImpl() { - const page = useService(Page); + const page = useService(Doc); const pageRecordList = useService(PageRecordList); const currentPageId = page.id; const { openPage, jumpToTag } = useNavigateHelper(); const currentWorkspace = useService(Workspace); const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace; - const pageMeta = useBlockSuitePageMeta(blockSuiteWorkspace).find( + const pageMeta = useBlockSuiteDocMeta(blockSuiteWorkspace).find( meta => meta.id === page.id ); @@ -128,7 +127,7 @@ const DetailPageImpl = memo(function DetailPageImpl() { usePageDocumentTitle(title); const onLoad = useCallback( - (bsPage: BlockSuitePage, editor: AffineEditorContainer) => { + (bsPage: BlockSuiteDoc, editor: AffineEditorContainer) => { try { // todo(joooye34): improve the following migration code const surfaceBlock = bsPage.getBlockByFlavour('affine:surface')[0]; @@ -139,7 +138,7 @@ const DetailPageImpl = memo(function DetailPageImpl() { 'type' ) !== '$blocksuite:internal:native$' ) { - globalBlockSuiteSchema.upgradePage( + globalBlockSuiteSchema.upgradeDoc( 0, { 'affine:surface': 3, @@ -165,12 +164,10 @@ const DetailPageImpl = memo(function DetailPageImpl() { EmbedLoomService.setLinkPreviewEndpoint(runtimeConfig.linkPreviewUrl); // provide page mode and updated date to blocksuite - const pageService = editorHost.std.spec.getService( - 'affine:page' - ) as PageService; - pageService.getPageMode = (pageId: string) => + const pageService = editorHost.std.spec.getService('affine:page'); + pageService.getEditorMode = (pageId: string) => pageRecordList.record(pageId).value?.mode.value ?? 'page'; - pageService.getPageUpdatedAt = (pageId: string) => { + pageService.getDocUpdatedAt = (pageId: string) => { const linkedPage = pageRecordList.record(pageId).value; if (!linkedPage) return new Date(); @@ -181,8 +178,8 @@ const DetailPageImpl = memo(function DetailPageImpl() { page.setMode(mode); // fixme: it seems pageLinkClicked is not triggered sometimes? - const dispose = editor.slots.pageLinkClicked.on(({ pageId }) => { - return openPage(blockSuiteWorkspace.id, pageId); + const dispose = editor.slots.docLinkClicked.on(({ docId }) => { + return openPage(blockSuiteWorkspace.id, docId); }); const disposeTagClick = editor.slots.tagClicked.on(({ tagId }) => { jumpToTag(currentWorkspace.id, tagId); @@ -209,7 +206,7 @@ const DetailPageImpl = memo(function DetailPageImpl() { header={ <> @@ -238,11 +235,11 @@ const DetailPageImpl = memo(function DetailPageImpl() {
) : null @@ -271,7 +268,7 @@ export const DetailPage = ({ pageId }: { pageId: string }): ReactElement => { const pageManager = useService(PageManager); - const [page, setPage] = useState(null); + const [page, setPage] = useState(null); useEffect(() => { if (!pageRecord) { diff --git a/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/extensions.tsx b/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/extensions.tsx index 76c1cdae96..90334838cf 100644 --- a/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/extensions.tsx +++ b/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/extensions.tsx @@ -2,7 +2,7 @@ import { IconButton } from '@affine/component'; import { useJournalInfoHelper } from '@affine/core/hooks/use-journal'; import { useWorkspaceEnabledFeatures } from '@affine/core/hooks/use-workspace-features'; import { FeatureType } from '@affine/graphql'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import type { Workspace } from '@toeverything/infra'; import { assignInlineVars } from '@vanilla-extract/dynamic'; import { useAtom, useAtomValue } from 'jotai'; @@ -16,7 +16,7 @@ import * as styles from './extensions.css'; export interface ExtensionTabsProps { workspace: Workspace; - page: Page; + page: Doc; } // provide a switcher for active extensions diff --git a/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/journal.tsx b/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/journal.tsx index d5857732da..b2503ffcc0 100644 --- a/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/journal.tsx +++ b/packages/frontend/core/src/pages/workspace/detail-page/editor-sidebar/extensions/journal.tsx @@ -7,7 +7,7 @@ import { } from '@affine/component'; import { MoveToTrash } from '@affine/core/components/page-list'; import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useBlockSuiteWorkspacePageTitle } from '@affine/core/hooks/use-block-suite-workspace-page-title'; import { useJournalHelper, @@ -23,7 +23,7 @@ import { PageIcon, TodayIcon, } from '@blocksuite/icons'; -import type { Page, PageMeta } from '@blocksuite/store'; +import type { Doc, DocMeta } from '@blocksuite/store'; import { assignInlineVars } from '@vanilla-extract/dynamic'; import clsx from 'clsx'; import dayjs from 'dayjs'; @@ -44,7 +44,7 @@ const CountDisplay = ({ return {count > max ? `${max}+` : count}; }; interface PageItemProps extends HTMLAttributes { - pageMeta: PageMeta; + pageMeta: DocMeta; workspace: BlockSuiteWorkspace; right?: ReactNode; } @@ -156,7 +156,7 @@ const EditorJournalPanel = (props: EditorExtensionProps) => { }; const sortPagesByDate = ( - pages: PageMeta[], + pages: DocMeta[], field: 'updatedDate' | 'createDate', order: 'asc' | 'desc' = 'desc' ) => { @@ -180,7 +180,7 @@ const JournalDailyCountBlock = ({ workspace, date }: JournalBlockProps) => { const nodeRef = useRef(null); const t = useAFFiNEI18N(); const [activeItem, setActiveItem] = useState('createdToday'); - const pageMetas = useBlockSuitePageMeta(workspace); + const pageMetas = useBlockSuiteDocMeta(workspace); const navigateHelper = useNavigateHelper(); @@ -289,7 +289,7 @@ interface ConflictListProps extends JournalBlockProps, PropsWithChildren, HTMLAttributes { - pages: Page[]; + pages: Doc[]; } const ConflictList = ({ page: currentPage, @@ -303,7 +303,7 @@ const ConflictList = ({ const { setTrashModal } = useTrashModalHelper(workspace); const handleOpenTrashModal = useCallback( - (page: Page) => { + (page: Doc) => { if (!page.meta) return; setTrashModal({ open: true, @@ -320,9 +320,9 @@ const ConflictList = ({ const isCurrent = page.id === currentPage.id; return ( { const currentWorkspace = useService(Workspace); - const pageMetas = useBlockSuitePageMeta(currentWorkspace.blockSuiteWorkspace); + const pageMetas = useBlockSuiteDocMeta(currentWorkspace.blockSuiteWorkspace); const { tags, filterPageMetaByTag } = useTagMetas( currentWorkspace.blockSuiteWorkspace, diff --git a/packages/frontend/core/src/pages/workspace/trash-page.tsx b/packages/frontend/core/src/pages/workspace/trash-page.tsx index 725795cd99..0f3e0b141a 100644 --- a/packages/frontend/core/src/pages/workspace/trash-page.tsx +++ b/packages/frontend/core/src/pages/workspace/trash-page.tsx @@ -12,11 +12,11 @@ import { pageHeaderColsDef } from '@affine/core/components/page-list/header-col- import { Header } from '@affine/core/components/pure/header'; import { WindowsAppControls } from '@affine/core/components/pure/header/windows-app-controls'; import { useBlockSuiteMetaHelper } from '@affine/core/hooks/affine/use-block-suite-meta-helper'; -import { useBlockSuitePageMeta } from '@affine/core/hooks/use-block-suite-page-meta'; +import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { assertExists } from '@blocksuite/global/utils'; import { DeleteIcon } from '@blocksuite/icons'; -import type { PageMeta } from '@blocksuite/store'; +import type { DocMeta } from '@blocksuite/store'; import { Workspace } from '@toeverything/infra'; import { useService } from '@toeverything/infra/di'; import { useCallback } from 'react'; @@ -51,7 +51,7 @@ export const TrashPage = () => { const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace; assertExists(blockSuiteWorkspace); - const pageMetas = useBlockSuitePageMeta(blockSuiteWorkspace); + const pageMetas = useBlockSuiteDocMeta(blockSuiteWorkspace); const filteredPageMetas = useFilteredPageMetas(currentWorkspace, pageMetas, { trash: true, }); @@ -63,7 +63,7 @@ export const TrashPage = () => { const pageOperationsRenderer = useCallback( (item: ListItem) => { - const page = item as PageMeta; + const page = item as DocMeta; const onRestorePage = () => { restoreFromTrash(page.id); toast( diff --git a/packages/frontend/core/src/testing.ts b/packages/frontend/core/src/testing.ts index 8a5c7373f0..1b65f370b9 100644 --- a/packages/frontend/core/src/testing.ts +++ b/packages/frontend/core/src/testing.ts @@ -1,5 +1,5 @@ import { WorkspaceFlavour } from '@affine/env/workspace'; -import type { Page as BlockSuitePage } from '@blocksuite/store'; +import type { Doc as BlockSuiteDoc } from '@blocksuite/store'; import { configureTestingInfraServices, PageManager, @@ -22,7 +22,7 @@ export async function configureTestingEnvironment() { const { workspace } = workspaceManager.open( await workspaceManager.createWorkspace(WorkspaceFlavour.LOCAL, async ws => { - const initPage = async (page: BlockSuitePage) => { + const initPage = async (page: BlockSuiteDoc) => { page.load(); const pageBlockId = page.addBlock('affine:page', { title: new page.Text(''), @@ -30,7 +30,7 @@ export async function configureTestingEnvironment() { const frameId = page.addBlock('affine:note', {}, pageBlockId); page.addBlock('affine:paragraph', {}, frameId); }; - await initPage(ws.createPage({ id: 'page0' })); + await initPage(ws.createDoc({ id: 'page0' })); }) ); diff --git a/packages/frontend/electron/package.json b/packages/frontend/electron/package.json index 5382eceed3..817d88a921 100644 --- a/packages/frontend/electron/package.json +++ b/packages/frontend/electron/package.json @@ -25,10 +25,10 @@ "@affine-test/kit": "workspace:*", "@affine/env": "workspace:*", "@affine/native": "workspace:*", - "@blocksuite/blocks": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/lit": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/presets": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/blocks": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/lit": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/presets": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "@electron-forge/cli": "^7.3.0", "@electron-forge/core": "^7.3.0", "@electron-forge/core-utils": "^7.3.0", diff --git a/packages/frontend/workspace-impl/src/local/__tests__/engine.spec.ts b/packages/frontend/workspace-impl/src/local/__tests__/engine.spec.ts index 5b4d732f48..af648bde5b 100644 --- a/packages/frontend/workspace-impl/src/local/__tests__/engine.spec.ts +++ b/packages/frontend/workspace-impl/src/local/__tests__/engine.spec.ts @@ -37,7 +37,7 @@ describe('SyncEngine', () => { ); syncEngine.start(); - const page = workspace.createPage({ + const page = workspace.createDoc({ id: 'page0', }); page.load(); diff --git a/packages/frontend/workspace-impl/src/local/__tests__/peer.spec.ts b/packages/frontend/workspace-impl/src/local/__tests__/peer.spec.ts index 69598a8a33..2f5d5f0141 100644 --- a/packages/frontend/workspace-impl/src/local/__tests__/peer.spec.ts +++ b/packages/frontend/workspace-impl/src/local/__tests__/peer.spec.ts @@ -31,7 +31,7 @@ describe('SyncPeer', () => { ); await syncPeer.waitForLoaded(); - const page = workspace.createPage({ + const page = workspace.createDoc({ id: 'page0', }); page.load(); @@ -79,7 +79,7 @@ describe('SyncPeer', () => { await syncPeer.waitForSynced(); expect(syncPeer.status.step).toBe(SyncPeerStep.Synced); - const page = workspace.createPage({ + const page = workspace.createDoc({ id: 'page0', }); expect(syncPeer.status.step).toBe(SyncPeerStep.LoadingSubDoc); diff --git a/tests/affine-cloud/e2e/collaboration.spec.ts b/tests/affine-cloud/e2e/collaboration.spec.ts index 99a426cec6..3ad004675a 100644 --- a/tests/affine-cloud/e2e/collaboration.spec.ts +++ b/tests/affine-cloud/e2e/collaboration.spec.ts @@ -89,7 +89,7 @@ test('share page with default edgeless', async ({ page, browser }) => { await page.keyboard.press('Enter', { delay: 50 }); await page.keyboard.type('TEST CONTENT', { delay: 50 }); await clickEdgelessModeButton(page); - await expect(page.locator('affine-edgeless-page')).toBeVisible({ + await expect(page.locator('affine-edgeless-root')).toBeVisible({ timeout: 1000, }); await page.getByTestId('cloud-share-menu-button').click(); @@ -106,7 +106,7 @@ test('share page with default edgeless', async ({ page, browser }) => { const page2 = await context.newPage(); await page2.goto(url); await waitForEditorLoad(page2); - await expect(page.locator('affine-edgeless-page')).toBeVisible({ + await expect(page.locator('affine-edgeless-root')).toBeVisible({ timeout: 1000, }); expect(await page2.textContent('affine-paragraph')).toContain( diff --git a/tests/affine-cloud/e2e/migration.spec.ts b/tests/affine-cloud/e2e/migration.spec.ts index b0a42db203..2a4da7ddb2 100644 --- a/tests/affine-cloud/e2e/migration.spec.ts +++ b/tests/affine-cloud/e2e/migration.spec.ts @@ -104,10 +104,4 @@ test.skip('migration', async ({ page, browser }) => { await page.waitForTimeout(5000); await page.reload(); await waitForEditorLoad(page); - - // click edgeless switch button is flaky in e2e - // await clickEdgelessModeButton(page); - // await expect(page.locator('affine-edgeless-page')).toBeVisible({ - // timeout: 1000, - // }); }); diff --git a/tests/affine-local/e2e/all-page.spec.ts b/tests/affine-local/e2e/all-page.spec.ts index 7c5c1b1774..16b92fe110 100644 --- a/tests/affine-local/e2e/all-page.spec.ts +++ b/tests/affine-local/e2e/all-page.spec.ts @@ -66,7 +66,7 @@ test('all page can create new edgeless page', async ({ page }) => { await waitForEditorLoad(page); await clickSideBarAllPageButton(page); await clickNewEdgelessDropdown(); - await expect(page.locator('affine-edgeless-page')).toBeVisible(); + await expect(page.locator('affine-edgeless-root')).toBeVisible(); }); test('allow creation of filters by favorite', async ({ page }) => { diff --git a/tests/affine-local/e2e/change-page-mode.spec.ts b/tests/affine-local/e2e/change-page-mode.spec.ts index d2a0a62baf..cbe0a9a315 100644 --- a/tests/affine-local/e2e/change-page-mode.spec.ts +++ b/tests/affine-local/e2e/change-page-mode.spec.ts @@ -32,7 +32,7 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => { const count = await getCount(); expect(count).toBe(1); } - const edgeless = page.locator('affine-edgeless-page'); + const edgeless = page.locator('affine-edgeless-root'); await expect(edgeless).toBeVisible(); const editorWrapperPadding = await page @@ -62,7 +62,7 @@ test('Convert to edgeless by editor header items', async ({ page }) => { await clickPageMoreActions(page); const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless'); await menusEdgelessItem.click({ delay: 100 }); - const edgeless = page.locator('affine-edgeless-page'); + const edgeless = page.locator('affine-edgeless-root'); await expect(edgeless).toBeVisible(); }); diff --git a/tests/affine-local/e2e/quick-search.spec.ts b/tests/affine-local/e2e/quick-search.spec.ts index 8874e00aa2..22e3598250 100644 --- a/tests/affine-local/e2e/quick-search.spec.ts +++ b/tests/affine-local/e2e/quick-search.spec.ts @@ -44,7 +44,7 @@ const commandsIsVisible = async (page: Page, label: string) => { }; async function assertTitle(page: Page, text: string) { - const edgeless = page.locator('affine-edgeless-page'); + const edgeless = page.locator('affine-edgeless-root'); if (!edgeless) { const locator = getBlockSuiteEditorTitle(page); const actual = await locator.inputValue(); @@ -97,7 +97,7 @@ async function assertResultList(page: Page, texts: string[]) { } async function titleIsFocused(page: Page) { - const edgeless = page.locator('affine-edgeless-page'); + const edgeless = page.locator('affine-edgeless-root'); if (!edgeless) { const title = getBlockSuiteEditorTitle(page); await expect(title).toBeVisible(); diff --git a/tests/affine-migration/e2e/basic.spec.ts b/tests/affine-migration/e2e/basic.spec.ts index cad1bbfb17..43f4a5d366 100644 --- a/tests/affine-migration/e2e/basic.spec.ts +++ b/tests/affine-migration/e2e/basic.spec.ts @@ -85,7 +85,7 @@ test('v3 to v4, surface migration', async ({ page }) => { // check edgeless mode is correct await clickEdgelessModeButton(page); await expect(page.locator('.edgeless-toolbar-container')).toBeVisible(); - await expect(page.locator('affine-edgeless-page')).toBeVisible(); + await expect(page.locator('affine-edgeless-root')).toBeVisible(); }); test('v0 to v4, subdoc migration', async ({ page }) => { @@ -112,5 +112,5 @@ test('v0 to v4, subdoc migration', async ({ page }) => { // check edgeless mode is correct await clickEdgelessModeButton(page); await expect(page.locator('.edgeless-toolbar-container')).toBeVisible(); - await expect(page.locator('affine-edgeless-page')).toBeVisible(); + await expect(page.locator('affine-edgeless-root')).toBeVisible(); }); diff --git a/tests/storybook/package.json b/tests/storybook/package.json index ee859d2d1b..0003c06425 100644 --- a/tests/storybook/package.json +++ b/tests/storybook/package.json @@ -22,14 +22,14 @@ "storybook-addon-react-router-v6": "^2.0.10" }, "devDependencies": { - "@blocksuite/block-std": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/blocks": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/global": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/block-std": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/blocks": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/global": "0.12.0-canary-202402271448-6d3a709", "@blocksuite/icons": "2.1.44", - "@blocksuite/inline": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/lit": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/presets": "0.12.0-canary-202402220729-0868ac6", - "@blocksuite/store": "0.12.0-canary-202402220729-0868ac6", + "@blocksuite/inline": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/lit": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/presets": "0.12.0-canary-202402271448-6d3a709", + "@blocksuite/store": "0.12.0-canary-202402271448-6d3a709", "@storybook/addon-actions": "^7.6.17", "@storybook/addon-essentials": "^7.6.17", "@storybook/addon-interactions": "^7.6.17", diff --git a/tests/storybook/src/stories/blocksuite-editor.stories.tsx b/tests/storybook/src/stories/blocksuite-editor.stories.tsx index c63a14f841..a5fe6f9ff5 100644 --- a/tests/storybook/src/stories/blocksuite-editor.stories.tsx +++ b/tests/storybook/src/stories/blocksuite-editor.stories.tsx @@ -13,7 +13,7 @@ async function createAndInitPage( title: string, preview: string ) { - const page = workspace.createPage(); + const page = workspace.createDoc(); initEmptyPage(page, title); page.getBlockByFlavour('affine:paragraph').at(0)?.text?.insert(preview, 0); return page; diff --git a/tests/storybook/src/stories/image-preview-modal.stories.tsx b/tests/storybook/src/stories/image-preview-modal.stories.tsx index 1612c62c4c..0f6cffbebc 100644 --- a/tests/storybook/src/stories/image-preview-modal.stories.tsx +++ b/tests/storybook/src/stories/image-preview-modal.stories.tsx @@ -1,7 +1,7 @@ import { BlockSuiteEditor } from '@affine/core/components/blocksuite/block-suite-editor'; import { ImagePreviewModal } from '@affine/core/components/image-preview'; import type { Meta } from '@storybook/react'; -import type { Page } from '@toeverything/infra'; +import type { Doc } from '@toeverything/infra'; import { PageManager, ServiceProviderContext, @@ -21,13 +21,13 @@ export const Default = () => { const workspace = useService(Workspace); const pageManager = useService(PageManager); - const [page, setPage] = useState(null); + const [page, setPage] = useState(null); useEffect(() => { - const bsPage = workspace.blockSuiteWorkspace.createPage('page0'); + const bsPage = workspace.blockSuiteWorkspace.createDoc('page0'); initEmptyPage(bsPage); - const { page, release } = pageManager.open(bsPage.meta.id); + const { page, release } = pageManager.open(bsPage.meta!.id); fetch(new URL('@affine-test/fixtures/large-image.png', import.meta.url)) .then(res => res.arrayBuffer()) @@ -76,11 +76,11 @@ export const Default = () => { overflow: 'auto', }} > - + {createPortal( , document.body )} diff --git a/tests/storybook/src/stories/page-info-properties.stories.tsx b/tests/storybook/src/stories/page-info-properties.stories.tsx index b5cae03030..7e11426ed5 100644 --- a/tests/storybook/src/stories/page-info-properties.stories.tsx +++ b/tests/storybook/src/stories/page-info-properties.stories.tsx @@ -13,7 +13,7 @@ async function createAndInitPage( title: string, preview: string ) { - const page = workspace.createPage(); + const page = workspace.createDoc(); initEmptyPage(page, title); page.getBlockByFlavour('affine:paragraph').at(0)?.text?.insert(preview, 0); return page; @@ -53,7 +53,9 @@ PageInfoProperties.loaders = [ 'Hello World from page 1' ); - page.meta.updatedDate = Date.now(); + if (page.meta) { + page.meta.updatedDate = Date.now(); + } return { page, diff --git a/tests/storybook/src/stories/page-list.stories.tsx b/tests/storybook/src/stories/page-list.stories.tsx index 7845723760..429ce5e5f8 100644 --- a/tests/storybook/src/stories/page-list.stories.tsx +++ b/tests/storybook/src/stories/page-list.stories.tsx @@ -230,7 +230,7 @@ async function createAndInitPage( title: string, preview: string ) { - const page = workspace.createPage(); + const page = workspace.createDoc(); initEmptyPage(page, title); page.getBlockByFlavour('affine:paragraph').at(0)?.text?.insert(preview, 0); return page; @@ -273,16 +273,16 @@ PageListStory.loaders = [ 'Hello World from page 3Hello World from page 3Hello World from page 3Hello World from page 3Hello World from page 3' ); - page1.meta.createDate = new Date('2021-01-01').getTime(); - page2.meta.createDate = page2.meta.createDate - 3600 * 1000 * 24; - page3.meta.createDate = page3.meta.createDate - 3600 * 1000 * 24 * 7; + page1.meta!.createDate = new Date('2021-01-01').getTime(); + page2.meta!.createDate = page2.meta!.createDate - 3600 * 1000 * 24; + page3.meta!.createDate = page3.meta!.createDate - 3600 * 1000 * 24 * 7; - workspace.meta.pageMetas[3].tags = testTags.slice(0, 3).map(t => t.id); - workspace.meta.pageMetas[2].tags = testTags.slice(0, 12).map(t => t.id); + workspace.meta.docMetas[3].tags = testTags.slice(0, 3).map(t => t.id); + workspace.meta.docMetas[2].tags = testTags.slice(0, 12).map(t => t.id); return { blockSuiteWorkspace: workspace, - pages: workspace.meta.pages, + pages: workspace.meta.docs, }; }, ]; diff --git a/tests/storybook/src/stories/quick-search/quick-search-main.stories.tsx b/tests/storybook/src/stories/quick-search/quick-search-main.stories.tsx index 20870fd266..143b7c3792 100644 --- a/tests/storybook/src/stories/quick-search/quick-search-main.stories.tsx +++ b/tests/storybook/src/stories/quick-search/quick-search-main.stories.tsx @@ -6,7 +6,7 @@ import { import { CMDKQuickSearchModal } from '@affine/core/components/pure/cmdk'; import { HighlightLabel } from '@affine/core/components/pure/cmdk/highlight'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; -import type { Page } from '@blocksuite/store'; +import type { Doc } from '@blocksuite/store'; import type { Meta, StoryFn } from '@storybook/react'; import { useStore } from 'jotai'; import { useEffect, useState } from 'react'; @@ -23,7 +23,7 @@ const createMockedPage = () => { return { id: 'test-page', waitForLoaded: () => Promise.resolve(), - } as any as Page; + } as any as Doc; }; function useRegisterCommands() { diff --git a/tests/storybook/src/stories/share-menu.stories.tsx b/tests/storybook/src/stories/share-menu.stories.tsx index e10bc25151..2ab43017a3 100644 --- a/tests/storybook/src/stories/share-menu.stories.tsx +++ b/tests/storybook/src/stories/share-menu.stories.tsx @@ -2,7 +2,7 @@ import { toast } from '@affine/component'; import { PublicLinkDisableModal } from '@affine/component/disable-public-link'; import { ShareMenu } from '@affine/core/components/affine/share-page-modal/share-menu'; import { WorkspaceFlavour } from '@affine/env/workspace'; -import { type Page } from '@blocksuite/store'; +import { type Doc } from '@blocksuite/store'; import { expect } from '@storybook/jest'; import type { Meta, StoryFn } from '@storybook/react'; import { Workspace } from '@toeverything/infra'; @@ -26,10 +26,10 @@ async function unimplemented() { export const Basic: StoryFn = () => { const workspace = useService(Workspace); - const [page, setPage] = useState(null); + const [page, setPage] = useState(null); useEffect(() => { - const page = workspace.blockSuiteWorkspace.createPage(nanoid()); + const page = workspace.blockSuiteWorkspace.createDoc(nanoid()); initEmptyPage(page); setPage(page); @@ -68,10 +68,10 @@ Basic.play = async ({ canvasElement }) => { export const AffineBasic: StoryFn = () => { const workspace = useService(Workspace); - const [page, setPage] = useState(null); + const [page, setPage] = useState(null); useEffect(() => { - const page = workspace.blockSuiteWorkspace.createPage(nanoid()); + const page = workspace.blockSuiteWorkspace.createDoc(nanoid()); initEmptyPage(page); setPage(page); diff --git a/tools/@types/env/__all.d.ts b/tools/@types/env/__all.d.ts index c8f0321e7c..1e92c49305 100644 --- a/tools/@types/env/__all.d.ts +++ b/tools/@types/env/__all.d.ts @@ -19,7 +19,7 @@ declare global { } declare module '@blocksuite/store' { - interface PageMeta { + interface DocMeta { favorite?: boolean; // If a page remove to trash, and it is a subpage, it will remove from its parent `subpageIds`, 'trashRelate' is use for save it parent trashRelate?: string; diff --git a/yarn.lock b/yarn.lock index 7c70b31d75..931ae6e41c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -202,12 +202,12 @@ __metadata: "@affine/electron-api": "workspace:*" "@affine/graphql": "workspace:*" "@affine/i18n": "workspace:*" - "@blocksuite/blocks": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/blocks": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" "@blocksuite/icons": "npm:2.1.44" - "@blocksuite/lit": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/presets": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/lit": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/presets": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" "@dnd-kit/core": "npm:^6.1.0" "@dnd-kit/modifiers": "npm:^7.0.0" "@dnd-kit/sortable": "npm:^8.0.0" @@ -303,14 +303,14 @@ __metadata: "@affine/templates": "workspace:*" "@affine/workspace-impl": "workspace:*" "@aws-sdk/client-s3": "npm:3.515.0" - "@blocksuite/block-std": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/blocks": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/block-std": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/blocks": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" "@blocksuite/icons": "npm:2.1.44" - "@blocksuite/inline": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/lit": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/presets": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/inline": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/lit": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/presets": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" "@dnd-kit/core": "npm:^6.1.0" "@dnd-kit/modifiers": "npm:^7.0.0" "@dnd-kit/sortable": "npm:^8.0.0" @@ -441,10 +441,10 @@ __metadata: "@affine-test/kit": "workspace:*" "@affine/env": "workspace:*" "@affine/native": "workspace:*" - "@blocksuite/blocks": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/lit": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/presets": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/blocks": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/lit": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/presets": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" "@electron-forge/cli": "npm:^7.3.0" "@electron-forge/core": "npm:^7.3.0" "@electron-forge/core-utils": "npm:^7.3.0" @@ -492,8 +492,8 @@ __metadata: version: 0.0.0-use.local resolution: "@affine/env@workspace:packages/common/env" dependencies: - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" lit: "npm:^3.1.2" react: "npm:18.2.0" react-dom: "npm:18.2.0" @@ -741,14 +741,14 @@ __metadata: "@affine/component": "workspace:*" "@affine/i18n": "workspace:*" "@affine/workspace-impl": "workspace:*" - "@blocksuite/block-std": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/blocks": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/block-std": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/blocks": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" "@blocksuite/icons": "npm:2.1.44" - "@blocksuite/inline": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/lit": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/presets": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/inline": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/lit": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/presets": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" "@dnd-kit/sortable": "npm:^8.0.0" "@storybook/addon-actions": "npm:^7.6.17" "@storybook/addon-essentials": "npm:^7.6.17" @@ -3423,33 +3423,34 @@ __metadata: languageName: node linkType: hard -"@blocksuite/block-std@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/block-std@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/block-std@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/block-std@npm:0.12.0-canary-202402271448-6d3a709" dependencies: - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" lz-string: "npm:^1.5.0" w3c-keyname: "npm:^2.2.8" zod: "npm:^3.22.4" peerDependencies: - "@blocksuite/store": 0.12.0-canary-202402220729-0868ac6 - checksum: 10/1ce4bbba56b80283ee4397ddda3a03d777bc8e63bcbd3b09ea479c088621e2d95f577cf2d368ed67344f4a82011ea103a563db7fb0253bc4b25be56465d2dc29 + "@blocksuite/store": 0.12.0-canary-202402271448-6d3a709 + checksum: 10/e383f20aedcc15b2f5191967249e1be176923af61c0d726dcd82dab949ead707c6fc76060a9baf403ca4bfaa3434f7a5364bf6d37412e110ab10b1cf79cc39e7 languageName: node linkType: hard -"@blocksuite/blocks@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/blocks@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/blocks@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/blocks@npm:0.12.0-canary-202402271448-6d3a709" dependencies: - "@blocksuite/block-std": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/inline": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/lit": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/block-std": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/inline": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/lit": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" "@floating-ui/dom": "npm:^1.5.4" "@toeverything/theme": "npm:^0.7.27" "@types/hast": "npm:^3.0.3" "@types/mdast": "npm:^4.0.3" + "@types/sortablejs": "npm:^1.15.7" "@types/webfontloader": "npm:^1.6.38" buffer: "npm:^6.0.3" date-fns: "npm:^3.3.0" @@ -3479,16 +3480,16 @@ __metadata: unified: "npm:^11.0.4" webfontloader: "npm:^1.6.28" zod: "npm:^3.22.4" - checksum: 10/771c5eb8f15347815e9af8888ca6ad1450259751fce74ccc79ff4514004772763f638730d852c8f7565b352dfadef4613655ef5670ae05aa5600cf601c2b93cb + checksum: 10/821bfe5f01801787af9aa1846592c3f9b7923b41bb57549e2e1db8eb47520396eca1e94a23d717e9f149b36c791097d5f7272d5befc285f01518d3c6ed3d3ac4 languageName: node linkType: hard -"@blocksuite/global@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/global@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/global@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/global@npm:0.12.0-canary-202402271448-6d3a709" dependencies: zod: "npm:^3.22.4" - checksum: 10/0708a75d64cabf2a9c27b274c95d2178c7911078aae556387010e4daa449552cb488153d7e0dc7fa6645a4ce710427db674218c9b00ef26042203867c9138e1a + checksum: 10/7cdb6fad7a8c63cc3df25b6dda3b8a7e7f80edf3db2674e755148b131a2ce3150b2bec9a5d51826d3b479d357d27bd63bfbad14bd14302c1be216a497b13e797 languageName: node linkType: hard @@ -3502,59 +3503,59 @@ __metadata: languageName: node linkType: hard -"@blocksuite/inline@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/inline@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/inline@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/inline@npm:0.12.0-canary-202402271448-6d3a709" dependencies: - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" zod: "npm:^3.22.4" peerDependencies: lit: ^3.1.1 yjs: ^13 - checksum: 10/b5b860967b62a22d298765e6c3dd0d73f636d43824e16c578d683506ea78dadfdf56b7f00dd2b22ead1cfc1d6f5d1d48b6a4e01dda80f2daa018c1dab6aa9c0e + checksum: 10/09c1706b07cef9623893f36f320c7ae2b408078c61033afeb39c161c8fce1cfc61ed6e577ed2449ae74fcafd07e31d525124c8b3a9bdda7320ad66a916180d5d languageName: node linkType: hard -"@blocksuite/lit@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/lit@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/lit@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/lit@npm:0.12.0-canary-202402271448-6d3a709" dependencies: - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/inline": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/inline": "npm:0.12.0-canary-202402271448-6d3a709" lit: "npm:^3.1.1" peerDependencies: - "@blocksuite/block-std": 0.12.0-canary-202402220729-0868ac6 - "@blocksuite/store": 0.12.0-canary-202402220729-0868ac6 - checksum: 10/c0f20bbb6b770befc7ca2cecafd680b7b1cf62db336d18dfd65455bccf064b03fd9f5f4b3b2c5f2729083e157c29a4e76df7947d657f5fb4f951c2c8cc668d57 + "@blocksuite/block-std": 0.12.0-canary-202402271448-6d3a709 + "@blocksuite/store": 0.12.0-canary-202402271448-6d3a709 + checksum: 10/323aeec9cb177a986dc3547ed9e448622ed56d826bdc9d234523d41e871c7987e0436a6296b6f933d7afe6ca544ce644cd657274cfe03fe4334702b0909a1830 languageName: node linkType: hard -"@blocksuite/presets@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/presets@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/presets@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/presets@npm:0.12.0-canary-202402271448-6d3a709" dependencies: - "@blocksuite/block-std": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/blocks": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/inline": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/lit": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/block-std": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/blocks": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/inline": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/lit": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" "@fal-ai/serverless-client": "npm:^0.8.2" "@floating-ui/dom": "npm:^1.5.4" "@toeverything/theme": "npm:^0.7.27" lit: "npm:^3.1.1" openai: "npm:^4.25.0" - checksum: 10/a4be3d35e5e2c34931bc3d385379c940d7543f14e3cba929c3f081651deb794aafb3227d3910526b1790b821bab4a73cb59b5efa5c43908af55504d92af6bac0 + checksum: 10/d78840b53de3ae13917df59d6f9ecbed98da78f3c6671e76270420620cebf004fed4716a2cc967a13bb12d480ae267e16edcd3bd08efd49f985d6aff18a6ceb9 languageName: node linkType: hard -"@blocksuite/store@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/store@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/store@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/store@npm:0.12.0-canary-202402271448-6d3a709" dependencies: - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/inline": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/sync": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/inline": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/sync": "npm:0.12.0-canary-202402271448-6d3a709" "@types/flexsearch": "npm:^0.7.6" flexsearch: "npm:0.7.43" idb-keyval: "npm:^6.2.1" @@ -3566,20 +3567,20 @@ __metadata: zod: "npm:^3.22.4" peerDependencies: yjs: ^13 - checksum: 10/9bc766c46f0400b4d61e503e41727c28bb25a33dc8c381e09584bbbd881e635e6ca5ec3647103cac42f08073b4c204d9ca07cc03cc959f22361f8dea349dd808 + checksum: 10/0e9f89157e433578d47f83ef52ee260947cfee31706607a887d2b0bf7fafca0bebfccfdf1fa32f2abd0a3e58b5cb945ad0298392eff25422acfca1d406206d58 languageName: node linkType: hard -"@blocksuite/sync@npm:0.12.0-canary-202402220729-0868ac6": - version: 0.12.0-canary-202402220729-0868ac6 - resolution: "@blocksuite/sync@npm:0.12.0-canary-202402220729-0868ac6" +"@blocksuite/sync@npm:0.12.0-canary-202402271448-6d3a709": + version: 0.12.0-canary-202402271448-6d3a709 + resolution: "@blocksuite/sync@npm:0.12.0-canary-202402271448-6d3a709" dependencies: - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" idb: "npm:^8.0.0" y-protocols: "npm:^1.0.6" peerDependencies: yjs: ^13 - checksum: 10/85e81278a162f9b4f8c57caf00b50eeabd506d61cb139790a753a46b063ad815e5da92e0d326487919517605604254339fb55c45d24fb23e3c56e87d1454d640 + checksum: 10/d450a952c42508b90c4fb90ed57964ba1d8d575b4318f4739ee2b3bbedd1fb1421bb8dc98c41574658199ac2ca718305cc7351b684330ead966c1ab86cb58b3d languageName: node linkType: hard @@ -13178,11 +13179,11 @@ __metadata: "@affine/debug": "workspace:*" "@affine/env": "workspace:*" "@affine/templates": "workspace:*" - "@blocksuite/blocks": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/lit": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/presets": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/blocks": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/lit": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/presets": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" "@testing-library/react": "npm:^14.2.1" async-call-rpc: "npm:^6.4.0" foxact: "npm:^0.2.31" @@ -13232,9 +13233,9 @@ __metadata: version: 0.0.0-use.local resolution: "@toeverything/y-indexeddb@workspace:packages/common/y-indexeddb" dependencies: - "@blocksuite/blocks": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/global": "npm:0.12.0-canary-202402220729-0868ac6" - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/blocks": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/global": "npm:0.12.0-canary-202402271448-6d3a709" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" fake-indexeddb: "npm:^5.0.2" idb: "npm:^8.0.0" nanoid: "npm:^5.0.6" @@ -14259,6 +14260,13 @@ __metadata: languageName: node linkType: hard +"@types/sortablejs@npm:^1.15.7": + version: 1.15.8 + resolution: "@types/sortablejs@npm:1.15.8" + checksum: 10/aea58b08cf45f5e9633707a8df0df1212595c731bbdfd29805487138fdd0d8c51fa5c741999738a645c1e801d43a92ba0d3fb5b45625b52e247c56588aef6c55 + languageName: node + linkType: hard + "@types/stack-utils@npm:^2.0.0": version: 2.0.3 resolution: "@types/stack-utils@npm:2.0.3" @@ -35565,7 +35573,7 @@ __metadata: version: 0.0.0-use.local resolution: "y-provider@workspace:packages/common/y-provider" dependencies: - "@blocksuite/store": "npm:0.12.0-canary-202402220729-0868ac6" + "@blocksuite/store": "npm:0.12.0-canary-202402271448-6d3a709" vite: "npm:^5.1.4" vite-plugin-dts: "npm:3.7.3" vitest: "npm:1.3.1"