There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(editor): merge store and blocks (#9591)
Saul-Mirone5842d45ab104
diff --git a/blocksuite/affine/block-data-view/src/data-source.ts b/blocksuite/affine/block-data-view/src/data-source.tsindex 1d0a76d9a8..871e8af952 100644--- a/blocksuite/affine/block-data-view/src/data-source.ts+++ b/blocksuite/affine/block-data-view/src/data-source.ts@@ -11,7 +11,7 @@ import type { EditorHost } from '@blocksuite/block-std';import { DataSourceBase, type PropertyMetaConfig } from '@blocksuite/data-view';import { propertyPresets } from '@blocksuite/data-view/property-presets';import { assertExists, Slot } from '@blocksuite/global/utils';-import type { Block, Blocks } from '@blocksuite/store';+import type { Block, Store } from '@blocksuite/store';import type { BlockMeta } from './block-meta/base.js';import { blockMetaMap } from './block-meta/index.js';@@ -73,14 +73,14 @@ export class BlockQueryDataSource extends DataSourceBase {this.columnMetaMap.set(property.metaConfig.type, property.metaConfig);}for (const collection of this.workspace.docs.values()) {- for (const block of Object.values(collection.getBlocks().blocks.peek())) {+ for (const block of Object.values(collection.getStore().blocks.peek())) {if (this.meta.selector(block)) {this.blockMap.set(block.id, block);}}}this.workspace.docs.forEach(doc => {- this.listenToDoc(doc.getBlocks());+ this.listenToDoc(doc.getStore());});this.workspace.slots.docCreated.on(id => {const doc = this.workspace.getDoc(id);@@ -140,7 +140,7 @@ export class BlockQueryDataSource extends DataSourceBase {return this.block.columns.find(v => v.id === id);}- listenToDoc(doc: Blocks) {+ listenToDoc(doc: Store) {this.docDisposeMap.set(doc.id,doc.slots.blockUpdated.on(v => {diff --git a/blocksuite/affine/block-database/src/database-service.ts b/blocksuite/affine/block-database/src/database-service.tsindex 86dd8fb6c1..7cbda707b7 100644--- a/blocksuite/affine/block-database/src/database-service.ts+++ b/blocksuite/affine/block-database/src/database-service.ts@@ -4,7 +4,7 @@ import {} from '@blocksuite/affine-model';import { BlockService } from '@blocksuite/block-std';import { viewPresets } from '@blocksuite/data-view/view-presets';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import {databaseViewAddView,@@ -36,7 +36,7 @@ export class DatabaseBlockService extends BlockService {viewPresets = viewPresets;initDatabaseBlock(- doc: Blocks,+ doc: Store,model: BlockModel,databaseId: string,viewType: string,diff --git a/blocksuite/affine/block-embed/src/common/render-linked-doc.ts b/blocksuite/affine/block-embed/src/common/render-linked-doc.tsindex 9848889c6f..d8dd970882 100644--- a/blocksuite/affine/block-embed/src/common/render-linked-doc.ts+++ b/blocksuite/affine/block-embed/src/common/render-linked-doc.ts@@ -11,12 +11,11 @@ import { BlockStdScope } from '@blocksuite/block-std';import { assertExists } from '@blocksuite/global/utils';import {type BlockModel,- type Blocks,type BlockSnapshot,type DraftModel,type Query,Slice,- Store,+ type Store,Text,} from '@blocksuite/store';import { render, type TemplateResult } from 'lit';@@ -196,11 +195,10 @@ async function renderNoteContent(mode: 'strict',match: ids.map(id => ({ id, viewType: 'display' })),};- const previewDoc = doc.doc.getBlocks({ query });+ const previewDoc = doc.doc.getStore({ query });const previewSpec = SpecProvider.getInstance().getSpec('page:preview');- const store = new Store({ blocks: previewDoc });const previewStd = new BlockStdScope({- store,+ store: previewDoc,extensions: previewSpec.value,});const previewTemplate = previewStd.render();@@ -222,7 +220,7 @@ function filterTextModel(model: BlockModel) {return false;}-export function getNotesFromDoc(doc: Blocks) {+export function getNotesFromDoc(doc: Store) {const notes = doc.root?.children.filter(child =>matchFlavours(child, ['affine:note']) &&@@ -236,7 +234,7 @@ export function getNotesFromDoc(doc: Blocks) {return notes;}-export function isEmptyDoc(doc: Blocks | null, mode: DocMode) {+export function isEmptyDoc(doc: Store | null, mode: DocMode) {if (!doc) {return true;}@@ -268,7 +266,7 @@ export function isEmptyNote(note: BlockModel) {/*** Gets the document content with a max length.*/-export function getDocContentWithMaxLength(doc: Blocks, maxlength = 500) {+export function getDocContentWithMaxLength(doc: Store, maxlength = 500) {const notes = getNotesFromDoc(doc);if (!notes) return;@@ -328,7 +326,7 @@ export function promptDocTitle(std: BlockStdScope, autofill?: string) {});}-export function notifyDocCreated(std: BlockStdScope, doc: Blocks) {+export function notifyDocCreated(std: BlockStdScope, doc: Store) {const notification = std.getOptional(NotificationProvider);if (!notification) return;@@ -367,7 +365,7 @@ export function notifyDocCreated(std: BlockStdScope, doc: Blocks) {export async function convertSelectedBlocksToLinkedDoc(std: BlockStdScope,- doc: Blocks,+ doc: Store,selectedModels: DraftModel[] | Promise<DraftModel[]>,docTitle?: string) {@@ -401,7 +399,7 @@ export async function convertSelectedBlocksToLinkedDoc(export function createLinkedDocFromSlice(std: BlockStdScope,- doc: Blocks,+ doc: Store,snapshots: BlockSnapshot[],docTitle?: string) {diff --git a/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-edgeless-synced-doc-block.ts b/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-edgeless-synced-doc-block.tsindex 4a0e5827fa..54cd506cb2 100644--- a/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-edgeless-synced-doc-block.ts+++ b/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-edgeless-synced-doc-block.ts@@ -10,7 +10,6 @@ import {} from '@blocksuite/affine-shared/services';import { BlockSelection, BlockStdScope } from '@blocksuite/block-std';import { Bound } from '@blocksuite/global/utils';-import { Store } from '@blocksuite/store';import { html, nothing } from 'lit';import { choose } from 'lit/directives/choose.js';import { classMap } from 'lit/directives/class-map.js';@@ -31,8 +30,6 @@ export class EmbedEdgelessSyncedDocBlockComponent extends toEdgelessEmbedBlock(return html`${nothing}`;}- const store = new Store({ blocks: syncedDoc });-let containerStyleMap = styleMap({position: 'relative',width: '100%',@@ -70,7 +67,7 @@ export class EmbedEdgelessSyncedDocBlockComponent extends toEdgelessEmbedBlock(() => html`<div class="affine-page-viewport" data-theme=${appTheme}>${new BlockStdScope({- store,+ store: syncedDoc,extensions: this._buildPreviewSpec('page:preview'),}).render()}</div>@@ -81,7 +78,7 @@ export class EmbedEdgelessSyncedDocBlockComponent extends toEdgelessEmbedBlock(() => html`<div class="affine-edgeless-viewport" data-theme=${edgelessTheme}>${new BlockStdScope({- store,+ store: syncedDoc,extensions: this._buildPreviewSpec('edgeless:preview'),}).render()}</div>diff --git a/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.ts b/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.tsindex 0659256534..636a2f5f07 100644--- a/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.ts+++ b/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.ts@@ -26,12 +26,7 @@ import {} from '@blocksuite/block-std';import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';import { assertExists, Bound, getCommonBound } from '@blocksuite/global/utils';-import {- type GetBlocksOptions,- type Query,- Store,- Text,-} from '@blocksuite/store';+import { type GetBlocksOptions, type Query, Text } from '@blocksuite/store';import { computed } from '@preact/signals-core';import { html, nothing, type PropertyValues } from 'lit';import { query, state } from 'lit/decorators.js';@@ -156,8 +151,6 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSyncereturn html`${nothing}`;}- const store = new Store({ blocks: syncedDoc });-if (isPageMode) {this.dataset.pageMode = '';}@@ -186,7 +179,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce() => html`<div class="affine-page-viewport" data-theme=${appTheme}>${new BlockStdScope({- store,+ store: syncedDoc,extensions: this._buildPreviewSpec('page:preview'),}).render()}</div>@@ -197,7 +190,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce() => html`<div class="affine-edgeless-viewport" data-theme=${edgelessTheme}>${new BlockStdScope({- store,+ store: syncedDoc,extensions: this._buildPreviewSpec('edgeless:preview'),}).render()}</div>diff --git a/blocksuite/affine/block-list/src/commands/utils.ts b/blocksuite/affine/block-list/src/commands/utils.tsindex a1f73ff842..c03e2faf41 100644--- a/blocksuite/affine/block-list/src/commands/utils.ts+++ b/blocksuite/affine/block-list/src/commands/utils.ts@@ -3,7 +3,7 @@ import {getNextContinuousNumberedLists,matchFlavours,} from '@blocksuite/affine-shared/utils';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';/*** correct target is a numbered list, which is divided into two steps:@@ -12,7 +12,7 @@ import type { BlockModel, Blocks } from '@blocksuite/store';* 2. find continuous lists starting from the target list and keep their order continuous*/export function correctNumberedListsOrderToPrev(- doc: Blocks,+ doc: Store,modelOrId: BlockModel | string,transact = true) {@@ -58,7 +58,7 @@ export function correctNumberedListsOrderToPrev(}}-export function correctListOrder(doc: Blocks, model: ListBlockModel) {+export function correctListOrder(doc: Store, model: ListBlockModel) {// old numbered list has no orderif (model.type === 'numbered' && !Number.isInteger(model.order)) {correctNumberedListsOrderToPrev(doc, model, false);diff --git a/blocksuite/affine/block-surface-ref/src/portal/note.ts b/blocksuite/affine/block-surface-ref/src/portal/note.tsindex dcab7ed774..c560eeaa26 100644--- a/blocksuite/affine/block-surface-ref/src/portal/note.ts+++ b/blocksuite/affine/block-surface-ref/src/portal/note.ts@@ -18,7 +18,7 @@ import {ShadowlessElement,} from '@blocksuite/block-std';import { deserializeXYWH, WithDisposable } from '@blocksuite/global/utils';-import { type BlockModel, type Query, Store } from '@blocksuite/store';+import { type BlockModel, type Query } from '@blocksuite/store';import { css, nothing } from 'lit';import { property } from 'lit/decorators.js';import { styleMap } from 'lit/directives/style-map.js';@@ -114,14 +114,13 @@ export class SurfaceRefNotePortal extends WithDisposable(ShadowlessElement) {console.error('Query is not set before rendering note preview');return nothing;}- const doc = this.model.doc.doc.getBlocks({+ const doc = this.model.doc.doc.getStore({query: this.query,readonly: true,});- const store = new Store({ blocks: doc });const previewSpec = SpecProvider.getInstance().getSpec('page:preview');return new BlockStdScope({- store,+ store: doc,extensions: previewSpec.value.slice(),}).render();}diff --git a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts b/blocksuite/affine/block-surface-ref/src/surface-ref-block.tsindex f66a68012e..2ea8513ca8 100644--- a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts+++ b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts@@ -47,7 +47,7 @@ import {DisposableGroup,type SerializedXYWH,} from '@blocksuite/global/utils';-import { type Blocks, Store } from '@blocksuite/store';+import { type Store } from '@blocksuite/store';import { css, html, nothing, type TemplateResult } from 'lit';import { query, state } from 'lit/decorators.js';import { styleMap } from 'lit/directives/style-map.js';@@ -240,7 +240,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode}`;- private _previewDoc: Blocks | null = null;+ private _previewDoc: Store | null = null;private readonly _previewSpec =SpecProvider.getInstance().getSpec('edgeless:preview');@@ -339,7 +339,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode}const doc = [...this.std.workspace.docs.values()]- .map(doc => doc.getBlocks())+ .map(doc => doc.getStore()).find(doc =>doc.getBlock(this.model.reference) ||@@ -546,9 +546,8 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockModeif (!this._viewportEditor) {if (this._previewDoc) {- const store = new Store({ blocks: this._previewDoc });this._viewportEditor = new BlockStdScope({- store,+ store: this._previewDoc,extensions: _previewSpec,}).render();} else {diff --git a/blocksuite/affine/block-surface/src/utils/get-surface-block.ts b/blocksuite/affine/block-surface/src/utils/get-surface-block.tsindex 6123a21210..676ab0eefc 100644--- a/blocksuite/affine/block-surface/src/utils/get-surface-block.ts+++ b/blocksuite/affine/block-surface/src/utils/get-surface-block.ts@@ -1,8 +1,8 @@-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import type { SurfaceBlockModel } from '../surface-model';-export function getSurfaceBlock(doc: Blocks) {+export function getSurfaceBlock(doc: Store) {const blocks = doc.getBlocksByFlavour('affine:surface');return blocks.length !== 0 ? (blocks[0].model as SurfaceBlockModel) : null;}diff --git a/blocksuite/affine/components/src/caption/block-caption.ts b/blocksuite/affine/components/src/caption/block-caption.tsindex d6fdb30e4f..b1370e87fd 100644--- a/blocksuite/affine/components/src/caption/block-caption.ts+++ b/blocksuite/affine/components/src/caption/block-caption.ts@@ -8,7 +8,7 @@ import {stdContext,} from '@blocksuite/block-std';import { WithDisposable } from '@blocksuite/global/utils';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { Text } from '@blocksuite/store';import { consume } from '@lit/context';import { css, html, nothing } from 'lit';@@ -161,7 +161,7 @@ export class BlockCaptionEditor<accessor display = false;@consume({ context: docContext })- accessor doc!: Blocks;+ accessor doc!: Store;@query('.block-caption-editor')accessor input!: HTMLInputElement;diff --git a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-node.ts b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-node.tsindex 78280dee1e..b9b3f3ecce 100644--- a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-node.ts+++ b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-node.ts@@ -26,7 +26,7 @@ import {ZERO_WIDTH_NON_JOINER,ZERO_WIDTH_SPACE,} from '@blocksuite/inline';-import type { Blocks, DocMeta } from '@blocksuite/store';+import type { DocMeta, Store } from '@blocksuite/store';import { css, html, nothing } from 'lit';import { property, state } from 'lit/decorators.js';import { choose } from 'lit/directives/choose.js';@@ -73,7 +73,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {}`;- private readonly _updateRefMeta = (doc: Blocks) => {+ private readonly _updateRefMeta = (doc: Store) => {const refAttribute = this.delta.attributes?.reference;if (!refAttribute) {return;diff --git a/blocksuite/affine/components/src/toolbar/menu-context.ts b/blocksuite/affine/components/src/toolbar/menu-context.tsindex f43b00431d..0f0f2dff8b 100644--- a/blocksuite/affine/components/src/toolbar/menu-context.ts+++ b/blocksuite/affine/components/src/toolbar/menu-context.ts@@ -1,9 +1,9 @@import type { BlockStdScope, EditorHost } from '@blocksuite/block-std';import type { GfxModel } from '@blocksuite/block-std/gfx';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';export abstract class MenuContext {- abstract get doc(): Blocks;+ abstract get doc(): Store;get firstElement(): GfxModel | null {return null;diff --git a/blocksuite/affine/shared/src/services/doc-display-meta-service.ts b/blocksuite/affine/shared/src/services/doc-display-meta-service.tsindex c7b2247b9c..56f62caed0 100644--- a/blocksuite/affine/shared/src/services/doc-display-meta-service.ts+++ b/blocksuite/affine/shared/src/services/doc-display-meta-service.ts@@ -11,7 +11,7 @@ import {LinkedPageIcon,PageIcon,} from '@blocksuite/icons/lit';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { computed, type Signal, signal } from '@preact/signals-core';import type { TemplateResult } from 'lit';@@ -70,9 +70,9 @@ export class DocDisplayMetaServicereadonly disposables: Disposable[] = [];- readonly iconMap = new WeakMap<Blocks, Signal<TemplateResult>>();+ readonly iconMap = new WeakMap<Store, Signal<TemplateResult>>();- readonly titleMap = new WeakMap<Blocks, Signal<string>>();+ readonly titleMap = new WeakMap<Store, Signal<string>>();static override setup(di: Container) {di.addImpl(DocDisplayMetaProvider, this, [StdIdentifier]);diff --git a/blocksuite/affine/shared/src/utils/model/checker.ts b/blocksuite/affine/shared/src/utils/model/checker.tsindex 48f59be8ee..8145fe9d51 100644--- a/blocksuite/affine/shared/src/utils/model/checker.ts+++ b/blocksuite/affine/shared/src/utils/model/checker.ts@@ -1,4 +1,4 @@-import type { BlockModel, Blocks, DraftModel } from '@blocksuite/store';+import type { BlockModel, DraftModel, Store } from '@blocksuite/store';import { minimatch } from 'minimatch';export function matchFlavours<Key extends (keyof BlockSuite.BlockModels)[]>(@@ -14,7 +14,7 @@ export function matchFlavours<Key extends (keyof BlockSuite.BlockModels)[]>(}export function isInsideBlockByFlavour(- doc: Blocks,+ doc: Store,block: BlockModel | string,flavour: string): boolean {diff --git a/blocksuite/affine/shared/src/utils/model/getter.ts b/blocksuite/affine/shared/src/utils/model/getter.tsindex 579a235192..3479d54bb8 100644--- a/blocksuite/affine/shared/src/utils/model/getter.ts+++ b/blocksuite/affine/shared/src/utils/model/getter.ts@@ -1,6 +1,6 @@import { type NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';import type { BlockComponent, EditorHost } from '@blocksuite/block-std';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { matchFlavours } from './checker.js';@@ -41,7 +41,7 @@ export function findNoteBlockModel(model: BlockModel) {) as NoteBlockModel | null;}-export function getLastNoteBlock(doc: Blocks) {+export function getLastNoteBlock(doc: Store) {let note: NoteBlockModel | null = null;if (!doc.root) return null;const { children } = doc.root;diff --git a/blocksuite/affine/shared/src/utils/model/list.ts b/blocksuite/affine/shared/src/utils/model/list.tsindex f4c5efebac..08c84a02d8 100644--- a/blocksuite/affine/shared/src/utils/model/list.ts+++ b/blocksuite/affine/shared/src/utils/model/list.ts@@ -1,6 +1,6 @@import type { ListBlockModel } from '@blocksuite/affine-model';import type { BlockStdScope } from '@blocksuite/block-std';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { matchFlavours } from './checker.js';@@ -9,7 +9,7 @@ import { matchFlavours } from './checker.js';* typically used for updating list numbers. The result not contains the list passed in.*/export function getNextContinuousNumberedLists(- doc: Blocks,+ doc: Store,modelOrId: BlockModel | string): ListBlockModel[] {const model =diff --git a/blocksuite/affine/shared/src/utils/model/transform-model.ts b/blocksuite/affine/shared/src/utils/model/transform-model.tsindex b29429bc31..5f5d770e67 100644--- a/blocksuite/affine/shared/src/utils/model/transform-model.ts+++ b/blocksuite/affine/shared/src/utils/model/transform-model.ts@@ -1,9 +1,9 @@-import type { BlockModel, Blocks, Text } from '@blocksuite/store';+import type { BlockModel, Store, Text } from '@blocksuite/store';export function transformModel(model: BlockModel,flavour: BlockSuite.Flavour,- props?: Parameters<Blocks['addBlock']>[1]+ props?: Parameters<Store['addBlock']>[1]) {const doc = model.doc;const parent = doc.getParent(model);diff --git a/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.ts b/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.tsindex 86daa58e20..3962a8114a 100644--- a/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.ts+++ b/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.ts@@ -5,7 +5,7 @@ import {type DndEventState,} from '@blocksuite/block-std';import { Point } from '@blocksuite/global/utils';-import { type BlockViewType, type Query, Store } from '@blocksuite/store';+import { type BlockViewType, type Query } from '@blocksuite/store';import { DragPreview } from '../components/drag-preview.js';import type { AffineDragHandleWidget } from '../drag-handle.js';@@ -79,10 +79,9 @@ export class PreviewHelper {const query = this._calculateQuery(selectedIds);- const doc = this.widget.doc.doc.getBlocks({ query });+ const store = this.widget.doc.doc.getStore({ query });const previewSpec = SpecProvider.getInstance().getSpec('page:preview');- const store = new Store({ blocks: doc });const previewStd = new BlockStdScope({store,extensions: previewSpec.value,diff --git a/blocksuite/blocks/src/__tests__/database/database.unit.spec.ts b/blocksuite/blocks/src/__tests__/database/database.unit.spec.tsindex 8fd722853e..dbea86008c 100644--- a/blocksuite/blocks/src/__tests__/database/database.unit.spec.ts+++ b/blocksuite/blocks/src/__tests__/database/database.unit.spec.ts@@ -17,7 +17,7 @@ import {RootBlockSchema,} from '@blocksuite/affine-model';import { propertyModelPresets } from '@blocksuite/data-view/property-pure-presets';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { Schema, Text } from '@blocksuite/store';import {createAutoIncrementIdGenerator,@@ -49,7 +49,7 @@ function createTestDoc(docId = 'doc0') {}describe('DatabaseManager', () => {- let doc: Blocks;+ let doc: Store;let db: DatabaseBlockModel;let rootId: BlockModel['id'];diff --git a/blocksuite/blocks/src/_common/export-manager/export-manager.ts b/blocksuite/blocks/src/_common/export-manager/export-manager.tsindex e5c60d1b34..ea249c1210 100644--- a/blocksuite/blocks/src/_common/export-manager/export-manager.ts+++ b/blocksuite/blocks/src/_common/export-manager/export-manager.ts@@ -24,7 +24,7 @@ import type { GfxBlockElementModel } from '@blocksuite/block-std/gfx';import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';import type { IBound } from '@blocksuite/global/utils';import { Bound } from '@blocksuite/global/utils';-import type { Blocks, ExtensionType } from '@blocksuite/store';+import type { ExtensionType, Store } from '@blocksuite/store';import {getBlockComponentByModel,@@ -109,7 +109,7 @@ export class ExportManager {await Promise.all(promises);};- get doc(): Blocks {+ get doc(): Store {return this.std.doc;}diff --git a/blocksuite/blocks/src/_common/transformers/html.ts b/blocksuite/blocks/src/_common/transformers/html.tsindex 86f072324f..87fe35200e 100644--- a/blocksuite/blocks/src/_common/transformers/html.ts+++ b/blocksuite/blocks/src/_common/transformers/html.ts@@ -1,7 +1,7 @@import { HtmlAdapter } from '@blocksuite/affine-shared/adapters';import { Container } from '@blocksuite/global/di';import { sha } from '@blocksuite/global/utils';-import type { Blocks, Workspace } from '@blocksuite/store';+import type { Store, Workspace } from '@blocksuite/store';import { extMimeMap, Job } from '@blocksuite/store';import { defaultBlockHtmlAdapterMatchers } from '../adapters/html/block-matcher.js';@@ -43,7 +43,7 @@ const provider = container.provider();* @param doc - The doc to be exported.* @returns A Promise that resolves when the export is complete.*/-async function exportDoc(doc: Blocks) {+async function exportDoc(doc: Store) {const job = new Job({schema: doc.schema,blobCRUD: doc.blobSync,diff --git a/blocksuite/blocks/src/_common/transformers/markdown.ts b/blocksuite/blocks/src/_common/transformers/markdown.tsindex 0a503532d1..b50c9f5da5 100644--- a/blocksuite/blocks/src/_common/transformers/markdown.ts+++ b/blocksuite/blocks/src/_common/transformers/markdown.ts@@ -2,7 +2,7 @@ import { MarkdownAdapter } from '@blocksuite/affine-shared/adapters';import { Container } from '@blocksuite/global/di';import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';import { assertExists, sha } from '@blocksuite/global/utils';-import type { Blocks, Workspace } from '@blocksuite/store';+import type { Store, Workspace } from '@blocksuite/store';import { extMimeMap, Job } from '@blocksuite/store';import { defaultBlockMarkdownAdapterMatchers } from '../adapters/index.js';@@ -28,7 +28,7 @@ const container = new Container();const provider = container.provider();type ImportMarkdownToBlockOptions = {- doc: Blocks;+ doc: Store;markdown: string;blockId: string;};@@ -49,7 +49,7 @@ type ImportMarkdownZipOptions = {* @param doc The doc to export* @returns A Promise that resolves when the export is complete*/-async function exportDoc(doc: Blocks) {+async function exportDoc(doc: Store) {const job = new Job({schema: doc.schema,blobCRUD: doc.blobSync,diff --git a/blocksuite/blocks/src/_common/transformers/zip.ts b/blocksuite/blocks/src/_common/transformers/zip.tsindex 27da2aed05..48a2672b66 100644--- a/blocksuite/blocks/src/_common/transformers/zip.ts+++ b/blocksuite/blocks/src/_common/transformers/zip.ts@@ -1,11 +1,11 @@import { sha } from '@blocksuite/global/utils';-import type { Blocks, DocSnapshot, Workspace } from '@blocksuite/store';+import type { DocSnapshot, Store, Workspace } from '@blocksuite/store';import { extMimeMap, getAssetName, Job } from '@blocksuite/store';import { download, Unzip, Zip } from '../transformers/utils.js';import { replaceIdMiddleware, titleMiddleware } from './middlewares.js';-async function exportDocs(collection: Workspace, docs: Blocks[]) {+async function exportDocs(collection: Workspace, docs: Store[]) {const zip = new Zip();const job = new Job({schema: collection.schema,diff --git a/blocksuite/blocks/src/_common/types.ts b/blocksuite/blocks/src/_common/types.tsindex 03dba901c2..846a40ce60 100644--- a/blocksuite/blocks/src/_common/types.ts+++ b/blocksuite/blocks/src/_common/types.ts@@ -5,7 +5,7 @@ import type {GroupElementModel,} from '@blocksuite/affine-model';import type { Slot } from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';/** Common context interface definition for block models. */@@ -14,7 +14,7 @@ type EditorSlots = {};export type AbstractEditor = {- doc: Blocks;+ doc: Store;mode: DocMode;readonly slots: EditorSlots;} & HTMLElement;diff --git a/blocksuite/blocks/src/root-block/clipboard/index.ts b/blocksuite/blocks/src/root-block/clipboard/index.tsindex 6f0305eac9..f1f6e329a4 100644--- a/blocksuite/blocks/src/root-block/clipboard/index.ts+++ b/blocksuite/blocks/src/root-block/clipboard/index.ts@@ -9,7 +9,7 @@ import {} from '@blocksuite/affine-shared/adapters';import type { BlockComponent, UIEventHandler } from '@blocksuite/block-std';import { DisposableGroup } from '@blocksuite/global/utils';-import type { Blocks, BlockSnapshot } from '@blocksuite/store';+import type { BlockSnapshot, Store } from '@blocksuite/store';import {defaultImageProxyMiddleware,@@ -99,7 +99,7 @@ export class PageClipboard {onBlockSnapshotPaste = async (snapshot: BlockSnapshot,- doc: Blocks,+ doc: Store,parent?: string,index?: number) => {diff --git a/blocksuite/blocks/src/root-block/edgeless/components/connector/connector-handle.ts b/blocksuite/blocks/src/root-block/edgeless/components/connector/connector-handle.tsindex e7637c7d56..327b49326b 100644--- a/blocksuite/blocks/src/root-block/edgeless/components/connector/connector-handle.ts+++ b/blocksuite/blocks/src/root-block/edgeless/components/connector/connector-handle.ts@@ -10,7 +10,7 @@ import {} from '@blocksuite/block-std';import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';import { DisposableGroup, Vec, WithDisposable } from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { consume } from '@lit/context';import { css, html, LitElement } from 'lit';import { property, query } from 'lit/decorators.js';@@ -150,7 +150,7 @@ export class EdgelessConnectorHandle extends WithDisposable(LitElement) {@consume({context: docContext,})- accessor doc!: Blocks;+ accessor doc!: Store;@property({ attribute: false })accessor edgeless!: EdgelessRootBlockComponent;diff --git a/blocksuite/blocks/src/root-block/edgeless/components/frame/frame-preview.ts b/blocksuite/blocks/src/root-block/edgeless/components/frame/frame-preview.tsindex 3f52a5611c..bae27bbdc6 100644--- a/blocksuite/blocks/src/root-block/edgeless/components/frame/frame-preview.ts+++ b/blocksuite/blocks/src/root-block/edgeless/components/frame/frame-preview.ts@@ -12,7 +12,7 @@ import {DisposableGroup,WithDisposable,} from '@blocksuite/global/utils';-import { type Blocks, type Query, Store } from '@blocksuite/store';+import { type Query, type Store } from '@blocksuite/store';import { css, html, nothing, type PropertyValues } from 'lit';import { property, query, state } from 'lit/decorators.js';import { styleMap } from 'lit/directives/style-map.js';@@ -78,7 +78,7 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {private _frameDisposables: DisposableGroup | null = null;- private _previewDoc: Blocks | null = null;+ private _previewDoc: Store | null = null;private readonly _previewSpec =SpecProvider.getInstance().getSpec('edgeless:preview');@@ -155,7 +155,6 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {private _renderSurfaceContent() {if (!this._previewDoc || !this.frame) return nothing;const { width, height } = this.frameViewportWH;- const store = new Store({ blocks: this._previewDoc });const _previewSpec = this._previewSpec.value;return html`<div@@ -173,7 +172,7 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {})}>${new BlockStdScope({- store,+ store: this._previewDoc,extensions: _previewSpec,}).render()}</div>diff --git a/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts b/blocksuite/blocks/src/root-block/edgeless/frame-manager.tsindex 0302b43830..b25b0d1bfb 100644--- a/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts+++ b/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts@@ -19,7 +19,7 @@ import {type IVec,type SerializedXYWH,} from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { Text } from '@blocksuite/store';import * as Y from 'yjs';@@ -463,7 +463,7 @@ export class EdgelessFrameManager extends GfxExtension {}export function getNotesInFrameBound(- doc: Blocks,+ doc: Store,frame: FrameBlockModel,fullyContained: boolean = true) {@@ -481,7 +481,7 @@ export function getNotesInFrameBound(}export function getBlocksInFrameBound(- doc: Blocks,+ doc: Store,model: FrameBlockModel,fullyContained: boolean = true) {diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.tsindex 4f68d879bf..415e05300b 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.ts@@ -5,7 +5,7 @@ import { DocModeProvider } from '@blocksuite/affine-shared/services';import { getBlockProps } from '@blocksuite/affine-shared/utils';import type { EditorHost } from '@blocksuite/block-std';import { GfxBlockElementModel } from '@blocksuite/block-std/gfx';-import { type BlockModel, type Blocks, Text } from '@blocksuite/store';+import { type BlockModel, type Store, Text } from '@blocksuite/store';import {getElementProps,@@ -14,11 +14,7 @@ import {} from '../../../edgeless/utils/clone-utils.js';import { isFrameBlock, isNoteBlock } from '../../../edgeless/utils/query.js';-function addBlocksToDoc(- targetDoc: Blocks,- model: BlockModel,- parentId: string-) {+function addBlocksToDoc(targetDoc: Store, model: BlockModel, parentId: string) {// Add current block to linked docconst blockProps = getBlockProps(model);const newModelId = targetDoc.addBlock(@@ -36,7 +32,7 @@ function addBlocksToDoc(}export function createLinkedDocFromNote(- doc: Blocks,+ doc: Store,note: NoteBlockModel,docTitle?: string) {diff --git a/blocksuite/framework/block-std/src/__tests__/test-editor.ts b/blocksuite/framework/block-std/src/__tests__/test-editor.tsindex 718f7230ff..1deec7e642 100644--- a/blocksuite/framework/block-std/src/__tests__/test-editor.ts+++ b/blocksuite/framework/block-std/src/__tests__/test-editor.ts@@ -1,5 +1,5 @@import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';-import { type Blocks, type ExtensionType, Store } from '@blocksuite/store';+import type { ExtensionType, Store } from '@blocksuite/store';import { html } from 'lit';import { customElement, property } from 'lit/decorators.js';@@ -18,9 +18,8 @@ export class TestEditorContainer extends SignalWatcher(override connectedCallback() {super.connectedCallback();- const store = new Store({ blocks: this.doc });this._std = new BlockStdScope({- store,+ store: this.doc,extensions: this.specs,});}@@ -32,7 +31,7 @@ export class TestEditorContainer extends SignalWatcher(}@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;@property({ attribute: false })accessor specs: ExtensionType[] = [];diff --git a/blocksuite/framework/block-std/src/clipboard/index.ts b/blocksuite/framework/block-std/src/clipboard/index.tsindex f86799e2f1..ce610b4665 100644--- a/blocksuite/framework/block-std/src/clipboard/index.ts+++ b/blocksuite/framework/block-std/src/clipboard/index.ts@@ -2,11 +2,11 @@ import type { ServiceProvider } from '@blocksuite/global/di';import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';import type {BaseAdapter,- Blocks,BlockSnapshot,Job,JobMiddleware,Slice,+ Store,} from '@blocksuite/store';import DOMPurify from 'dompurify';import type { RootContentMap } from 'hast';@@ -110,7 +110,7 @@ export class Clipboard extends LifeCycleWatcher {private readonly _getSnapshotByPriority = async (getItem: (type: string) => string | File[],- doc: Blocks,+ doc: Store,parent?: string,index?: number) => {@@ -182,7 +182,7 @@ export class Clipboard extends LifeCycleWatcher {duplicateSlice = async (slice: Slice,- doc: Blocks,+ doc: Store,parent?: string,index?: number,type = 'BLOCKSUITE/SNAPSHOT'@@ -201,7 +201,7 @@ export class Clipboard extends LifeCycleWatcher {paste = async (event: ClipboardEvent,- doc: Blocks,+ doc: Store,parent?: string,index?: number) => {@@ -238,7 +238,7 @@ export class Clipboard extends LifeCycleWatcher {pasteBlockSnapshot = async (snapshot: BlockSnapshot,- doc: Blocks,+ doc: Store,parent?: string,index?: number) => {diff --git a/blocksuite/framework/block-std/src/gfx/grid.ts b/blocksuite/framework/block-std/src/gfx/grid.tsindex 3a1a77e824..6db5a420ac 100644--- a/blocksuite/framework/block-std/src/gfx/grid.ts+++ b/blocksuite/framework/block-std/src/gfx/grid.ts@@ -4,7 +4,7 @@ import {getBoundWithRotation,intersects,} from '@blocksuite/global/utils';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { compare } from '../utils/layer.js';import { GfxBlockElementModel } from './model/gfx-block-model.js';@@ -361,7 +361,7 @@ export class GridManager {this.add(element);}- watch(blocks: { doc?: Blocks; surface?: SurfaceBlockModel | null }) {+ watch(blocks: { doc?: Store; surface?: SurfaceBlockModel | null }) {const disposables: { dispose: () => void }[] = [];const { doc, surface } = blocks;const isRenderableBlock = (diff --git a/blocksuite/framework/block-std/src/gfx/layer.ts b/blocksuite/framework/block-std/src/gfx/layer.tsindex a7f7262c48..f280476c5c 100644--- a/blocksuite/framework/block-std/src/gfx/layer.ts+++ b/blocksuite/framework/block-std/src/gfx/layer.ts@@ -5,7 +5,7 @@ import {last,Slot,} from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { generateKeyBetween } from 'fractional-indexing';import {@@ -100,7 +100,7 @@ export class LayerManager {};constructor(- private readonly _doc: Blocks,+ private readonly _doc: Store,private _surface: SurfaceBlockModel | null,options: {watch: boolean;@@ -476,7 +476,7 @@ export class LayerManager {private _reset() {const elements = (this._doc- .getBlocks()+ .getStore().filter(model =>model instanceof GfxBlockElementModel &&@@ -775,7 +775,7 @@ export class LayerManager {}}- watch(blocks: { doc?: Blocks; surface: SurfaceBlockModel | null }) {+ watch(blocks: { doc?: Store; surface: SurfaceBlockModel | null }) {const { doc, surface } = blocks;if (doc) {diff --git a/blocksuite/framework/block-std/src/scope/block-std-scope.ts b/blocksuite/framework/block-std/src/scope/block-std-scope.tsindex 8805fb1192..78ba90ab9a 100644--- a/blocksuite/framework/block-std/src/scope/block-std-scope.ts+++ b/blocksuite/framework/block-std/src/scope/block-std-scope.ts@@ -75,7 +75,7 @@ export class BlockStdScope {}get doc() {- return this.store.blocks;+ return this.store;}get clipboard() {diff --git a/blocksuite/framework/block-std/src/utils/gfx.ts b/blocksuite/framework/block-std/src/utils/gfx.tsindex 30ac57ece9..1744edf8b3 100644--- a/blocksuite/framework/block-std/src/utils/gfx.ts+++ b/blocksuite/framework/block-std/src/utils/gfx.ts@@ -1,10 +1,10 @@-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { effect } from '@preact/signals-core';import { SurfaceBlockModel } from '../gfx/model/surface/surface-model.js';export function onSurfaceAdded(- doc: Blocks,+ doc: Store,callback: (model: SurfaceBlockModel | null) => void) {let found = false;diff --git a/blocksuite/framework/block-std/src/utils/layer.ts b/blocksuite/framework/block-std/src/utils/layer.tsindex a950eb85b9..0b71b31e1b 100644--- a/blocksuite/framework/block-std/src/utils/layer.ts+++ b/blocksuite/framework/block-std/src/utils/layer.ts@@ -1,5 +1,5 @@import { nToLast } from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import type { GfxLocalElementModel } from '../gfx/index.js';import type { Layer } from '../gfx/layer.js';@@ -82,7 +82,7 @@ export function isInRange(edges: [GfxModel, GfxModel], target: GfxModel) {}export function renderableInEdgeless(- doc: Blocks,+ doc: Store,surface: SurfaceBlockModel,block: GfxBlockElementModel) {diff --git a/blocksuite/framework/block-std/src/utils/tree.ts b/blocksuite/framework/block-std/src/utils/tree.tsindex 5ea0279f0a..7fbffa0b8f 100644--- a/blocksuite/framework/block-std/src/utils/tree.ts+++ b/blocksuite/framework/block-std/src/utils/tree.ts@@ -1,4 +1,4 @@-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import {type GfxCompatibleInterface,@@ -124,16 +124,13 @@ export function isLockedImpl(element: GfxCompatibleInterface): boolean {return isLockedBySelfImpl(element) || isLockedByAncestorImpl(element);}-export function lockElementImpl(doc: Blocks, element: GfxCompatibleInterface) {+export function lockElementImpl(doc: Store, element: GfxCompatibleInterface) {doc.transact(() => {element.lockedBySelf = true;});}-export function unlockElementImpl(- doc: Blocks,- element: GfxCompatibleInterface-) {+export function unlockElementImpl(doc: Store, element: GfxCompatibleInterface) {doc.transact(() => {element.lockedBySelf = false;});diff --git a/blocksuite/framework/block-std/src/view/element/block-component.ts b/blocksuite/framework/block-std/src/view/element/block-component.tsindex 947571862e..81b09387e0 100644--- a/blocksuite/framework/block-std/src/view/element/block-component.ts+++ b/blocksuite/framework/block-std/src/view/element/block-component.ts@@ -1,6 +1,6 @@import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';-import { type BlockModel, Blocks, type BlockViewType } from '@blocksuite/store';+import { type BlockModel, type BlockViewType, Store } from '@blocksuite/store';import { consume, provide } from '@lit/context';import { computed } from '@preact/signals-core';import { nothing, type TemplateResult } from 'lit';@@ -23,7 +23,7 @@ import { ShadowlessElement } from './shadowless-element.js';import type { WidgetComponent } from './widget-component.js';@requiredProperties({- doc: PropTypes.instanceOf(Blocks),+ doc: PropTypes.instanceOf(Store),std: PropTypes.object,widgets: PropTypes.recordOf(PropTypes.object),})@@ -307,7 +307,7 @@ export class BlockComponent<private accessor _service: Service | null = null;@consume({ context: docContext })- accessor doc!: Blocks;+ accessor doc!: Store;@property({ attribute: false })accessor viewType: BlockViewType = 'display';diff --git a/blocksuite/framework/block-std/src/view/element/lit-host.ts b/blocksuite/framework/block-std/src/view/element/lit-host.tsindex 3967026119..fbe660e006 100644--- a/blocksuite/framework/block-std/src/view/element/lit-host.ts+++ b/blocksuite/framework/block-std/src/view/element/lit-host.ts@@ -4,7 +4,7 @@ import {handleError,} from '@blocksuite/global/exceptions';import { SignalWatcher, Slot, WithDisposable } from '@blocksuite/global/utils';-import { type BlockModel, Blocks } from '@blocksuite/store';+import { type BlockModel, Store } from '@blocksuite/store';import { createContext, provide } from '@lit/context';import { css, LitElement, nothing, type TemplateResult } from 'lit';import { property } from 'lit/decorators.js';@@ -22,11 +22,11 @@ import type { ViewStore } from '../view-store.js';import { BLOCK_ID_ATTR, WIDGET_ID_ATTR } from './consts.js';import { ShadowlessElement } from './shadowless-element.js';-export const docContext = createContext<Blocks>('doc');+export const docContext = createContext<Store>('doc');export const stdContext = createContext<BlockStdScope>('std');@requiredProperties({- doc: PropTypes.instanceOf(Blocks),+ doc: PropTypes.instanceOf(Store),std: PropTypes.object,})export class EditorHost extends SignalWatcher(@@ -189,7 +189,7 @@ export class EditorHost extends SignalWatcher(@provide({ context: docContext })@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;@provide({ context: stdContext })@property({ attribute: false })diff --git a/blocksuite/framework/block-std/src/view/element/widget-component.ts b/blocksuite/framework/block-std/src/view/element/widget-component.tsindex e81e20d1ce..7d5f9cfbcc 100644--- a/blocksuite/framework/block-std/src/view/element/widget-component.ts+++ b/blocksuite/framework/block-std/src/view/element/widget-component.ts@@ -1,5 +1,5 @@import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { consume } from '@lit/context';import { LitElement } from 'lit';@@ -94,7 +94,7 @@ export class WidgetComponent<}@consume({ context: docContext })- private accessor _doc!: Blocks;+ private accessor _doc!: Store;@consume({ context: modelContext })private accessor _model!: Model;diff --git a/blocksuite/framework/store/src/__tests__/collection.unit.spec.ts b/blocksuite/framework/store/src/__tests__/collection.unit.spec.tsindex 76f4003ddc..5a106b56b8 100644--- a/blocksuite/framework/store/src/__tests__/collection.unit.spec.ts+++ b/blocksuite/framework/store/src/__tests__/collection.unit.spec.ts@@ -4,7 +4,7 @@ import type { Slot } from '@blocksuite/global/utils';import { assert, beforeEach, describe, expect, it, vi } from 'vitest';import { applyUpdate, type Doc, encodeStateAsUpdate } from 'yjs';-import type { BlockModel, Blocks, BlockSchemaType, DocMeta } from '../index.js';+import type { BlockModel, BlockSchemaType, DocMeta, Store } from '../index.js';import { Schema } from '../index.js';import { Text } from '../reactive/text.js';import { createAutoIncrementIdGenerator } from '../test/index.js';@@ -52,7 +52,7 @@ function waitOnce<T>(slot: Slot<T>) {return new Promise<T>(resolve => slot.once(val => resolve(val)));}-function createRoot(doc: Blocks) {+function createRoot(doc: Store) {doc.addBlock('affine:page');if (!doc.root) throw new Error('root not found');return doc.root;diff --git a/blocksuite/framework/store/src/adapter/base.ts b/blocksuite/framework/store/src/adapter/base.tsindex adf4ca8652..a208685351 100644--- a/blocksuite/framework/store/src/adapter/base.ts+++ b/blocksuite/framework/store/src/adapter/base.ts@@ -1,6 +1,6 @@import { BlockSuiteError } from '@blocksuite/global/exceptions';-import type { Blocks, DraftModel } from '../model/index.js';+import type { DraftModel, Store } from '../model/index.js';import type { AssetsManager } from '../transformer/assets.js';import type { Job, Slice } from '../transformer/index.js';import type {@@ -93,7 +93,7 @@ export abstract class BaseAdapter<AdapterTarget = unknown> {| Promise<FromBlockSnapshotResult<AdapterTarget>>| FromBlockSnapshotResult<AdapterTarget>;- async fromDoc(doc: Blocks) {+ async fromDoc(doc: Store) {try {const docSnapshot = this.job.docToSnapshot(doc);if (!docSnapshot) return;@@ -138,7 +138,7 @@ export abstract class BaseAdapter<AdapterTarget = unknown> {async toBlock(payload: ToBlockSnapshotPayload<AdapterTarget>,- doc: Blocks,+ doc: Store,parent?: string,index?: number) {@@ -175,7 +175,7 @@ export abstract class BaseAdapter<AdapterTarget = unknown> {async toSlice(payload: ToSliceSnapshotPayload<AdapterTarget>,- doc: Blocks,+ doc: Store,parent?: string,index?: number) {diff --git a/blocksuite/framework/store/src/extension/store-extension.ts b/blocksuite/framework/store/src/extension/store-extension.tsindex d18cc57493..613c1c0340 100644--- a/blocksuite/framework/store/src/extension/store-extension.ts+++ b/blocksuite/framework/store/src/extension/store-extension.ts@@ -1,8 +1,8 @@import { type Container, createIdentifier } from '@blocksuite/global/di';import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';-import { StoreIdentifier } from '../store/identifier';-import type { Store } from '../store/store';+import type { Store } from '../model/store';+import { StoreIdentifier } from '../model/store/identifier';import { Extension } from './extension';export const StoreExtensionIdentifier =diff --git a/blocksuite/framework/store/src/index.ts b/blocksuite/framework/store/src/index.tsindex d5895ea9cd..526a50bbef 100644--- a/blocksuite/framework/store/src/index.ts+++ b/blocksuite/framework/store/src/index.ts@@ -6,7 +6,6 @@ export * from './extension';export * from './model';export * from './reactive';export * from './schema';-export * from './store';export * from './transformer';export { type IdGenerator, nanoid, uuidv4 } from './utils/id-generator';export * from './yjs';diff --git a/blocksuite/framework/store/src/model/block/block-model.ts b/blocksuite/framework/store/src/model/block/block-model.tsindex 0b0c073915..c210cc6ff5 100644--- a/blocksuite/framework/store/src/model/block/block-model.ts+++ b/blocksuite/framework/store/src/model/block/block-model.ts@@ -2,7 +2,7 @@ import { type Disposable, Slot } from '@blocksuite/global/utils';import { computed, type Signal, signal } from '@preact/signals-core';import type { Text } from '../../reactive/index.js';-import type { Blocks } from '../blocks/blocks.js';+import type { Store } from '../store/store.js';import type { YBlock } from './types.js';import type { RoleType } from './zod.js';@@ -38,7 +38,7 @@ export class BlockModel</*** @deprecated use doc instead*/- page!: Blocks;+ page!: Store;private readonly _childModels = computed(() => {const value: BlockModel[] = [];@@ -102,7 +102,7 @@ export class BlockModel<return this.page;}- set doc(doc: Blocks) {+ set doc(doc: Store) {this.page = doc;}diff --git a/blocksuite/framework/store/src/model/block/block.ts b/blocksuite/framework/store/src/model/block/block.tsindex b4b168507c..7f9deed2a6 100644--- a/blocksuite/framework/store/src/model/block/block.ts+++ b/blocksuite/framework/store/src/model/block/block.ts@@ -1,5 +1,5 @@import type { Schema } from '../../schema/index.js';-import type { Blocks } from '../blocks/blocks.js';+import type { Store } from '../store/store.js';import { SyncController } from './sync-controller.js';import type { BlockOptions, YBlock } from './types.js';@@ -37,7 +37,7 @@ export class Block {constructor(readonly schema: Schema,readonly yBlock: YBlock,- readonly doc?: Blocks,+ readonly doc?: Store,readonly options: BlockOptions = {}) {const onChange = !options.onChangediff --git a/blocksuite/framework/store/src/model/block/sync-controller.ts b/blocksuite/framework/store/src/model/block/sync-controller.tsindex 9631658891..ff08517fe1 100644--- a/blocksuite/framework/store/src/model/block/sync-controller.ts+++ b/blocksuite/framework/store/src/model/block/sync-controller.ts@@ -11,7 +11,7 @@ import {y2Native,} from '../../reactive/index.js';import type { Schema } from '../../schema/schema.js';-import type { Blocks } from '../blocks/blocks.js';+import type { Store } from '../store/store.js';import { BlockModel } from './block-model.js';import type { YBlock } from './types.js';import { internalPrimitives } from './zod.js';@@ -104,7 +104,7 @@ export class SyncController {constructor(readonly schema: Schema,readonly yBlock: YBlock,- readonly doc?: Blocks,+ readonly doc?: Store,readonly onChange?: (key: string, value: unknown) => void) {const { id, flavour, version, yChildren, props } = this._parseYBlock();diff --git a/blocksuite/framework/store/src/model/blocks/index.ts b/blocksuite/framework/store/src/model/blocks/index.tsdeleted file mode 100644index c37ae9ebc5..0000000000--- a/blocksuite/framework/store/src/model/blocks/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from './blocks.js';-export * from './query.js';diff --git a/blocksuite/framework/store/src/model/doc.ts b/blocksuite/framework/store/src/model/doc.tsindex 1ee477756f..c40b60af67 100644--- a/blocksuite/framework/store/src/model/doc.ts+++ b/blocksuite/framework/store/src/model/doc.ts@@ -4,15 +4,12 @@ import type * as Y from 'yjs';import type { Schema } from '../schema/schema.js';import type { AwarenessStore } from '../yjs/awareness.js';import type { YBlock } from './block/types.js';-import type { Blocks } from './blocks/blocks.js';-import type { Query } from './blocks/query.js';+import type { Query } from './store/query.js';+import type { Store, StoreOptions } from './store/store.js';import type { Workspace } from './workspace.js';import type { DocMeta } from './workspace-meta.js';-export type GetBlocksOptions = {- query?: Query;- readonly?: boolean;-};+export type GetBlocksOptions = Omit<StoreOptions, 'schema' | 'doc'>;export type CreateBlocksOptions = GetBlocksOptions & {id?: string;};@@ -53,7 +50,7 @@ export interface Doc {captureSync(): void;clear(): void;- getBlocks(options?: GetBlocksOptions): Blocks;+ getStore(options?: GetBlocksOptions): Store;clearQuery(query: Query, readonly?: boolean): void;get loaded(): boolean;diff --git a/blocksuite/framework/store/src/model/index.ts b/blocksuite/framework/store/src/model/index.tsindex 3cd9fba3da..ee38592c99 100644--- a/blocksuite/framework/store/src/model/index.ts+++ b/blocksuite/framework/store/src/model/index.ts@@ -1,8 +1,8 @@import type { BlockModel } from './block/block-model.js';export * from './block/index.js';-export * from './blocks/index.js';export * from './doc.js';+export * from './store/index.js';export * from './workspace.js';export * from './workspace-meta.js';diff --git a/blocksuite/framework/store/src/model/blocks/crud.ts b/blocksuite/framework/store/src/model/store/crud.tssimilarity index 100%rename from blocksuite/framework/store/src/model/blocks/crud.tsrename to blocksuite/framework/store/src/model/store/crud.tsdiff --git a/blocksuite/framework/store/src/store/identifier.ts b/blocksuite/framework/store/src/model/store/identifier.tssimilarity index 100%rename from blocksuite/framework/store/src/store/identifier.tsrename to blocksuite/framework/store/src/model/store/identifier.tsdiff --git a/blocksuite/framework/store/src/model/store/index.ts b/blocksuite/framework/store/src/model/store/index.tsnew file mode 100644index 0000000000..58fdcc8137--- /dev/null+++ b/blocksuite/framework/store/src/model/store/index.ts@@ -0,0 +1,3 @@+export * from './identifier.js';+export * from './query.js';+export * from './store.js';diff --git a/blocksuite/framework/store/src/model/blocks/query.ts b/blocksuite/framework/store/src/model/store/query.tssimilarity index 100%rename from blocksuite/framework/store/src/model/blocks/query.tsrename to blocksuite/framework/store/src/model/store/query.tsdiff --git a/blocksuite/framework/store/src/model/blocks/blocks.ts b/blocksuite/framework/store/src/model/store/store.tssimilarity index 94%rename from blocksuite/framework/store/src/model/blocks/blocks.tsrename to blocksuite/framework/store/src/model/store/store.tsindex 55d2f77e5a..2036842e5e 100644--- a/blocksuite/framework/store/src/model/blocks/blocks.ts+++ b/blocksuite/framework/store/src/model/store/store.ts@@ -1,7 +1,9 @@+import { Container, type ServiceProvider } from '@blocksuite/global/di';import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';import { type Disposable, Slot } from '@blocksuite/global/utils';import { signal } from '@preact/signals-core';+import type { ExtensionType } from '../../extension/extension.js';import type { Schema } from '../../schema/index.js';import {Block,@@ -12,17 +14,22 @@ import {} from '../block/index.js';import type { Doc } from '../doc.js';import { DocCRUD } from './crud.js';+import { StoreIdentifier } from './identifier.js';import { type Query, runQuery } from './query.js';import { syncBlockProps } from './utils.js';-type DocOptions = {+export type StoreOptions = {schema: Schema;- blockCollection: Doc;+ doc: Doc;readonly?: boolean;query?: Query;+ provider?: ServiceProvider;+ extensions?: ExtensionType[];};-export class Blocks {+export class Store {+ private readonly _provider: ServiceProvider;+private readonly _runQuery = (block: Block) => {runQuery(this._query, block);};@@ -147,6 +154,10 @@ export class Blocks {return this._doc.awarenessStore;}+ get provider() {+ return this._provider;+ }+get blobSync() {return this.workspace.blobSync;}@@ -259,8 +270,24 @@ export class Blocks {return this._doc.withoutTransact.bind(this._doc);}- constructor({ schema, blockCollection, readonly, query }: DocOptions) {- this._doc = blockCollection;+ constructor({+ schema,+ doc,+ readonly,+ query,+ provider,+ extensions,+ }: StoreOptions) {+ const container = new Container();+ container.addImpl(StoreIdentifier, () => this);++ const userExtensions = extensions ?? [];+ userExtensions.forEach(extension => {+ extension.setup(container);+ });++ this._provider = container.provider(undefined, provider);+ this._doc = doc;this.slots = {ready: new Slot(),@@ -271,7 +298,7 @@ export class Blocks {yBlockUpdated: this._doc.slots.yBlockUpdated,};- this._crud = new DocCRUD(this._yBlocks, blockCollection.schema);+ this._crud = new DocCRUD(this._yBlocks, doc.schema);this._schema = schema;this._readonly = readonly;if (query) {@@ -565,7 +592,7 @@ export class Blocks {return (this.getBlock(id)?.model ?? null) as Model | null;}- getBlocks() {+ getStore() {return Object.values(this._blocks.peek()).map(block => block.model);}diff --git a/blocksuite/framework/store/src/model/blocks/utils.ts b/blocksuite/framework/store/src/model/store/utils.tssimilarity index 100%rename from blocksuite/framework/store/src/model/blocks/utils.tsrename to blocksuite/framework/store/src/model/store/utils.tsdiff --git a/blocksuite/framework/store/src/model/workspace.ts b/blocksuite/framework/store/src/model/workspace.tsindex cd33b5ec0b..66c171c890 100644--- a/blocksuite/framework/store/src/model/workspace.ts+++ b/blocksuite/framework/store/src/model/workspace.ts@@ -5,8 +5,8 @@ import type * as Y from 'yjs';import type { Schema } from '../schema/schema.js';import type { IdGenerator } from '../utils/id-generator.js';import type { AwarenessStore } from '../yjs/awareness.js';-import type { Blocks } from './blocks/blocks.js';import type { CreateBlocksOptions, Doc, GetBlocksOptions } from './doc.js';+import type { Store } from './store/store.js';import type { WorkspaceMeta } from './workspace-meta.js';export interface Workspace {@@ -26,8 +26,8 @@ export interface Workspace {docRemoved: Slot<string>;};- createDoc(options?: CreateBlocksOptions): Blocks;- getDoc(docId: string, options?: GetBlocksOptions): Blocks | null;+ createDoc(options?: CreateBlocksOptions): Store;+ getDoc(docId: string, options?: GetBlocksOptions): Store | null;removeDoc(docId: string): void;dispose(): void;diff --git a/blocksuite/framework/store/src/store/index.ts b/blocksuite/framework/store/src/store/index.tsdeleted file mode 100644index 63c6027f1e..0000000000--- a/blocksuite/framework/store/src/store/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from './identifier';-export * from './store';diff --git a/blocksuite/framework/store/src/store/store.ts b/blocksuite/framework/store/src/store/store.tsdeleted file mode 100644index 2fa4f455e4..0000000000--- a/blocksuite/framework/store/src/store/store.ts+++ /dev/null@@ -1,41 +0,0 @@-import { Container, type ServiceProvider } from '@blocksuite/global/di';--import type { Extension, StoreExtension } from '../extension';-import type { Blocks } from '../model';-import { StoreIdentifier } from './identifier';--export interface StoreOptions {- blocks: Blocks;- provider?: ServiceProvider;- extensions?: (typeof Extension | typeof StoreExtension)[];-}--export class Store {- private readonly _blocks: Blocks;- private readonly _provider: ServiceProvider;-- get blocks() {- return this._blocks;- }-- get provider() {- return this._provider;- }-- get awareness() {- return this._blocks.awarenessStore;- }-- constructor(options: StoreOptions) {- this._blocks = options.blocks;- const container = new Container();- container.addImpl(StoreIdentifier, () => this);-- const userExtensions = options.extensions ?? [];- userExtensions.forEach(extension => {- extension.setup(container);- });-- this._provider = container.provider(undefined, options.provider);- }-}diff --git a/blocksuite/framework/store/src/test/test-doc.ts b/blocksuite/framework/store/src/test/test-doc.tsindex 818e027ffa..b9042583df 100644--- a/blocksuite/framework/store/src/test/test-doc.ts+++ b/blocksuite/framework/store/src/test/test-doc.ts@@ -3,9 +3,9 @@ import { signal } from '@preact/signals-core';import * as Y from 'yjs';import type { YBlock } from '../model/block/types.js';-import { Blocks } from '../model/blocks/blocks.js';-import type { Query } from '../model/blocks/query.js';import type { Doc, GetBlocksOptions, Workspace } from '../model/index.js';+import type { Query } from '../model/store/query.js';+import { Store } from '../model/store/store.js';import type { AwarenessStore } from '../yjs/index.js';type DocOptions = {@@ -25,9 +25,9 @@ export class TestDoc implements Doc {private readonly _collection: Workspace;private readonly _docMap = {- undefined: new Map<string, Blocks>(),- true: new Map<string, Blocks>(),- false: new Map<string, Blocks>(),+ undefined: new Map<string, Store>(),+ true: new Map<string, Store>(),+ false: new Map<string, Store>(),};// doc/space container.@@ -279,7 +279,7 @@ export class TestDoc implements Doc {}}- getBlocks({ readonly, query }: GetBlocksOptions = {}) {+ getStore({ readonly, query, provider, extensions }: GetBlocksOptions = {}) {const readonlyKey = this._getReadonlyKey(readonly);const key = JSON.stringify(query);@@ -288,11 +288,13 @@ export class TestDoc implements Doc {return this._docMap[readonlyKey].get(key)!;}- const doc = new Blocks({- blockCollection: this,+ const doc = new Store({+ doc: this,schema: this.workspace.schema,readonly,query,+ provider,+ extensions,});this._docMap[readonlyKey].set(key, doc);diff --git a/blocksuite/framework/store/src/test/test-workspace.ts b/blocksuite/framework/store/src/test/test-workspace.tsindex 9334e186d1..aadd5b39ac 100644--- a/blocksuite/framework/store/src/test/test-workspace.ts+++ b/blocksuite/framework/store/src/test/test-workspace.ts@@ -17,9 +17,9 @@ import { Awareness } from 'y-protocols/awareness.js';import * as Y from 'yjs';import type {- Blocks,CreateBlocksOptions,GetBlocksOptions,+ Store,Workspace,WorkspaceMeta,} from '../model/index.js';@@ -205,7 +205,7 @@ export class TestWorkspace implements Workspace {tags: [],});this.slots.docCreated.emit(docId);- return this.getDoc(docId, { query, readonly }) as Blocks;+ return this.getDoc(docId, { query, readonly }) as Store;}dispose() {@@ -227,9 +227,9 @@ export class TestWorkspace implements Workspace {return space ?? null;}- getDoc(docId: string, options?: GetBlocksOptions): Blocks | null {+ getDoc(docId: string, options?: GetBlocksOptions): Store | null {const collection = this.getBlockCollection(docId);- return collection?.getBlocks(options) ?? null;+ return collection?.getStore(options) ?? null;}removeDoc(docId: string) {diff --git a/blocksuite/framework/store/src/transformer/job.ts b/blocksuite/framework/store/src/transformer/job.tsindex f846255025..1a9d497a20 100644--- a/blocksuite/framework/store/src/transformer/job.ts+++ b/blocksuite/framework/store/src/transformer/job.ts@@ -3,9 +3,9 @@ import { nextTick, Slot } from '@blocksuite/global/utils';import type {BlockModel,- Blocks,BlockSchemaType,DraftModel,+ Store,} from '../model/index.js';import type { Schema } from '../schema/index.js';import { AssetsManager } from './assets.js';@@ -82,7 +82,7 @@ export class Job {}};- docToSnapshot = (doc: Blocks): DocSnapshot | undefined => {+ docToSnapshot = (doc: Store): DocSnapshot | undefined => {try {this._slots.beforeExport.emit({type: 'page',@@ -158,7 +158,7 @@ export class Job {snapshotToBlock = async (snapshot: BlockSnapshot,- doc: Blocks,+ doc: Store,parent?: string,index?: number): Promise<BlockModel | undefined> => {@@ -174,9 +174,7 @@ export class Job {}};- snapshotToDoc = async (- snapshot: DocSnapshot- ): Promise<Blocks | undefined> => {+ snapshotToDoc = async (snapshot: DocSnapshot): Promise<Store | undefined> => {try {this._slots.beforeImport.emit({type: 'page',@@ -228,7 +226,7 @@ export class Job {snapshotToSlice = async (snapshot: SliceSnapshot,- doc: Blocks,+ doc: Store,parent?: string,index?: number): Promise<Slice | undefined> => {@@ -424,7 +422,7 @@ export class Job {}}- private _exportDocMeta(doc: Blocks): DocSnapshot['meta'] {+ private _exportDocMeta(doc: Store): DocSnapshot['meta'] {const docMeta = doc.meta;if (!docMeta) {@@ -472,7 +470,7 @@ export class Job {private async _insertBlockTree(nodes: DraftBlockTreeNode[],- doc: Blocks,+ doc: Store,parentId?: string,startIndex?: number,counter: number = 0@@ -561,7 +559,7 @@ export class Job {private async _snapshotToBlock(snapshot: BlockSnapshot,- doc: Blocks,+ doc: Store,parent?: string,index?: number): Promise<BlockModel | null> {diff --git a/blocksuite/framework/store/src/transformer/middleware.ts b/blocksuite/framework/store/src/transformer/middleware.tsindex 58c69ccf23..ad0d84cbc3 100644--- a/blocksuite/framework/store/src/transformer/middleware.ts+++ b/blocksuite/framework/store/src/transformer/middleware.ts@@ -1,6 +1,6 @@import type { Slot } from '@blocksuite/global/utils';-import type { Blocks, DraftModel } from '../model/index.js';+import type { DraftModel, Store } from '../model/index.js';import type { AssetsManager } from './assets.js';import type { Slice } from './slice.js';import type {@@ -37,7 +37,7 @@ export type BeforeExportPayload =type: 'block';}| {- page: Blocks;+ page: Store;type: 'page';}| {@@ -59,7 +59,7 @@ export type FinalPayload =| {snapshot: DocSnapshot;type: 'page';- page: Blocks;+ page: Store;}| {snapshot: SliceSnapshot;diff --git a/blocksuite/framework/store/src/transformer/slice.ts b/blocksuite/framework/store/src/transformer/slice.tsindex c0fc44865b..2b2801b774 100644--- a/blocksuite/framework/store/src/transformer/slice.ts+++ b/blocksuite/framework/store/src/transformer/slice.ts@@ -1,4 +1,4 @@-import type { Blocks, DraftModel } from '../model/index.js';+import type { DraftModel, Store } from '../model/index.js';type SliceData = {content: DraftModel[];@@ -21,7 +21,7 @@ export class Slice {constructor(readonly data: SliceData) {}- static fromModels(doc: Blocks, models: DraftModel[]) {+ static fromModels(doc: Store, models: DraftModel[]) {return new Slice({content: models,workspaceId: doc.workspace.id,diff --git a/blocksuite/framework/store/src/transformer/type.ts b/blocksuite/framework/store/src/transformer/type.tsindex ecf1c3fc08..d22e18009c 100644--- a/blocksuite/framework/store/src/transformer/type.ts+++ b/blocksuite/framework/store/src/transformer/type.ts@@ -1,6 +1,6 @@import { z } from 'zod';-import type { Blocks } from '../model/blocks/blocks.js';+import type { Store } from '../model/store/store.js';import type { DocMeta, DocsPropertiesMeta } from '../model/workspace-meta.js';export type BlockSnapshot = {@@ -75,7 +75,7 @@ export interface BlobCRUD {}export interface DocCRUD {- create: (id: string) => Blocks;- get: (id: string) => Blocks | null;+ create: (id: string) => Store;+ get: (id: string) => Store | null;delete: (id: string) => void;}diff --git a/blocksuite/playground/apps/_common/components/docs-panel.ts b/blocksuite/playground/apps/_common/components/docs-panel.tsindex 531ccc48cb..53414ed893 100644--- a/blocksuite/playground/apps/_common/components/docs-panel.ts+++ b/blocksuite/playground/apps/_common/components/docs-panel.ts@@ -73,7 +73,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {?.generateDocUrl(doc.id);if (url) history.pushState({}, '', url);- this.editor.doc = doc.getBlocks();+ this.editor.doc = doc.getStore();this.editor.doc.load();this.editor.doc.resetHistory();this.requestUpdate();@@ -146,7 +146,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {removeModeFromStorage(doc.id);// When delete the current doc, we need to set the editor doc to the first remaining docif (isDeleteCurrent) {- this.editor.doc = this.docs[0].getBlocks();+ this.editor.doc = this.docs[0].getStore();}};return html`<div class="doc-item" @click="${click}" style="${style}">diff --git a/blocksuite/playground/apps/_common/history.ts b/blocksuite/playground/apps/_common/history.tsindex 83947fe826..a8ee6741a3 100644--- a/blocksuite/playground/apps/_common/history.ts+++ b/blocksuite/playground/apps/_common/history.ts@@ -15,7 +15,7 @@ export function getDocFromUrlParams(collection: Workspace, url: URL) {if (!doc) {const blockCollection = collection.docs.values().next().value as Doc;assertExists(blockCollection, 'Need to create a doc first');- doc = blockCollection.getBlocks();+ doc = blockCollection.getStore();}doc.load();diff --git a/blocksuite/presets/src/__tests__/edgeless/layer.spec.ts b/blocksuite/presets/src/__tests__/edgeless/layer.spec.tsindex 15c61178c3..efd0020008 100644--- a/blocksuite/presets/src/__tests__/edgeless/layer.spec.ts+++ b/blocksuite/presets/src/__tests__/edgeless/layer.spec.ts@@ -5,7 +5,7 @@ import type {GroupElementModel,NoteBlockModel,} from '@blocksuite/blocks';-import { type BlockModel, type Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { beforeEach, describe, expect, test } from 'vitest';import * as Y from 'yjs';@@ -19,7 +19,7 @@ import { setupEditor } from '../utils/setup.js';let service!: EdgelessRootBlockComponent['service'];-const addNote = (doc: Blocks, props: Record<string, unknown> = {}) => {+const addNote = (doc: Store, props: Record<string, unknown> = {}) => {return _addNote(doc, {index: service.layer.generateIndex(),...props,diff --git a/blocksuite/presets/src/__tests__/utils/edgeless.ts b/blocksuite/presets/src/__tests__/utils/edgeless.tsindex 94e6158b45..27325e6acf 100644--- a/blocksuite/presets/src/__tests__/utils/edgeless.ts+++ b/blocksuite/presets/src/__tests__/utils/edgeless.ts@@ -3,11 +3,11 @@ import type {PageRootBlockComponent,SurfaceBlockComponent,} from '@blocksuite/blocks';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import type { AffineEditorContainer } from '../../index.js';-export function getSurface(doc: Blocks, editor: AffineEditorContainer) {+export function getSurface(doc: Store, editor: AffineEditorContainer) {const surfaceModel = doc.getBlockByFlavour('affine:surface');return editor.host!.view.getBlock(@@ -16,17 +16,17 @@ export function getSurface(doc: Blocks, editor: AffineEditorContainer) {}export function getDocRootBlock(- doc: Blocks,+ doc: Store,editor: AffineEditorContainer,mode: 'page'): PageRootBlockComponent;export function getDocRootBlock(- doc: Blocks,+ doc: Store,editor: AffineEditorContainer,mode: 'edgeless'): EdgelessRootBlockComponent;export function getDocRootBlock(- doc: Blocks,+ doc: Store,editor: AffineEditorContainer,_?: 'edgeless' | 'page') {@@ -35,7 +35,7 @@ export function getDocRootBlock(| PageRootBlockComponent;}-export function addNote(doc: Blocks, props: Record<string, any> = {}) {+export function addNote(doc: Store, props: Record<string, any> = {}) {const noteId = doc.addBlock('affine:note',{diff --git a/blocksuite/presets/src/__tests__/utils/setup.ts b/blocksuite/presets/src/__tests__/utils/setup.tsindex 81add31fc4..e184d91587 100644--- a/blocksuite/presets/src/__tests__/utils/setup.ts+++ b/blocksuite/presets/src/__tests__/utils/setup.ts@@ -1,5 +1,5 @@import { effects as blocksEffects } from '@blocksuite/blocks/effects';-import type { Blocks, Job } from '@blocksuite/store';+import type { Job, Store } from '@blocksuite/store';import { effects } from '../../effects.js';@@ -59,7 +59,7 @@ async function createEditor(collection: TestWorkspace, mode: DocMode = 'page') {const app = document.createElement('div');const blockCollection = collection.docs.values().next().value;assertExists(blockCollection, 'Need to create a doc first');- const doc = blockCollection.getBlocks();+ const doc = blockCollection.getStore();const editor = new AffineEditorContainer();editor.doc = doc;editor.mode = mode;@@ -109,12 +109,12 @@ export function cleanup() {declare global {const editor: AffineEditorContainer;- const doc: Blocks;+ const doc: Store;const collection: TestWorkspace;const job: Job;interface Window {editor: AffineEditorContainer;- doc: Blocks;+ doc: Store;job: Job;collection: TestWorkspace;}diff --git a/blocksuite/presets/src/editors/edgeless-editor.ts b/blocksuite/presets/src/editors/edgeless-editor.tsindex 73f6becfdb..4b91dbda9d 100644--- a/blocksuite/presets/src/editors/edgeless-editor.ts+++ b/blocksuite/presets/src/editors/edgeless-editor.ts@@ -1,7 +1,7 @@import { BlockStdScope, ShadowlessElement } from '@blocksuite/block-std';import { EdgelessEditorBlockSpecs, ThemeProvider } from '@blocksuite/blocks';import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';-import { type Blocks, Store } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { css, html, nothing, type TemplateResult } from 'lit';import { property, state } from 'lit/decorators.js';import { guard } from 'lit/directives/guard.js';@@ -48,9 +48,8 @@ export class EdgelessEditor extends SignalWatcher(this._disposables.add(this.doc.slots.rootAdded.on(() => this.requestUpdate()));- const store = new Store({ blocks: this.doc });this.std = new BlockStdScope({- store,+ store: this.doc,extensions: this.specs,});}@@ -78,16 +77,15 @@ export class EdgelessEditor extends SignalWatcher() {super.willUpdate(changedProperties);if (changedProperties.has('doc')) {- const store = new Store({ blocks: this.doc });this.std = new BlockStdScope({- store,+ store: this.doc,extensions: this.specs,});}}@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;@property({ attribute: false })accessor editor!: TemplateResult;diff --git a/blocksuite/presets/src/editors/editor-container.ts b/blocksuite/presets/src/editors/editor-container.tsindex fa276d7772..c71da6ec12 100644--- a/blocksuite/presets/src/editors/editor-container.ts+++ b/blocksuite/presets/src/editors/editor-container.ts@@ -9,9 +9,8 @@ import {import { SignalWatcher, Slot, WithDisposable } from '@blocksuite/global/utils';import {type BlockModel,- type Blocks,type ExtensionType,- Store,+ type Store,} from '@blocksuite/store';import { computed, signal } from '@preact/signals-core';import { css, html } from 'lit';@@ -89,7 +88,7 @@ export class AffineEditorContainer}`;- private readonly _doc = signal<Blocks>();+ private readonly _doc = signal<Store>();private readonly _edgelessSpecs = signal<ExtensionType[]>(EdgelessEditorBlockSpecs@@ -105,13 +104,9 @@ export class AffineEditorContainer: this._edgelessSpecs.value);- private readonly _store = computed(() => {- return new Store({ blocks: this.doc });- });-private readonly _std = computed(() => {return new BlockStdScope({- store: this._store.value,+ store: this.doc,extensions: this._specs.value,});});@@ -128,10 +123,10 @@ export class AffineEditorContainer};get doc() {- return this._doc.value as Blocks;+ return this._doc.value as Store;}- set doc(doc: Blocks) {+ set doc(doc: Store) {this._doc.value = doc;}diff --git a/blocksuite/presets/src/editors/page-editor.ts b/blocksuite/presets/src/editors/page-editor.tsindex 8865b3b0a2..2b5c472383 100644--- a/blocksuite/presets/src/editors/page-editor.ts+++ b/blocksuite/presets/src/editors/page-editor.ts@@ -5,7 +5,7 @@ import {} from '@blocksuite/block-std';import { PageEditorBlockSpecs, ThemeProvider } from '@blocksuite/blocks';import { noop, SignalWatcher, WithDisposable } from '@blocksuite/global/utils';-import { type Blocks, Store } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { css, html, nothing } from 'lit';import { property, state } from 'lit/decorators.js';import { guard } from 'lit/directives/guard.js';@@ -59,9 +59,8 @@ export class PageEditor extends SignalWatcher(this._disposables.add(this.doc.slots.rootAdded.on(() => this.requestUpdate()));- const store = new Store({ blocks: this.doc });this.std = new BlockStdScope({- store,+ store: this.doc,extensions: this.specs,});}@@ -94,16 +93,15 @@ export class PageEditor extends SignalWatcher() {super.willUpdate(changedProperties);if (changedProperties.has('doc')) {- const store = new Store({ blocks: this.doc });this.std = new BlockStdScope({- store,+ store: this.doc,extensions: this.specs,});}}@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;@property({ type: Boolean })accessor hasViewport = true;diff --git a/blocksuite/presets/src/fragments/doc-title/doc-title.ts b/blocksuite/presets/src/fragments/doc-title/doc-title.tsindex aa3c5fe620..68d0f85905 100644--- a/blocksuite/presets/src/fragments/doc-title/doc-title.ts+++ b/blocksuite/presets/src/fragments/doc-title/doc-title.ts@@ -2,7 +2,7 @@ import type { EditorHost } from '@blocksuite/block-std';import { ShadowlessElement } from '@blocksuite/block-std';import type { RichText, RootBlockModel } from '@blocksuite/blocks';import { assertExists, WithDisposable } from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { css, html } from 'lit';import { property, query, state } from 'lit/decorators.js';@@ -175,7 +175,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {private accessor _richTextElement!: RichText;@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;}export function getDocTitleByEditorHost(diff --git a/blocksuite/presets/src/fragments/frame-panel/body/frame-panel-body.ts b/blocksuite/presets/src/fragments/frame-panel/body/frame-panel-body.tsindex 4b132f1943..7597d09e5f 100644--- a/blocksuite/presets/src/fragments/frame-panel/body/frame-panel-body.ts+++ b/blocksuite/presets/src/fragments/frame-panel/body/frame-panel-body.ts@@ -13,7 +13,7 @@ import {SignalWatcher,WithDisposable,} from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { css, html, nothing, type PropertyValues } from 'lit';import { property, query, state } from 'lit/decorators.js';import { keyed } from 'lit/directives/keyed.js';@@ -326,7 +326,7 @@ export class FramePanelBody extends SignalWatcher(}}- private _setDocDisposables(doc: Blocks) {+ private _setDocDisposables(doc: Store) {this._clearDocDisposables();this._docDisposables = new DisposableGroup();this._docDisposables.add(diff --git a/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts b/blocksuite/presets/src/fragments/outline/body/outline-panel-body.tsindex 2662f1bb55..657a535747 100644--- a/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts+++ b/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts@@ -13,7 +13,7 @@ import {SignalWatcher,WithDisposable,} from '@blocksuite/global/utils';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import { effect, signal } from '@preact/signals-core';import { css, html, LitElement, nothing, type PropertyValues } from 'lit';import { property, query, state } from 'lit/decorators.js';@@ -698,7 +698,7 @@ export class OutlinePanelBody extends SignalWatcher(private accessor _selected: string[] = [];@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;@property({ attribute: false })accessor domHost!: Document | HTMLElement;diff --git a/blocksuite/presets/src/fragments/outline/card/outline-card.ts b/blocksuite/presets/src/fragments/outline/card/outline-card.tsindex 0510ccd90c..f0b43d6245 100644--- a/blocksuite/presets/src/fragments/outline/card/outline-card.ts+++ b/blocksuite/presets/src/fragments/outline/card/outline-card.ts@@ -7,7 +7,7 @@ import {once,} from '@blocksuite/blocks';import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { baseTheme } from '@toeverything/theme';import { css, html, LitElement, unsafeCSS } from 'lit';import { property, query, state } from 'lit/decorators.js';@@ -393,7 +393,7 @@ export class OutlineNoteCard extends SignalWatcher(WithDisposable(LitElement)) {accessor activeHeadingId: string | null = null;@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;@property({ attribute: false })accessor editorMode: 'page' | 'edgeless' = 'page';diff --git a/blocksuite/presets/src/fragments/outline/utils/drag.ts b/blocksuite/presets/src/fragments/outline/utils/drag.tsindex f442e75fb9..3ecbee0760 100644--- a/blocksuite/presets/src/fragments/outline/utils/drag.ts+++ b/blocksuite/presets/src/fragments/outline/utils/drag.ts@@ -1,5 +1,5 @@import { on, once } from '@blocksuite/blocks';-import type { Blocks } from '@blocksuite/store';+import type { Store } from '@blocksuite/store';import type { OutlinePanelBody } from '../body/outline-panel-body.js';import type { OutlineNoteCard } from '../card/outline-card.js';@@ -15,7 +15,7 @@ export function startDragging(options: {document: Document;host: Document | HTMLElement;container: OutlinePanelBody;- doc: Blocks;+ doc: Store;}) {const {document,diff --git a/blocksuite/presets/src/fragments/outline/utils/query.ts b/blocksuite/presets/src/fragments/outline/utils/query.tsindex aa9289ac78..6c3fcbb1f0 100644--- a/blocksuite/presets/src/fragments/outline/utils/query.ts+++ b/blocksuite/presets/src/fragments/outline/utils/query.ts@@ -5,7 +5,7 @@ import {type ParagraphBlockModel,type RootBlockModel,} from '@blocksuite/blocks';-import type { BlockModel, Blocks } from '@blocksuite/store';+import type { BlockModel, Store } from '@blocksuite/store';import { headingKeys } from '../config.js';@@ -22,7 +22,7 @@ type OutlineNoteItem = {};export function getNotesFromDoc(- doc: Blocks,+ doc: Store,modes: NoteDisplayMode[]): OutlineNoteItem[] {const rootModel = doc.root;@@ -74,7 +74,7 @@ export function getHeadingBlocksFromNote(}export function getHeadingBlocksFromDoc(- doc: Blocks,+ doc: Store,modes: NoteDisplayMode[],ignoreEmpty = false) {diff --git a/blocksuite/tests-legacy/embed-synced-doc.spec.ts b/blocksuite/tests-legacy/embed-synced-doc.spec.tsindex f615117b09..bf1fc2c738 100644--- a/blocksuite/tests-legacy/embed-synced-doc.spec.ts+++ b/blocksuite/tests-legacy/embed-synced-doc.spec.ts@@ -225,7 +225,7 @@ test.describe('Embed synced doc', () => {};const doc2Collection = getDocCollection();- const doc2 = doc2Collection!.getBlocks();+ const doc2 = doc2Collection!.getStore();const [noteBlock] = doc2!.getBlocksByFlavour('affine:note');const noteId = noteBlock.id;diff --git a/blocksuite/tests-legacy/utils/actions/misc.ts b/blocksuite/tests-legacy/utils/actions/misc.tsindex a268033cd8..7597a56a94 100644--- a/blocksuite/tests-legacy/utils/actions/misc.ts+++ b/blocksuite/tests-legacy/utils/actions/misc.ts@@ -194,7 +194,7 @@ async function initEmptyEditor({}if (noInit) {- const firstDoc = collection.docs.values().next().value?.getBlocks() as+ const firstDoc = collection.docs.values().next().value?.getStore() as| ReturnType<typeof collection.createDoc>| undefined;if (firstDoc) {diff --git a/packages/frontend/core/src/blocksuite/initialization/index.ts b/packages/frontend/core/src/blocksuite/initialization/index.tsindex f04549d2ff..332b7bc539 100644--- a/packages/frontend/core/src/blocksuite/initialization/index.ts+++ b/packages/frontend/core/src/blocksuite/initialization/index.ts@@ -5,7 +5,7 @@ import {type ParagraphProps,type RootBlockProps,} from '@blocksuite/affine/blocks';-import { type Blocks, Text } from '@blocksuite/affine/store';+import { type Store, Text } from '@blocksuite/affine/store';export interface DocProps {page?: Partial<RootBlockProps>;@@ -14,7 +14,7 @@ export interface DocProps {paragraph?: Partial<ParagraphProps>;}-export function initEmptyDoc(doc: Blocks, title?: string) {+export function initEmptyDoc(doc: Store, title?: string) {doc.load(() => {initDocFromProps(doc, {page: {@@ -24,7 +24,7 @@ export function initEmptyDoc(doc: Blocks, title?: string) {});}-export function initDocFromProps(doc: Blocks, props?: DocProps) {+export function initDocFromProps(doc: Store, props?: DocProps) {doc.load(() => {const pageBlockId = doc.addBlock('affine:page',diff --git a/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts b/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.tsindex 490adeaeb6..6e52ad5005 100644--- a/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts+++ b/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts@@ -18,12 +18,11 @@ import {} from '@blocksuite/affine/blocks';import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';import { WithDisposable } from '@blocksuite/affine/global/utils';-import {- type Blocks,- type ExtensionType,- type JobMiddleware,- type Query,- type Schema,+import type {+ ExtensionType,+ JobMiddleware,+ Query,+ Schema,Store,} from '@blocksuite/affine/store';import { css, html, nothing, type PropertyValues } from 'lit';@@ -174,7 +173,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {}};- private _doc: Blocks | null = null;+ private _doc: Store | null = null;private readonly _query: Query = {mode: 'strict',@@ -220,7 +219,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {).then(doc => {this.disposeDoc();- this._doc = doc.doc.getBlocks({+ this._doc = doc.doc.getStore({query: this._query,});this.disposables.add(() => {@@ -287,7 +286,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {this._doc,html`<div class="ai-answer-text-editor affine-page-viewport">${new BlockStdScope({- store: new Store({ blocks: this._doc }),+ store: this._doc,extensions: this.options.extensions ?? CustomPageEditorBlockSpecs,}).render()}</div>`diff --git a/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.ts b/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.tsindex bf6a0a2605..3d9acf178a 100644--- a/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.ts+++ b/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.ts@@ -17,13 +17,13 @@ import type { ServiceProvider } from '@blocksuite/affine/global/di';import { assertExists } from '@blocksuite/affine/global/utils';import type {BlockModel,- Blocks,BlockSnapshot,DraftModel,JobMiddleware,Schema,Slice,SliceSnapshot,+ Store,} from '@blocksuite/affine/store';import { Job } from '@blocksuite/affine/store';@@ -166,7 +166,7 @@ export const markdownToSnapshot = async (export async function insertFromMarkdown(host: EditorHost,markdown: string,- doc: Blocks,+ doc: Store,parent?: string,index?: number) {@@ -235,5 +235,5 @@ export async function markDownToDoc(if (!doc) {console.error('Failed to convert markdown to doc');}- return doc as Blocks;+ return doc as Store;}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.tsindex ec4b30a37e..9f054ab804 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.ts@@ -24,7 +24,7 @@ import {getCommonBoundWithRotation,type SerializedXYWH,} from '@blocksuite/affine/global/utils';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import type { TemplateResult } from 'lit';import type { ChatMessage } from '../../../blocks';@@ -101,7 +101,7 @@ export function constructUserInfoWithMessages(}export async function constructRootChatBlockMessages(- doc: Blocks,+ doc: Store,forkSessionId: string) {// Convert chat messages to AI chat block messages@@ -152,7 +152,7 @@ function addAIChatBlock(const { doc } = host;const surfaceBlock = doc- .getBlocks()+ .getStore().find(block => block.flavour === 'affine:surface');if (!surfaceBlock) {return;@@ -462,7 +462,7 @@ const CREATE_AS_LINKED_DOC = {const { doc } = host;const surfaceBlock = doc- .getBlocks()+ .getStore().find(block => block.flavour === 'affine:surface');if (!surfaceBlock) {return false;diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.tsindex d5c1387a00..5465211bf8 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.ts@@ -236,7 +236,7 @@ function getEdgelessContentBound(host: EditorHost) {const elements = (host.doc- .getBlocks()+ .getStore().filter(model =>model instanceof GfxBlockElementModel &&diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.tsindex d64b752f53..238e7a1e16 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts@@ -5,7 +5,7 @@ import type { EditorHost } from '@blocksuite/affine/block-std';import { ShadowlessElement } from '@blocksuite/affine/block-std';import { NotificationProvider } from '@blocksuite/affine/blocks';import { debounce, WithDisposable } from '@blocksuite/affine/global/utils';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { css, html, type PropertyValues } from 'lit';import { property, state } from 'lit/decorators.js';import { createRef, type Ref, ref } from 'lit/directives/ref.js';@@ -141,7 +141,7 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {accessor host!: EditorHost;@property({ attribute: false })- accessor doc!: Blocks;+ accessor doc!: Store;@state()accessor isLoading = false;diff --git a/packages/frontend/core/src/blocksuite/presets/ai/messages/slides-renderer.ts b/packages/frontend/core/src/blocksuite/presets/ai/messages/slides-renderer.tsindex eb1b2318a2..f656355d77 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/messages/slides-renderer.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/messages/slides-renderer.ts@@ -6,8 +6,7 @@ import {} from '@blocksuite/affine/blocks';import { AffineSchemas } from '@blocksuite/affine/blocks/schemas';import { WithDisposable } from '@blocksuite/affine/global/utils';-import type { Blocks } from '@blocksuite/affine/store';-import { Schema, Store } from '@blocksuite/affine/store';+import { Schema, type Store } from '@blocksuite/affine/store';import { css, html, LitElement, nothing } from 'lit';import { property, query } from 'lit/decorators.js';import { createRef, type Ref, ref } from 'lit/directives/ref.js';@@ -53,7 +52,7 @@ export class AISlidesRenderer extends WithDisposable(LitElement) {private readonly _editorContainer: Ref<HTMLDivElement> =createRef<HTMLDivElement>();- private _doc!: Blocks;+ private _doc!: Store;private _docCollection: WorkspaceImpl | null = null;@@ -208,7 +207,7 @@ export class AISlidesRenderer extends WithDisposable(LitElement) {${ref(this._editorContainer)}>${new BlockStdScope({- store: new Store({ blocks: this._doc }),+ store: this._doc,extensions:SpecProvider.getInstance().getSpec('edgeless:preview').value,}).render()}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/mini-mindmap/mindmap-preview.ts b/packages/frontend/core/src/blocksuite/presets/ai/mini-mindmap/mindmap-preview.tsindex f77b2c80ab..43a826d2d6 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/mini-mindmap/mindmap-preview.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/mini-mindmap/mindmap-preview.ts@@ -12,7 +12,7 @@ import {} from '@blocksuite/affine/blocks';import type { ServiceProvider } from '@blocksuite/affine/global/di';import { WithDisposable } from '@blocksuite/affine/global/utils';-import { type Blocks, Job, Schema, Store } from '@blocksuite/affine/store';+import { Job, Schema, type Store } from '@blocksuite/affine/store';import { css, html, LitElement, nothing } from 'lit';import { property, query } from 'lit/decorators.js';import { repeat } from 'lit/directives/repeat.js';@@ -79,7 +79,7 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {}`;- doc?: Blocks;+ doc?: Store;mindmapId?: string;@@ -129,7 +129,7 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {this.requestUpdate();}- private _toMindmapNode(answer: string, doc: Blocks) {+ private _toMindmapNode(answer: string, doc: Store) {return markdownToMindmap(answer, doc, this.host.std.provider);}@@ -175,7 +175,7 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {})}>${new BlockStdScope({- store: new Store({ blocks: this.doc }),+ store: this.doc,extensions: MiniMindmapSpecs,}).render()}</div>@@ -232,7 +232,7 @@ type Node = {export const markdownToMindmap = (answer: string,- doc: Blocks,+ doc: Store,provider: ServiceProvider) => {let result: Node | null = null;diff --git a/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-peek-view.ts b/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-peek-view.tsindex af12fec74d..9960d0badb 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-peek-view.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-peek-view.ts@@ -155,7 +155,7 @@ export class AIChatBlockPeekView extends LitElement {const { doc } = this.host;// create a new AI chat blockconst surfaceBlock = doc- .getBlocks()+ .getStore().find(block => block.flavour === 'affine:surface');if (!surfaceBlock) {return;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.tsxindex 5375246dfb..75a9536698 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@@ -11,7 +11,7 @@ import { WorkspaceService } from '@affine/core/modules/workspace';import { i18nTime, Trans, useI18n } from '@affine/i18n';import { track } from '@affine/track';import type { DocMode } from '@blocksuite/affine/blocks';-import type { Blocks, Workspace } from '@blocksuite/affine/store';+import type { Store, Workspace } from '@blocksuite/affine/store';import { CloseIcon, ToggleRightIcon } from '@blocksuite/icons/rc';import * as Collapsible from '@radix-ui/react-collapsible';import type { DialogContentProps } from '@radix-ui/react-dialog';@@ -87,7 +87,7 @@ const ModalContainer = ({interface HistoryEditorPreviewProps {ts?: string;historyList: HistoryList;- snapshotPage?: Blocks;+ snapshotPage?: Store;mode: DocMode;onModeChange: (mode: DocMode) => void;title: string;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.tsxindex 7e73a7dc84..7b4cec49e7 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,14 +1,14 @@import { useEnableCloud } from '@affine/core/components/hooks/affine/use-enable-cloud';import type { Workspace } from '@affine/core/modules/workspace';import { track } from '@affine/track';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useCallback } from 'react';import { ShareMenu } from './share-menu';type SharePageModalProps = {workspace: Workspace;- page: Blocks;+ page: Store;};export const SharePageButton = ({ workspace, page }: SharePageModalProps) => {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.tsxindex 7084bd81b1..3d4f616a21 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 { ShareInfoService } from '@affine/core/modules/share-doc';import type { WorkspaceMetadata } from '@affine/core/modules/workspace';import { useI18n } from '@affine/i18n';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { LockIcon, PublishIcon } from '@blocksuite/icons/rc';import { useLiveData, useService } from '@toeverything/infra';import { forwardRef, type PropsWithChildren, type Ref, useEffect } from 'react';@@ -15,7 +15,7 @@ import { SharePage } from './share-page';export interface ShareMenuProps extends PropsWithChildren {workspaceMetadata: WorkspaceMetadata;- currentPage: Blocks;+ currentPage: Store;onEnableAffineCloud: () => void;onOpenShareModal?: (open: boolean) => void;}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.tsxindex 60e49b2c69..747d6984b9 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@@ -10,7 +10,7 @@ import type {EdgelessEditor,PageEditor,} from '@blocksuite/affine/presets';-import { type BlockModel, type Blocks } from '@blocksuite/affine/store';+import { type BlockModel, type Store } from '@blocksuite/affine/store';import clsx from 'clsx';import type React from 'react';import {@@ -27,7 +27,7 @@ import { BlocksuiteDocEditor, BlocksuiteEdgelessEditor } from './lit-adaper';import * as styles from './styles.css';interface BlocksuiteEditorContainerProps {- page: Blocks;+ page: Store;mode: DocMode;shared?: boolean;className?: string;@@ -191,7 +191,7 @@ export const BlocksuiteEditorContainer = forwardRef<});// copy from '@blocksuite/affine-shared/utils'-export function getLastNoteBlock(doc: Blocks) {+export function getLastNoteBlock(doc: Store) {let note: NoteBlockModel | null = null;if (!doc.root) return null;const { children } = doc.root;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.tsxindex 352ae5a4e6..237fd53567 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@@ -11,7 +11,7 @@ import {} from '@blocksuite/affine/blocks';import { DisposableGroup } from '@blocksuite/affine/global/utils';import type { AffineEditorContainer } from '@blocksuite/affine/presets';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import type { CSSProperties } from 'react';import { useEffect, useState } from 'react';@@ -20,7 +20,7 @@ import { BlocksuiteEditorContainer } from './blocksuite-editor-container';import { NoPageRootError } from './no-page-error';export type EditorProps = {- page: Blocks;+ page: Store;mode: DocMode;shared?: boolean;defaultOpenProperty?: DefaultOpenProperty;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.tsxindex c943059928..bbeb343cea 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,12 +1,12 @@import { JournalService } from '@affine/core/modules/journal';import { i18nTime, useI18n } from '@affine/i18n';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useLiveData, useService } from '@toeverything/infra';import dayjs from 'dayjs';import * as styles from './styles.css';-export const BlocksuiteEditorJournalDocTitle = ({ page }: { page: Blocks }) => {+export const BlocksuiteEditorJournalDocTitle = ({ page }: { page: Store }) => {const journalService = useService(JournalService);const journalDateStr = useLiveData(journalService.journalDate$(page.id));const journalDate = journalDateStr ? dayjs(journalDateStr) : null;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.tsxindex a28707bb2e..7ea6173db6 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@@ -23,7 +23,7 @@ import {EdgelessEditor,PageEditor,} from '@blocksuite/affine/presets';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import {useFramework,useLiveData,@@ -86,7 +86,7 @@ const adapted = {};interface BlocksuiteEditorProps {- page: Blocks;+ page: Store;shared?: boolean;defaultOpenProperty?: DefaultOpenProperty;}diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/no-page-error.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/no-page-error.tsindex b2ea293a14..fa2aeaea66 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/no-page-error.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/no-page-error.ts@@ -1,11 +1,11 @@-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import type { Doc as YDoc, Map as YMap } from 'yjs';/*** TODO(@eyhn): Define error to unexpected state together in the future.*/export class NoPageRootError extends Error {- constructor(public page: Blocks) {+ constructor(public page: Store) {super('Page root not found when render editor!');// Log info to let sentry collect more messagediff --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.tsxindex e2cbd9c73f..f8a273f140 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@@ -2,13 +2,13 @@ import type { WeekDatePickerHandle } from '@affine/component';import { WeekDatePicker } from '@affine/component';import { useJournalRouteHelper } from '@affine/core/components/hooks/use-journal';import { JournalService } from '@affine/core/modules/journal';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useLiveData, useService } from '@toeverything/infra';import dayjs from 'dayjs';import { useEffect, useRef, useState } from 'react';export interface JournalWeekDatePickerProps {- page: Blocks;+ page: Store;}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.tsxindex df4b7198da..6e1d1bc54c 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@@ -22,7 +22,7 @@ import { ViewService } from '@affine/core/modules/workbench/services/view';import { WorkspaceService } from '@affine/core/modules/workspace';import { useI18n } from '@affine/i18n';import { track } from '@affine/track';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import {DuplicateIcon,EdgelessIcon,@@ -52,7 +52,7 @@ import { HistoryTipsModal } from './history-tips-modal';type PageMenuProps = {rename?: () => void;- page: Blocks;+ page: Store;isJournal?: boolean;containerWidth: number;};diff --git a/packages/frontend/core/src/components/hooks/affine/use-export-page.ts b/packages/frontend/core/src/components/hooks/affine/use-export-page.tsindex 9931f5ea8a..db00a32679 100644--- a/packages/frontend/core/src/components/hooks/affine/use-export-page.ts+++ b/packages/frontend/core/src/components/hooks/affine/use-export-page.ts@@ -22,7 +22,7 @@ import {ZipTransformer,} from '@blocksuite/affine/blocks';import type { AffineEditorContainer } from '@blocksuite/affine/presets';-import { type Blocks, Job } from '@blocksuite/affine/store';+import { Job, type Store } from '@blocksuite/affine/store';import { useLiveData, useService } from '@toeverything/infra';import { useSetAtom } from 'jotai';import { nanoid } from 'nanoid';@@ -32,7 +32,7 @@ import { useAsyncCallback } from '../affine-async-hooks';type ExportType = 'pdf' | 'html' | 'png' | 'markdown' | 'snapshot';interface ExportHandlerOptions {- page: Blocks;+ page: Store;editorContainer: AffineEditorContainer;type: ExportType;}@@ -54,7 +54,7 @@ interface AdapterConfig {}async function exportDoc(- doc: Blocks,+ doc: Store,std: BlockStdScope,config: AdapterConfig) {@@ -103,7 +103,7 @@ async function exportDoc(download(downloadBlob, name);}-async function exportToHtml(doc: Blocks, std?: BlockStdScope) {+async function exportToHtml(doc: Store, std?: BlockStdScope) {if (!std) {// If std is not provided, we use the default export methodawait HtmlTransformer.exportDoc(doc);@@ -117,7 +117,7 @@ async function exportToHtml(doc: Blocks, std?: BlockStdScope) {}}-async function exportToMarkdown(doc: Blocks, std?: BlockStdScope) {+async function exportToMarkdown(doc: Store, std?: BlockStdScope) {if (!std) {// If std is not provided, we use the default export methodawait MarkdownTransformer.exportDoc(doc);diff --git a/packages/frontend/core/src/components/hooks/use-block-suite-workspace-helper.ts b/packages/frontend/core/src/components/hooks/use-block-suite-workspace-helper.tsindex 60e0d5f821..8c50dc4004 100644--- a/packages/frontend/core/src/components/hooks/use-block-suite-workspace-helper.ts+++ b/packages/frontend/core/src/components/hooks/use-block-suite-workspace-helper.ts@@ -1,10 +1,10 @@-import type { Blocks, Workspace } from '@blocksuite/affine/store';+import type { Store, Workspace } from '@blocksuite/affine/store';import { useMemo } from 'react';export function useDocCollectionHelper(docCollection: Workspace) {return useMemo(() => ({- createDoc: (pageId?: string): Blocks => {+ createDoc: (pageId?: string): Store => {return docCollection.createDoc({ id: pageId });},}),diff --git a/packages/frontend/core/src/components/hooks/use-block-suite-workspace-page.ts b/packages/frontend/core/src/components/hooks/use-block-suite-workspace-page.tsindex 4d4336ca3a..7817da7fd9 100644--- a/packages/frontend/core/src/components/hooks/use-block-suite-workspace-page.ts+++ b/packages/frontend/core/src/components/hooks/use-block-suite-workspace-page.ts@@ -1,6 +1,6 @@import { DebugLogger } from '@affine/debug';import { DisposableGroup } from '@blocksuite/affine/global/utils';-import type { Blocks, Workspace } from '@blocksuite/affine/store';+import type { Store, Workspace } from '@blocksuite/affine/store';import { useEffect, useState } from 'react';const logger = new DebugLogger('use-doc-collection-page');@@ -8,7 +8,7 @@ const logger = new DebugLogger('use-doc-collection-page');export function useDocCollectionPage(docCollection: Workspace,pageId: string | null-): Blocks | null {+): Store | null {const [page, setPage] = useState(pageId ? docCollection.getDoc(pageId) : null);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.tsindex b7b2cabc53..137844d50a 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 { AffineSchemas } from '@blocksuite/affine/blocks/schemas';import { assertExists } from '@blocksuite/affine/global/utils';-import { type Blocks, Text } from '@blocksuite/affine/store';+import { type Store, Text } from '@blocksuite/affine/store';import { Schema } from '@blocksuite/store';import { TestWorkspace } from '@blocksuite/store/test';import { renderHook } from '@testing-library/react';@@ -22,7 +22,7 @@ beforeEach(async () => {vi.useFakeTimers({ toFake: ['requestIdleCallback'] });docCollection = new TestWorkspace({ id: 'test', schema });docCollection.meta.initialize();- const initPage = async (page: Blocks) => {+ const initPage = async (page: Store) => {page.load();expect(page).not.toBeNull();assertExists(page);@@ -37,7 +37,7 @@ beforeEach(async () => {describe('useBlockSuitePagePreview', () => {test('basic', async () => {- const page = docCollection.getDoc('page0') as Blocks;+ const page = docCollection.getDoc('page0') as Store;const id = page.addBlock('affine:paragraph',{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.tsindex 23877692b0..02debbdcfa 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 { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/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<Blocks, Atom<string>>();+const weakMap = new WeakMap<Store, Atom<string>>();-export const getPagePreviewText = (page: Blocks) => {+export const getPagePreviewText = (page: Store) => {const pageRoot = page.root;if (!pageRoot) {return '';@@ -60,7 +60,7 @@ export const getPagePreviewText = (page: Blocks) => {const emptyAtom = atom<string>('');-export function useBlockSuitePagePreview(page: Blocks | null): Atom<string> {+export function useBlockSuitePagePreview(page: Store | null): Atom<string> {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.tsindex 03249e5036..753bc073b5 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,6 +1,6 @@import { DebugLogger } from '@affine/debug';import { DisposableGroup } from '@blocksuite/affine/global/utils';-import type { Blocks, Workspace } from '@blocksuite/affine/store';+import type { Store, Workspace } from '@blocksuite/affine/store';import { useEffect, useState } from 'react';const logger = new DebugLogger('useBlockSuiteWorkspacePage');@@ -8,7 +8,7 @@ const logger = new DebugLogger('useBlockSuiteWorkspacePage');export function useDocCollectionPage(docCollection: Workspace,pageId: string | null-): Blocks | null {+): Store | null {const [page, setPage] = useState(pageId ? docCollection.getDoc(pageId) : null);diff --git a/packages/frontend/core/src/components/root-app-sidebar/index.tsx b/packages/frontend/core/src/components/root-app-sidebar/index.tsxindex 6246e7eb0f..593ffab8c9 100644--- a/packages/frontend/core/src/components/root-app-sidebar/index.tsx+++ b/packages/frontend/core/src/components/root-app-sidebar/index.tsx@@ -25,7 +25,7 @@ import { CMDKQuickSearchService } from '@affine/core/modules/quicksearch/serviceimport type { Workspace } from '@affine/core/modules/workspace';import { useI18n } from '@affine/i18n';import { track } from '@affine/track';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import {AllDocsIcon,GithubIcon,@@ -56,7 +56,7 @@ export type RootAppSidebarProps = {onOpenSettingModal: () => void;currentWorkspace: Workspace;openPage: (pageId: string) => void;- createPage: () => Blocks;+ createPage: () => Store;paths: {all: (workspaceId: string) => string;trash: (workspaceId: string) => string;diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/connector.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/connector.tsxindex 65d2c5d257..ff1d8d7622 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/connector.tsx+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/connector.tsx@@ -19,7 +19,7 @@ import {StrokeStyle,TextAlign,} from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useFramework, useLiveData } from '@toeverything/infra';import { isEqual } from 'lodash-es';import { useCallback, useMemo } from 'react';@@ -357,7 +357,7 @@ export const ConnectorSettings = () => {return getCurrentTextColor(color);}, [getCurrentTextColor, settings]);- const getElements = useCallback((doc: Blocks) => {+ const getElements = useCallback((doc: Store) => {const surface = getSurfaceBlock(doc);return surface?.getElementsByType('connector') || [];}, []);diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/docs/index.ts b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/docs/index.tsindex 8eb50ffddd..60361f8f12 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/docs/index.ts+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/docs/index.ts@@ -1,6 +1,6 @@import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace';import { AffineSchemas } from '@blocksuite/affine/blocks';-import type { Blocks, DocSnapshot } from '@blocksuite/affine/store';+import type { DocSnapshot, Store } from '@blocksuite/affine/store';import { Job, Schema } from '@blocksuite/affine/store';const getCollection = (() => {@@ -26,7 +26,7 @@ export type DocName =| 'connector'| 'mindmap';-const docMap = new Map<DocName, Promise<Blocks | undefined>>();+const docMap = new Map<DocName, Promise<Store | undefined>>();async function loadNote() {return (await import('./note.json')).default;diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/mind-map.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/mind-map.tsxindex 8d831db3c3..5480a9c62e 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/mind-map.tsx+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/mind-map.tsx@@ -8,7 +8,7 @@ import { SettingRow } from '@affine/component/setting-components';import { EditorSettingService } from '@affine/core/modules/editor-setting';import { useI18n } from '@affine/i18n';import { LayoutType, MindmapStyle } from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useFramework, useLiveData } from '@toeverything/infra';import { useCallback, useMemo } from 'react';@@ -93,7 +93,7 @@ export const MindMapSettings = () => {});}, [editorSetting, settings]);- const getElements = useCallback((doc: Blocks) => {+ const getElements = useCallback((doc: Store) => {const surface = getSurfaceBlock(doc);return surface?.getElementsByType('mindmap') || [];}, []);diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/note.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/note.tsxindex a7c2429697..4dbccef167 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/note.tsx+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/note.tsx@@ -15,7 +15,7 @@ import {NoteShadowMap,StrokeStyle,} from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useFramework, useLiveData } from '@toeverything/infra';import { isEqual } from 'lodash-es';import { useCallback, useMemo } from 'react';@@ -170,7 +170,7 @@ export const NoteSettings = () => {return getCurrentColor(background);}, [getCurrentColor, settings]);- const getElements = useCallback((doc: Blocks) => {+ const getElements = useCallback((doc: Store) => {return doc.getBlocksByFlavour('affine:note') || [];}, []);diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/pen.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/pen.tsxindex 10de31438a..690cd27b59 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/pen.tsx+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/pen.tsx@@ -3,7 +3,7 @@ import { SettingRow } from '@affine/component/setting-components';import { EditorSettingService } from '@affine/core/modules/editor-setting';import { useI18n } from '@affine/i18n';import { DefaultTheme } from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useFramework, useLiveData } from '@toeverything/infra';import { isEqual } from 'lodash-es';import { useCallback, useMemo } from 'react';@@ -59,7 +59,7 @@ export const PenSettings = () => {[editorSetting]);- const getElements = useCallback((doc: Blocks) => {+ const getElements = useCallback((doc: Store) => {const surface = getSurfaceBlock(doc);return surface?.getElementsByType('brush') || [];}, []);diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/shape.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/shape.tsxindex 2611992f86..6cc54f04e5 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/shape.tsx+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/shape.tsx@@ -26,7 +26,7 @@ import {StrokeStyle,TextAlign,} from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useFramework, useLiveData } from '@toeverything/infra';import { isEqual } from 'lodash-es';import { useCallback, useMemo, useState } from 'react';@@ -339,7 +339,7 @@ export const ShapeSettings = () => {}, [editorSetting, settings, currentShape, strokeColorPalettes]);const getElements = useCallback(- (doc: Blocks) => {+ (doc: Store) => {const surface = getSurfaceBlock(doc);if (!surface) return [];return surface.getElementsByType('shape').filter(node => {@@ -353,7 +353,7 @@ export const ShapeSettings = () => {);const firstUpdate = useCallback(- (doc: Blocks, editorHost: EditorHost) => {+ (doc: Store, editorHost: EditorHost) => {const edgelessService = editorHost.std.getService('affine:page') as EdgelessRootService;diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/snapshot.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/snapshot.tsxindex 93d77c863c..7c8d489743 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/snapshot.tsx+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/snapshot.tsx@@ -19,7 +19,7 @@ import {ThemeExtensionIdentifier,} from '@blocksuite/affine/blocks';import { Bound } from '@blocksuite/affine/global/utils';-import { type Block, type Blocks, Store } from '@blocksuite/affine/store';+import type { Block, Store } from '@blocksuite/affine/store';import { createSignalFromObservable } from '@blocksuite/affine-shared/utils';import type { Container } from '@blocksuite/global/di';import type { Signal } from '@preact/signals-core';@@ -45,8 +45,8 @@ interface Props {docName: DocName;keyName: keyof EditorSettingSchema;height?: number;- getElements: (doc: Blocks) => Array<Block | GfxPrimitiveElementModel>;- firstUpdate?: (doc: Blocks, editorHost: EditorHost) => void;+ getElements: (doc: Store) => Array<Block | GfxPrimitiveElementModel>;+ firstUpdate?: (doc: Store, editorHost: EditorHost) => void;children?: React.ReactElement;}@@ -63,7 +63,7 @@ export const EdgelessSnapshot = (props: Props) => {children,} = props;const wrapperRef = useRef<HTMLDivElement | null>(null);- const docRef = useRef<Blocks | null>(null);+ const docRef = useRef<Store | null>(null);const editorHostRef = useRef<EditorHost | null>(null);const framework = useFramework();const { editorSetting } = framework.get(EditorSettingService);@@ -90,7 +90,7 @@ export const EdgelessSnapshot = (props: Props) => {if (!doc) return;const editorHost = new BlockStdScope({- store: new Store({ blocks: doc }),+ store: doc,extensions: [...SpecProvider.getInstance().getSpec('edgeless:preview').value,getThemeExtension(framework),diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/text.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/text.tsxindex aec3ef9b32..4f5685637a 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/text.tsx+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/text.tsx@@ -15,7 +15,7 @@ import {FontWeightMap,TextAlign,} from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useFramework, useLiveData } from '@toeverything/infra';import { isEqual } from 'lodash-es';import { useCallback, useMemo } from 'react';@@ -143,7 +143,7 @@ export const TextSettings = () => {return getCurrentColor(color);}, [getCurrentColor, settings]);- const getElements = useCallback((doc: Blocks) => {+ const getElements = useCallback((doc: Store) => {return doc.getBlocksByFlavour('affine:edgeless-text') || [];}, []);diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/utils.ts b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/utils.tsindex ed76064458..821e12823e 100644--- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/utils.ts+++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/editor/edgeless/utils.ts@@ -1,13 +1,13 @@import type { SurfaceBlockModel } from '@blocksuite/affine/block-std/gfx';import type { FrameBlockModel } from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';-export function getSurfaceBlock(doc: Blocks) {+export function getSurfaceBlock(doc: Store) {const blocks = doc.getBlocksByFlavour('affine:surface');return blocks.length !== 0 ? (blocks[0].model as SurfaceBlockModel) : null;}-export function getFrameBlock(doc: Blocks) {+export function getFrameBlock(doc: Store) {const blocks = doc.getBlocksByFlavour('affine:frame');return blocks.length !== 0 ? (blocks[0].model as FrameBlockModel) : null;}diff --git a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsx b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsxindex 436920b663..f599dbdfdb 100644--- a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsx+++ b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page-header.tsx@@ -24,7 +24,7 @@ import type { Workspace } from '@affine/core/modules/workspace';import type { AffineDNDData } from '@affine/core/types/dnd';import { useI18n } from '@affine/i18n';import { track } from '@affine/track';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { useLiveData, useService } from '@toeverything/infra';import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';@@ -49,7 +49,7 @@ const Header = forwardRef<Header.displayName = 'forwardRef(Header)';interface PageHeaderProps {- page: Blocks;+ page: Store;workspace: Workspace;}export function JournalPageHeader({ page, workspace }: PageHeaderProps) {diff --git a/packages/frontend/core/src/desktop/pages/workspace/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/index.tsxindex 518725573b..91cb69dbe4 100644--- a/packages/frontend/core/src/desktop/pages/workspace/index.tsx+++ b/packages/frontend/core/src/desktop/pages/workspace/index.tsx@@ -265,7 +265,7 @@ const WorkspacePage = ({ meta }: { meta: WorkspaceMetadata }) => {workspace.docCollection,Array.from(workspace.docCollection.docs.values()).filter(doc => (docs ? docs.includes(doc.id) : true))- .map(doc => doc.getBlocks())+ .map(doc => doc.getStore()));};window.importWorkspaceSnapshot = async () => {diff --git a/packages/frontend/core/src/modules/dnd/services/index.ts b/packages/frontend/core/src/modules/dnd/services/index.tsindex f071abe04a..18d48b4b5b 100644--- a/packages/frontend/core/src/modules/dnd/services/index.ts+++ b/packages/frontend/core/src/modules/dnd/services/index.ts@@ -7,7 +7,7 @@ import { createPageModeSpecs } from '@affine/core/components/blocksuite/block-suimport type { AffineDNDData } from '@affine/core/types/dnd';import { BlockStdScope } from '@blocksuite/affine/block-std';import { DndApiExtensionIdentifier } from '@blocksuite/affine/blocks';-import { type SliceSnapshot, Store } from '@blocksuite/affine/store';+import { type SliceSnapshot } from '@blocksuite/affine/store';import { Service } from '@toeverything/infra';import type { DocsService } from '../../doc';@@ -69,7 +69,7 @@ export class DndService extends Service {}const std = new BlockStdScope({- store: new Store({ blocks: doc }),+ store: doc,extensions: createPageModeSpecs(this.framework),});const dndAPI = std.get(DndApiExtensionIdentifier);diff --git a/packages/frontend/core/src/modules/doc-info/utils.ts b/packages/frontend/core/src/modules/doc-info/utils.tsindex 587a848f0b..49298310d9 100644--- a/packages/frontend/core/src/modules/doc-info/utils.ts+++ b/packages/frontend/core/src/modules/doc-info/utils.ts@@ -1,7 +1,7 @@import { DebugLogger } from '@affine/debug';import { BlockStdScope } from '@blocksuite/affine/block-std';import { PageEditorBlockSpecs } from '@blocksuite/affine/blocks';-import { type Blocks, Store } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { LiveData } from '@toeverything/infra';import { useMemo } from 'react';import { Observable } from 'rxjs';@@ -42,15 +42,15 @@ export function signalToLiveData<T>(}// todo(pengx17): use rc pool?-export function createBlockStdScope(doc: Blocks) {+export function createBlockStdScope(doc: Store) {logger.debug('createBlockStdScope', doc.id);const std = new BlockStdScope({- store: new Store({ blocks: doc }),+ store: doc,extensions: PageEditorBlockSpecs,});return std;}-export function useBlockStdScope(doc: Blocks) {+export function useBlockStdScope(doc: Store) {return useMemo(() => createBlockStdScope(doc), [doc]);}diff --git a/packages/frontend/core/src/modules/doc-info/views/database-properties/cells/rich-text.tsx b/packages/frontend/core/src/modules/doc-info/views/database-properties/cells/rich-text.tsxindex c4dc5104a5..de17893bd1 100644--- a/packages/frontend/core/src/modules/doc-info/views/database-properties/cells/rich-text.tsx+++ b/packages/frontend/core/src/modules/doc-info/views/database-properties/cells/rich-text.tsx@@ -5,7 +5,7 @@ import {DefaultInlineManagerExtension,RichText,} from '@blocksuite/affine/blocks';-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { TextIcon } from '@blocksuite/icons/rc';import { type LiveData, useLiveData } from '@toeverything/infra';import { type CSSProperties, useEffect, useRef, useState } from 'react';@@ -23,7 +23,7 @@ const renderRichText = ({}: {std: BlockStdScope;text: Y.Text;- doc: Blocks;+ doc: Store;}) => {const inlineManager = std.get(DefaultInlineManagerExtension.identifier);diff --git a/packages/frontend/core/src/modules/doc/scopes/doc.ts b/packages/frontend/core/src/modules/doc/scopes/doc.tsindex 4b06fe3fe3..6677e5f010 100644--- a/packages/frontend/core/src/modules/doc/scopes/doc.ts+++ b/packages/frontend/core/src/modules/doc/scopes/doc.ts@@ -1,4 +1,4 @@-import type { Blocks } from '@blocksuite/affine/store';+import type { Store } from '@blocksuite/affine/store';import { Scope } from '@toeverything/infra';import type { DocRecord } from '../entities/record';@@ -6,5 +6,5 @@ import type { DocRecord } from '../entities/record';export class DocScope extends Scope<{docId: string;record: DocRecord;- blockSuiteDoc: Blocks;+ blockSuiteDoc: Store;}> {}diff --git a/packages/frontend/core/src/modules/workspace/impls/doc.ts b/packages/frontend/core/src/modules/workspace/impls/doc.tsindex ce7ed17250..1d4291d1a3 100644--- a/packages/frontend/core/src/modules/workspace/impls/doc.ts+++ b/packages/frontend/core/src/modules/workspace/impls/doc.ts@@ -1,10 +1,10 @@import { type Disposable, Slot } from '@blocksuite/affine/global/utils';import {type AwarenessStore,- Blocks,type Doc,type GetBlocksOptions,type Query,+ Store,type Workspace,type YBlock,} from '@blocksuite/affine/store';@@ -28,9 +28,9 @@ export class DocImpl implements Doc {private readonly _collection: Workspace;private readonly _docMap = {- undefined: new Map<string, Blocks>(),- true: new Map<string, Blocks>(),- false: new Map<string, Blocks>(),+ undefined: new Map<string, Store>(),+ true: new Map<string, Store>(),+ false: new Map<string, Store>(),};// doc/space container.@@ -274,20 +274,22 @@ export class DocImpl implements Doc {}}- getBlocks({ readonly, query }: GetBlocksOptions = {}) {+ getStore({ readonly, query, provider, extensions }: GetBlocksOptions = {}) {const readonlyKey = this._getReadonlyKey(readonly);const key = JSON.stringify(query);if (this._docMap[readonlyKey].has(key)) {- return this._docMap[readonlyKey].get(key) as Blocks;+ return this._docMap[readonlyKey].get(key) as Store;}- const doc = new Blocks({- blockCollection: this,+ const doc = new Store({+ doc: this,schema: this.workspace.schema,readonly,query,+ provider,+ extensions,});this._docMap[readonlyKey].set(key, doc);diff --git a/packages/frontend/core/src/modules/workspace/impls/workspace.ts b/packages/frontend/core/src/modules/workspace/impls/workspace.tsindex ef7e32d4bf..a124939d1e 100644--- a/packages/frontend/core/src/modules/workspace/impls/workspace.ts+++ b/packages/frontend/core/src/modules/workspace/impls/workspace.ts@@ -6,13 +6,13 @@ import type { BlockSuiteFlags } from '@blocksuite/affine/global/types';import { NoopLogger, Slot } from '@blocksuite/affine/global/utils';import {AwarenessStore,- type Blocks,type CreateBlocksOptions,type Doc,type GetBlocksOptions,type IdGenerator,nanoid,type Schema,+ type Store,type Workspace,type WorkspaceMeta,} from '@blocksuite/affine/store';@@ -152,7 +152,7 @@ export class WorkspaceImpl implements Workspace {tags: [],});this.slots.docCreated.emit(docId);- return this.getDoc(docId, { query, readonly }) as Blocks;+ return this.getDoc(docId, { query, readonly }) as Store;}dispose() {@@ -164,9 +164,9 @@ export class WorkspaceImpl implements Workspace {return space ?? null;}- getDoc(docId: string, options?: GetBlocksOptions): Blocks | null {+ getDoc(docId: string, options?: GetBlocksOptions): Store | null {const collection = this._getDoc(docId);- return collection?.getBlocks(options) ?? null;+ return collection?.getStore(options) ?? null;}removeDoc(docId: string) {