Skip to content

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.

refactor(editor): rename store api (#9518)

Saul-Mironec773982ced9a
diff --git a/blocksuite/affine/block-data-view/src/block-meta/todo.ts b/blocksuite/affine/block-data-view/src/block-meta/todo.ts
index c76a3df464..db3e96ee23 100644
--- a/blocksuite/affine/block-data-view/src/block-meta/todo.ts
+++ b/blocksuite/affine/block-data-view/src/block-meta/todo.ts
@@ -53,7 +53,7 @@ todoMeta.addProperty({
metaConfig: propertyPresets.textPropertyConfig,
get: block => block.doc.meta?.title ?? '',
updated: (block, callback) => {
- return block.doc.collection.slots.docListUpdated.on(() => {
+ return block.doc.workspace.slots.docListUpdated.on(() => {
callback();
});
},
diff --git a/blocksuite/affine/block-data-view/src/data-source.ts b/blocksuite/affine/block-data-view/src/data-source.ts
index 19d1d51d54..1d0a76d9a8 100644
--- a/blocksuite/affine/block-data-view/src/data-source.ts
+++ b/blocksuite/affine/block-data-view/src/data-source.ts
@@ -59,7 +59,7 @@ export class BlockQueryDataSource extends DataSourceBase {
}
get workspace() {
- return this.host.doc.collection;
+ return this.host.doc.workspace;
}
constructor(
@@ -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.getDoc().blocks.peek())) {
+ for (const block of Object.values(collection.getBlocks().blocks.peek())) {
if (this.meta.selector(block)) {
this.blockMap.set(block.id, block);
}
}
}
this.workspace.docs.forEach(doc => {
- this.listenToDoc(doc.getDoc());
+ this.listenToDoc(doc.getBlocks());
});
this.workspace.slots.docCreated.on(id => {
const doc = this.workspace.getDoc(id);
@@ -167,7 +167,7 @@ export class BlockQueryDataSource extends DataSourceBase {
type ?? propertyPresets.multiSelectPropertyConfig.type
].create(this.newColumnName());
- const id = doc.collection.idGenerator();
+ const id = doc.workspace.idGenerator();
if (this.block.columns.some(v => v.id === id)) {
return id;
}
diff --git a/blocksuite/affine/block-data-view/src/data-view-model.ts b/blocksuite/affine/block-data-view/src/data-view-model.ts
index d18135084e..b4445deb4c 100644
--- a/blocksuite/affine/block-data-view/src/data-view-model.ts
+++ b/blocksuite/affine/block-data-view/src/data-view-model.ts
@@ -33,7 +33,7 @@ export class DataViewBlockModel extends BlockModel<Props> {
}
duplicateView(id: string): string {
- const newId = this.doc.collection.idGenerator();
+ const newId = this.doc.workspace.idGenerator();
this.doc.transact(() => {
const index = this.views.findIndex(v => v.id === id);
const view = this.views[index];
diff --git a/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts b/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts
index 8f284af540..b5c269e20e 100644
--- a/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts
+++ b/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts
@@ -47,7 +47,7 @@ export class NoteRenderer
}
addNote() {
- const collection = this.host?.std.collection;
+ const collection = this.host?.std.workspace;
if (!collection) {
return;
}
diff --git a/blocksuite/affine/block-database/src/properties/link/cell-renderer.ts b/blocksuite/affine/block-database/src/properties/link/cell-renderer.ts
index 9d71184c75..d43e22a276 100644
--- a/blocksuite/affine/block-database/src/properties/link/cell-renderer.ts
+++ b/blocksuite/affine/block-database/src/properties/link/cell-renderer.ts
@@ -132,7 +132,7 @@ export class LinkCell extends BaseCellRenderer<string> {
override render() {
const linkText = this.value ?? '';
const docName =
- this.docId && this.std?.collection.getDoc(this.docId)?.meta?.title;
+ this.docId && this.std?.workspace.getDoc(this.docId)?.meta?.title;
return html`
<div class="affine-database-link" @click="${this._onClick}">
${docName
diff --git a/blocksuite/affine/block-database/src/properties/title/define.ts b/blocksuite/affine/block-database/src/properties/title/define.ts
index a1217e32db..264765aa6a 100644
--- a/blocksuite/affine/block-database/src/properties/title/define.ts
+++ b/blocksuite/affine/block-database/src/properties/title/define.ts
@@ -19,7 +19,7 @@ export const titlePurePropertyConfig = titleColumnType.modelConfig<Text>({
cellToJson: ({ value, dataSource }) => {
const host = dataSource.contextGet(HostContextKey);
if (host) {
- const collection = host.std.collection;
+ const collection = host.std.workspace;
const deltas = value.deltas$.value;
const text = deltas
.map(delta => {
diff --git a/blocksuite/affine/block-database/src/properties/title/text.ts b/blocksuite/affine/block-database/src/properties/title/text.ts
index 080b1653b8..2ffdfd6a88 100644
--- a/blocksuite/affine/block-database/src/properties/title/text.ts
+++ b/blocksuite/affine/block-database/src/properties/title/text.ts
@@ -98,7 +98,7 @@ abstract class BaseTextCell extends BaseCellRenderer<Text> {
if (!this.docId$.value) {
return this.value;
}
- const doc = this.host?.std.collection.getDoc(this.docId$.value);
+ const doc = this.host?.std.workspace.getDoc(this.docId$.value);
const root = doc?.root as RootBlockModel;
return root.title;
});
diff --git a/blocksuite/affine/block-database/src/utils/block-utils.ts b/blocksuite/affine/block-database/src/utils/block-utils.ts
index bc889769bd..94e8fd0c28 100644
--- a/blocksuite/affine/block-database/src/utils/block-utils.ts
+++ b/blocksuite/affine/block-database/src/utils/block-utils.ts
@@ -19,7 +19,7 @@ export function addProperty(
id?: string;
}
): string {
- const id = column.id ?? model.doc.collection.idGenerator();
+ const id = column.id ?? model.doc.workspace.idGenerator();
if (model.columns.some(v => v.id === id)) {
return id;
}
@@ -101,7 +101,7 @@ export function deleteView(model: DatabaseBlockModel, id: string) {
}
export function duplicateView(model: DatabaseBlockModel, id: string): string {
- const newId = model.doc.collection.idGenerator();
+ const newId = model.doc.workspace.idGenerator();
model.doc.transact(() => {
const index = model.views.findIndex(v => v.id === id);
const view = model.views[index];
diff --git a/blocksuite/affine/block-embed/src/common/render-linked-doc.ts b/blocksuite/affine/block-embed/src/common/render-linked-doc.ts
index dd47c03e4f..23b3559a66 100644
--- a/blocksuite/affine/block-embed/src/common/render-linked-doc.ts
+++ b/blocksuite/affine/block-embed/src/common/render-linked-doc.ts
@@ -196,7 +196,7 @@ async function renderNoteContent(
mode: 'strict',
match: ids.map(id => ({ id, viewType: BlockViewType.Display })),
};
- const previewDoc = doc.blockCollection.getDoc({ query });
+ const previewDoc = doc.doc.getBlocks({ query });
const previewSpec = SpecProvider.getInstance().getSpec('page:preview');
const previewStd = new BlockStdScope({
doc: previewDoc,
@@ -405,7 +405,7 @@ export function createLinkedDocFromSlice(
docTitle?: string
) {
// const modelsWithChildren = (list:BlockModel[]):BlockModel[]=>list.flatMap(model=>[model,...modelsWithChildren(model.children)])
- const linkedDoc = doc.collection.createDoc({});
+ const linkedDoc = doc.workspace.createDoc({});
linkedDoc.load(() => {
const rootId = linkedDoc.addBlock('affine:page', {
title: new Text(docTitle),
diff --git a/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts b/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts
index 8cc68c0708..7279cf1bfa 100644
--- a/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts
+++ b/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts
@@ -114,7 +114,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
};
private readonly _setDocUpdatedAt = () => {
- const meta = this.doc.collection.meta.getDocMeta(this.model.pageId);
+ const meta = this.doc.workspace.meta.getDocMeta(this.model.pageId);
if (meta) {
const date = meta.updatedDate || meta.createDate;
this._docUpdatedAt = new Date(date);
@@ -241,7 +241,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
}
get linkedDoc() {
- return this.std.collection.getDoc(this.model.pageId);
+ return this.std.workspace.getDoc(this.model.pageId);
}
private _handleDoubleClick(event: MouseEvent) {
@@ -296,7 +296,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
const linkedDoc = this.linkedDoc;
if (linkedDoc) {
this.disposables.add(
- linkedDoc.collection.slots.docListUpdated.on(() => {
+ linkedDoc.workspace.slots.docListUpdated.on(() => {
this._load().catch(e => {
console.error(e);
this.isError = true;
@@ -329,7 +329,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
this._setDocUpdatedAt();
this.disposables.add(
- this.doc.collection.slots.docListUpdated.on(() => {
+ this.doc.workspace.slots.docListUpdated.on(() => {
this._setDocUpdatedAt();
})
);
diff --git a/blocksuite/affine/block-embed/src/embed-synced-doc-block/components/embed-synced-doc-card.ts b/blocksuite/affine/block-embed/src/embed-synced-doc-block/components/embed-synced-doc-card.ts
index fee07e4f5e..2a04ee1eea 100644
--- a/blocksuite/affine/block-embed/src/embed-synced-doc-block/components/embed-synced-doc-card.ts
+++ b/blocksuite/affine/block-embed/src/embed-synced-doc-block/components/embed-synced-doc-card.ts
@@ -100,7 +100,7 @@ export class EmbedSyncedDocCard extends WithDisposable(ShadowlessElement) {
}
this.disposables.add(
- syncedDoc.collection.slots.docListUpdated.on(() => {
+ syncedDoc.workspace.slots.docListUpdated.on(() => {
renderLinkedDocInCard(this);
})
);
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.ts
index 5e12c70b15..5cad7e9278 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
@@ -27,7 +27,7 @@ import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
import { assertExists, Bound, getCommonBound } from '@blocksuite/global/utils';
import {
BlockViewType,
- type GetDocOptions,
+ type GetBlocksOptions,
type Query,
Text,
} from '@blocksuite/store';
@@ -365,9 +365,9 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
}
get syncedDoc() {
- const options: GetDocOptions = { readonly: true };
+ const options: GetBlocksOptions = { readonly: true };
if (this.isPageMode) options.query = this._pageFilter;
- return this.std.collection.getDoc(this.model.pageId, options);
+ return this.std.workspace.getDoc(this.model.pageId, options);
}
private _checkCycle() {
@@ -440,7 +440,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
}
private _setDocUpdatedAt() {
- const meta = this.doc.collection.meta.getDocMeta(this.model.pageId);
+ const meta = this.doc.workspace.meta.getDocMeta(this.model.pageId);
if (meta) {
const date = meta.updatedDate || meta.createDate;
this._docUpdatedAt = new Date(date);
@@ -476,7 +476,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
this._setDocUpdatedAt();
this.disposables.add(
- this.doc.collection.slots.docListUpdated.on(() => {
+ this.doc.workspace.slots.docListUpdated.on(() => {
this._setDocUpdatedAt();
})
);
diff --git a/blocksuite/affine/block-surface-ref/src/portal/note.ts b/blocksuite/affine/block-surface-ref/src/portal/note.ts
index b78b26a615..79cb8573ad 100644
--- a/blocksuite/affine/block-surface-ref/src/portal/note.ts
+++ b/blocksuite/affine/block-surface-ref/src/portal/note.ts
@@ -55,7 +55,7 @@ export class SurfaceRefNotePortal extends WithDisposable(ShadowlessElement) {
const doc = this.model.doc;
this._disposables.add(() => {
- doc.blockCollection.clearQuery(query, true);
+ doc.doc.clearQuery(query, true);
});
}
@@ -114,7 +114,7 @@ export class SurfaceRefNotePortal extends WithDisposable(ShadowlessElement) {
console.error('Query is not set before rendering note preview');
return nothing;
}
- const doc = this.model.doc.blockCollection.getDoc({
+ const doc = this.model.doc.doc.getBlocks({
query: this.query,
readonly: true,
});
diff --git a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
index 482ba33873..dc17d4896a 100644
--- a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
+++ b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
@@ -336,8 +336,8 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
];
}
- const doc = [...this.std.collection.docs.values()]
- .map(doc => doc.getDoc())
+ const doc = [...this.std.workspace.docs.values()]
+ .map(doc => doc.getBlocks())
.find(
doc =>
doc.getBlock(this.model.reference) ||
@@ -370,7 +370,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
this._referencedModel =
referencedModel && referencedModel.xywh ? referencedModel : null;
- this._previewDoc = this.doc.collection.getDoc(docId, {
+ this._previewDoc = this.doc.workspace.getDoc(docId, {
readonly: true,
});
this._referenceXYWH = this._referencedModel?.xywh ?? null;
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.ts
index 72ec3272aa..4b0fa57cdb 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
@@ -77,7 +77,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
return;
}
- const refMeta = doc.collection.meta.docMetas.find(
+ const refMeta = doc.workspace.meta.docMetas.find(
doc => doc.id === refAttribute.pageId
);
this.refMeta = refMeta
@@ -221,7 +221,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
const doc = this.doc;
if (doc) {
this._disposables.add(
- doc.collection.slots.docListUpdated.on(() => this._updateRefMeta(doc))
+ doc.workspace.slots.docListUpdated.on(() => this._updateRefMeta(doc))
);
}
diff --git a/blocksuite/affine/components/src/rich-text/keymap/bracket.ts b/blocksuite/affine/components/src/rich-text/keymap/bracket.ts
index fd89816de8..f0ac8d1742 100644
--- a/blocksuite/affine/components/src/rich-text/keymap/bracket.ts
+++ b/blocksuite/affine/components/src/rich-text/keymap/bracket.ts
@@ -150,7 +150,7 @@ function tryConvertToLinkedDoc(std: BlockStdScope, inlineEditor: InlineEditor) {
});
inlineEditor.setInlineRange({ index: inlineRange.index - 1, length: 0 });
- const doc = createDefaultDoc(std.doc.collection, {
+ const doc = createDefaultDoc(std.doc.workspace, {
title: docName,
});
insertLinkedNode({
diff --git a/blocksuite/affine/model/src/blocks/root/root-block-model.ts b/blocksuite/affine/model/src/blocks/root/root-block-model.ts
index 7a44df55c8..ca61212e52 100644
--- a/blocksuite/affine/model/src/blocks/root/root-block-model.ts
+++ b/blocksuite/affine/model/src/blocks/root/root-block-model.ts
@@ -12,9 +12,9 @@ export class RootBlockModel extends BlockModel<RootBlockProps> {
this.doc.slots.rootAdded.on(id => {
const model = this.doc.getBlockById(id);
if (model instanceof RootBlockModel) {
- const newDocMeta = this.doc.collection.meta.getDocMeta(model.doc.id);
+ const newDocMeta = this.doc.workspace.meta.getDocMeta(model.doc.id);
if (!newDocMeta || newDocMeta.title !== model.title.toString()) {
- this.doc.collection.meta.setDocMeta(model.doc.id, {
+ this.doc.workspace.meta.setDocMeta(model.doc.id, {
title: model.title.toString(),
});
}
diff --git a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts b/blocksuite/affine/shared/src/adapters/middlewares/paste.ts
index 2c67f6da7c..2e1242c532 100644
--- a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts
+++ b/blocksuite/affine/shared/src/adapters/middlewares/paste.ts
@@ -400,7 +400,7 @@ class PasteTr {
op.attributes.link
);
if (searchResult) {
- const doc = this.std.collection.getDoc(searchResult.docId);
+ const doc = this.std.workspace.getDoc(searchResult.docId);
if (doc) {
docId = doc.id;
linkToDocId.set(op.attributes.link, doc.id);
diff --git a/blocksuite/affine/shared/src/services/doc-display-meta-service.ts b/blocksuite/affine/shared/src/services/doc-display-meta-service.ts
index b55a52933e..c7b2247b9c 100644
--- a/blocksuite/affine/shared/src/services/doc-display-meta-service.ts
+++ b/blocksuite/affine/shared/src/services/doc-display-meta-service.ts
@@ -88,7 +88,7 @@ export class DocDisplayMetaService
pageId: string,
{ params, title, referenced }: DocDisplayMetaParams = {}
): Signal<TemplateResult> {
- const doc = this.std.collection.getDoc(pageId);
+ const doc = this.std.workspace.getDoc(pageId);
if (!doc) {
return signal(DocDisplayMetaService.icons.deleted);
@@ -114,7 +114,7 @@ export class DocDisplayMetaService
this.disposables.push(disposable);
this.disposables.push(
- this.std.collection.slots.docRemoved
+ this.std.workspace.slots.docRemoved
.filter(docId => docId === doc.id)
.once(() => {
const index = this.disposables.findIndex(d => d === disposable);
@@ -152,7 +152,7 @@ export class DocDisplayMetaService
}
title(pageId: string, { title }: DocDisplayMetaParams = {}): Signal<string> {
- const doc = this.std.collection.getDoc(pageId);
+ const doc = this.std.workspace.getDoc(pageId);
if (!doc) {
return signal(title || 'Deleted doc');
@@ -162,13 +162,13 @@ export class DocDisplayMetaService
if (!title$) {
title$ = signal(doc.meta?.title || 'Untitled');
- const disposable = this.std.collection.slots.docListUpdated.on(() => {
+ const disposable = this.std.workspace.slots.docListUpdated.on(() => {
title$!.value = doc.meta?.title || 'Untitled';
});
this.disposables.push(disposable);
this.disposables.push(
- this.std.collection.slots.docRemoved
+ this.std.workspace.slots.docRemoved
.filter(docId => docId === doc.id)
.once(() => {
const index = this.disposables.findIndex(d => d === disposable);
diff --git a/blocksuite/affine/shared/src/services/drag-handle-config.ts b/blocksuite/affine/shared/src/services/drag-handle-config.ts
index 0a4d0669ab..7cbafc5b1c 100644
--- a/blocksuite/affine/shared/src/services/drag-handle-config.ts
+++ b/blocksuite/affine/shared/src/services/drag-handle-config.ts
@@ -54,7 +54,7 @@ export class DNDAPIExtension extends Extension {
...snapshot,
content: [
{
- id: this.std.collection.idGenerator(),
+ id: this.std.workspace.idGenerator(),
type: 'block',
flavour,
props,
diff --git a/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.ts b/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.ts
index f202506fcc..a2fa5b4e40 100644
--- a/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.ts
+++ b/blocksuite/affine/widget-drag-handle/src/helpers/preview-helper.ts
@@ -79,7 +79,7 @@ export class PreviewHelper {
const query = this._calculateQuery(selectedIds);
- const doc = this.widget.doc.blockCollection.getDoc({ query });
+ const doc = this.widget.doc.doc.getBlocks({ query });
const previewSpec = SpecProvider.getInstance().getSpec('page:preview');
const previewStd = new BlockStdScope({
@@ -96,7 +96,7 @@ export class PreviewHelper {
dragPreview = new DragPreview(offset);
dragPreview.template = previewTemplate;
dragPreview.onRemove = () => {
- this.widget.doc.blockCollection.clearQuery(query);
+ this.widget.doc.doc.clearQuery(query);
};
dragPreview.style.width = `${width / this.widget.scaleInNote.peek()}px`;
dragPreview.style.transform = `translate(${posX}px, ${posY}px) scale(${this.widget.scaleInNote.peek()})`;
diff --git a/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts b/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts
index 0cb2dc5646..deba782587 100644
--- a/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts
+++ b/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts
@@ -10,7 +10,7 @@ export const newIdCrossDoc =
samePage = payload.snapshot.pageId === std.doc.id;
}
if (payload.type === 'block' && !samePage) {
- payload.snapshot.id = std.collection.idGenerator();
+ payload.snapshot.id = std.workspace.idGenerator();
}
});
};
diff --git a/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts b/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts
index 3ffb436b6e..00800020bf 100644
--- a/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts
+++ b/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts
@@ -18,7 +18,7 @@ export const surfaceRefToEmbed =
!std.doc.hasBlock(payload.snapshot.id)
) {
const id = payload.snapshot.id;
- payload.snapshot.id = std.collection.idGenerator();
+ payload.snapshot.id = std.workspace.idGenerator();
payload.snapshot.flavour = 'affine:embed-linked-doc';
payload.snapshot.props = {
blockId: id,
diff --git a/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts b/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts
index 32b5d64a79..86651d59fa 100644
--- a/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts
+++ b/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts
@@ -5,7 +5,7 @@ import { multiPlayersColor } from './color-picker';
export class RemoteColorManager {
private get awarenessStore() {
- return this.std.doc.collection.awarenessStore;
+ return this.std.doc.workspace.awarenessStore;
}
constructor(readonly std: BlockStdScope) {
diff --git a/blocksuite/blocks/src/_common/transformers/html.ts b/blocksuite/blocks/src/_common/transformers/html.ts
index 0a7597cca7..86f072324f 100644
--- a/blocksuite/blocks/src/_common/transformers/html.ts
+++ b/blocksuite/blocks/src/_common/transformers/html.ts
@@ -48,13 +48,13 @@ async function exportDoc(doc: Blocks) {
schema: doc.schema,
blobCRUD: doc.blobSync,
docCRUD: {
- create: (id: string) => doc.collection.createDoc({ id }),
- get: (id: string) => doc.collection.getDoc(id),
- delete: (id: string) => doc.collection.removeDoc(id),
+ create: (id: string) => doc.workspace.createDoc({ id }),
+ get: (id: string) => doc.workspace.getDoc(id),
+ delete: (id: string) => doc.workspace.removeDoc(id),
},
middlewares: [
- docLinkBaseURLMiddleware(doc.collection.id),
- titleMiddleware(doc.collection.meta.docMetas),
+ docLinkBaseURLMiddleware(doc.workspace.id),
+ titleMiddleware(doc.workspace.meta.docMetas),
],
});
const snapshot = job.docToSnapshot(doc);
diff --git a/blocksuite/blocks/src/_common/transformers/markdown.ts b/blocksuite/blocks/src/_common/transformers/markdown.ts
index 827fff078f..0a503532d1 100644
--- a/blocksuite/blocks/src/_common/transformers/markdown.ts
+++ b/blocksuite/blocks/src/_common/transformers/markdown.ts
@@ -54,13 +54,13 @@ async function exportDoc(doc: Blocks) {
schema: doc.schema,
blobCRUD: doc.blobSync,
docCRUD: {
- create: (id: string) => doc.collection.createDoc({ id }),
- get: (id: string) => doc.collection.getDoc(id),
- delete: (id: string) => doc.collection.removeDoc(id),
+ create: (id: string) => doc.workspace.createDoc({ id }),
+ get: (id: string) => doc.workspace.getDoc(id),
+ delete: (id: string) => doc.workspace.removeDoc(id),
},
middlewares: [
- docLinkBaseURLMiddleware(doc.collection.id),
- titleMiddleware(doc.collection.meta.docMetas),
+ docLinkBaseURLMiddleware(doc.workspace.id),
+ titleMiddleware(doc.workspace.meta.docMetas),
],
});
const snapshot = job.docToSnapshot(doc);
@@ -113,20 +113,20 @@ async function importMarkdownToBlock({
schema: doc.schema,
blobCRUD: doc.blobSync,
docCRUD: {
- create: (id: string) => doc.collection.createDoc({ id }),
- get: (id: string) => doc.collection.getDoc(id),
- delete: (id: string) => doc.collection.removeDoc(id),
+ create: (id: string) => doc.workspace.createDoc({ id }),
+ get: (id: string) => doc.workspace.getDoc(id),
+ delete: (id: string) => doc.workspace.removeDoc(id),
},
middlewares: [
defaultImageProxyMiddleware,
- docLinkBaseURLMiddleware(doc.collection.id),
+ docLinkBaseURLMiddleware(doc.workspace.id),
],
});
const adapter = new MarkdownAdapter(job, provider);
const snapshot = await adapter.toSliceSnapshot({
file: markdown,
assets: job.assetsManager,
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
pageId: doc.id,
});
diff --git a/blocksuite/blocks/src/root-block/clipboard/index.ts b/blocksuite/blocks/src/root-block/clipboard/index.ts
index d41d56f7f2..2bc58a07bd 100644
--- a/blocksuite/blocks/src/root-block/clipboard/index.ts
+++ b/blocksuite/blocks/src/root-block/clipboard/index.ts
@@ -60,10 +60,10 @@ export class PageClipboard {
this._std.clipboard.use(copy);
this._std.clipboard.use(paste);
this._std.clipboard.use(
- replaceIdMiddleware(this._std.doc.collection.idGenerator)
+ replaceIdMiddleware(this._std.doc.workspace.idGenerator)
);
this._std.clipboard.use(
- titleMiddleware(this._std.doc.collection.meta.docMetas)
+ titleMiddleware(this._std.doc.workspace.meta.docMetas)
);
this._std.clipboard.use(defaultImageProxyMiddleware);
@@ -85,10 +85,10 @@ export class PageClipboard {
this._std.clipboard.unuse(copy);
this._std.clipboard.unuse(paste);
this._std.clipboard.unuse(
- replaceIdMiddleware(this._std.doc.collection.idGenerator)
+ replaceIdMiddleware(this._std.doc.workspace.idGenerator)
);
this._std.clipboard.unuse(
- titleMiddleware(this._std.doc.collection.meta.docMetas)
+ titleMiddleware(this._std.doc.workspace.meta.docMetas)
);
this._std.clipboard.unuse(defaultImageProxyMiddleware);
},
diff --git a/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts b/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts
index ee3c54cfcc..8a48f71e3d 100644
--- a/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts
@@ -370,12 +370,12 @@ export class EdgelessClipboardController extends PageClipboard {
const elementsRawData = JSON.parse(mayBeSurfaceDataJson);
const { snapshot, blobs } = elementsRawData;
const job = new Job({
- schema: this.std.collection.schema,
- blobCRUD: this.std.collection.blobSync,
+ schema: this.std.workspace.schema,
+ blobCRUD: this.std.workspace.blobSync,
docCRUD: {
- create: (id: string) => this.std.collection.createDoc({ id }),
- get: (id: string) => this.std.collection.getDoc(id),
- delete: (id: string) => this.std.collection.removeDoc(id),
+ create: (id: string) => this.std.workspace.createDoc({ id }),
+ get: (id: string) => this.std.workspace.getDoc(id),
+ delete: (id: string) => this.std.workspace.removeDoc(id),
},
});
const map = job.assetsManager.getAssets();
@@ -475,7 +475,7 @@ export class EdgelessClipboardController extends PageClipboard {
const { xywh, rotate, sourceId, name, size, type, embed, style } =
attachment.props;
- if (!(await this.host.std.collection.blobSync.get(sourceId as string))) {
+ if (!(await this.host.std.workspace.blobSync.get(sourceId as string))) {
return null;
}
const attachmentId = this.crud.addBlock(
@@ -741,7 +741,7 @@ export class EdgelessClipboardController extends PageClipboard {
const { xywh, rotate, sourceId, size, width, height, caption } =
image.props;
- if (!(await this.host.std.collection.blobSync.get(sourceId as string))) {
+ if (!(await this.host.std.workspace.blobSync.get(sourceId as string))) {
return null;
}
return this.crud.addBlock(
@@ -1374,12 +1374,12 @@ export async function prepareClipboardData(
std: BlockStdScope
) {
const job = new Job({
- schema: std.collection.schema,
- blobCRUD: std.collection.blobSync,
+ schema: std.workspace.schema,
+ blobCRUD: std.workspace.blobSync,
docCRUD: {
- create: (id: string) => std.collection.createDoc({ id }),
- get: (id: string) => std.collection.getDoc(id),
- delete: (id: string) => std.collection.removeDoc(id),
+ create: (id: string) => std.workspace.createDoc({ id }),
+ get: (id: string) => std.workspace.getDoc(id),
+ delete: (id: string) => std.workspace.removeDoc(id),
},
});
const selected = await Promise.all(
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.ts
index b05e13fdd4..38b3107086 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
@@ -104,7 +104,7 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {
}
private _initPreviewDoc() {
- this._previewDoc = this._originalDoc.collection.getDoc(
+ this._previewDoc = this._originalDoc.workspace.getDoc(
this._originalDoc.id,
{
query: this._docFilter,
@@ -112,7 +112,7 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {
}
);
this.disposables.add(() => {
- this._originalDoc.blockCollection.clearQuery(this._docFilter);
+ this._originalDoc.doc.clearQuery(this._docFilter);
});
}
diff --git a/blocksuite/blocks/src/root-block/edgeless/services/template-middlewares.ts b/blocksuite/blocks/src/root-block/edgeless/services/template-middlewares.ts
index a12c8644e3..f01add8f99 100644
--- a/blocksuite/blocks/src/root-block/edgeless/services/template-middlewares.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/services/template-middlewares.ts
@@ -20,7 +20,7 @@ export const replaceIdMiddleware = (job: TemplateJob) => {
const { blockJson } = data;
const newId = regeneratedIdMap.has(blockJson.id)
? regeneratedIdMap.get(blockJson.id)!
- : job.model.doc.collection.idGenerator();
+ : job.model.doc.workspace.idGenerator();
if (!regeneratedIdMap.has(blockJson.id)) {
regeneratedIdMap.set(blockJson.id, newId);
@@ -62,7 +62,7 @@ export const replaceIdMiddleware = (job: TemplateJob) => {
});
blockJson.children.forEach(block => {
- regeneratedIdMap.set(block.id, job.model.doc.collection.idGenerator());
+ regeneratedIdMap.set(block.id, job.model.doc.workspace.idGenerator());
});
defered.forEach(id => {
diff --git a/blocksuite/blocks/src/root-block/edgeless/services/template.ts b/blocksuite/blocks/src/root-block/edgeless/services/template.ts
index c39a95a05f..32d94f34db 100644
--- a/blocksuite/blocks/src/root-block/edgeless/services/template.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/services/template.ts
@@ -87,12 +87,12 @@ export class TemplateJob {
constructor({ model, type, middlewares }: TemplateJobConfig) {
this.job = new Job({
- schema: model.doc.collection.schema,
- blobCRUD: model.doc.collection.blobSync,
+ schema: model.doc.workspace.schema,
+ blobCRUD: model.doc.workspace.blobSync,
docCRUD: {
- create: (id: string) => model.doc.collection.createDoc({ id }),
- get: (id: string) => model.doc.collection.getDoc(id),
- delete: (id: string) => model.doc.collection.removeDoc(id),
+ create: (id: string) => model.doc.workspace.createDoc({ id }),
+ get: (id: string) => model.doc.workspace.getDoc(id),
+ delete: (id: string) => model.doc.workspace.removeDoc(id),
},
middlewares: [],
});
@@ -317,7 +317,7 @@ export class TemplateJob {
to: Y.Map<Y.Map<unknown>>
) {
const schema =
- this.model.doc.collection.schema.flavourSchemaMap.get('affine:surface');
+ this.model.doc.workspace.schema.flavourSchemaMap.get('affine:surface');
const surfaceTransformer =
schema?.transformer?.() as SurfaceBlockTransformer;
diff --git a/blocksuite/blocks/src/root-block/edgeless/utils/clone-utils.ts b/blocksuite/blocks/src/root-block/edgeless/utils/clone-utils.ts
index a99c2453c5..c26fbf8806 100644
--- a/blocksuite/blocks/src/root-block/edgeless/utils/clone-utils.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/utils/clone-utils.ts
@@ -40,12 +40,12 @@ export function getSortedCloneElements(elements: GfxModel[]) {
export function prepareCloneData(elements: GfxModel[], std: BlockStdScope) {
elements = sortEdgelessElements(elements);
const job = new Job({
- schema: std.collection.schema,
- blobCRUD: std.collection.blobSync,
+ schema: std.workspace.schema,
+ blobCRUD: std.workspace.blobSync,
docCRUD: {
- create: (id: string) => std.collection.createDoc({ id }),
- get: (id: string) => std.collection.getDoc(id),
- delete: (id: string) => std.collection.removeDoc(id),
+ create: (id: string) => std.workspace.createDoc({ id }),
+ get: (id: string) => std.workspace.getDoc(id),
+ delete: (id: string) => std.workspace.removeDoc(id),
},
});
const res = elements.map(element => {
diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-embed-card-button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-embed-card-button.ts
index 9fe18a7489..15b633d1f8 100644
--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-embed-card-button.ts
+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-embed-card-button.ts
@@ -501,7 +501,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
get _originalDocInfo(): AliasInfo | undefined {
const model = this.model;
const doc = isInternalEmbedModel(model)
- ? this.std.collection.getDoc(model.pageId)
+ ? this.std.workspace.getDoc(model.pageId)
: null;
if (doc) {
@@ -518,7 +518,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
get _originalDocTitle() {
const model = this.model;
const doc = isInternalEmbedModel(model)
- ? this.std.collection.getDoc(model.pageId)
+ ? this.std.workspace.getDoc(model.pageId)
: null;
return doc?.meta?.title || 'Untitled';
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.ts
index 3c59d1bfda..4f68d879bf 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
@@ -40,7 +40,7 @@ export function createLinkedDocFromNote(
note: NoteBlockModel,
docTitle?: string
) {
- const linkedDoc = doc.collection.createDoc({});
+ const linkedDoc = doc.workspace.createDoc({});
linkedDoc.load(() => {
const rootId = linkedDoc.addBlock('affine:page', {
title: new Text(docTitle),
@@ -71,7 +71,7 @@ export function createLinkedDocFromEdgelessElements(
elements: BlockSuite.EdgelessModel[],
docTitle?: string
) {
- const linkedDoc = host.doc.collection.createDoc({});
+ const linkedDoc = host.doc.workspace.createDoc({});
linkedDoc.load(() => {
const rootId = linkedDoc.addBlock('affine:page', {
title: new Text(docTitle),
diff --git a/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts b/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts
index 5acdfc1d95..cc571adc97 100644
--- a/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts
+++ b/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts
@@ -263,7 +263,7 @@ export class EmbedCardToolbar extends WidgetComponent<
if (!model) return undefined;
const doc = isInternalEmbedModel(model)
- ? this.std.collection.getDoc(model.pageId)
+ ? this.std.workspace.getDoc(model.pageId)
: null;
if (doc) {
@@ -282,7 +282,7 @@ export class EmbedCardToolbar extends WidgetComponent<
if (!model) return undefined;
const doc = isInternalEmbedModel(model)
- ? this.std.collection.getDoc(model.pageId)
+ ? this.std.workspace.getDoc(model.pageId)
: null;
return doc?.meta?.title || 'Untitled';
diff --git a/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts b/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts
index e927f0b0d3..a1b15a7838 100644
--- a/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts
+++ b/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts
@@ -275,7 +275,7 @@ const pageToolGroup: KeyboardToolPanelGroup = {
.chain()
.getSelectedModels()
.inline(({ selectedModels }) => {
- const newDoc = createDefaultDoc(std.doc.collection);
+ const newDoc = createDefaultDoc(std.doc.workspace);
if (!selectedModels?.length) return;
insertContent(std.host, selectedModels[0], REFERENCE_NODE, {
reference: {
diff --git a/blocksuite/blocks/src/root-block/widgets/linked-doc/config.ts b/blocksuite/blocks/src/root-block/widgets/linked-doc/config.ts
index 62cec4c734..ce98328ca3 100644
--- a/blocksuite/blocks/src/root-block/widgets/linked-doc/config.ts
+++ b/blocksuite/blocks/src/root-block/widgets/linked-doc/config.ts
@@ -105,7 +105,7 @@ export function createLinkedDocMenuGroup(
inlineEditor: AffineInlineEditor
) {
const doc = editorHost.doc;
- const { docMetas } = doc.collection.meta;
+ const { docMetas } = doc.workspace.meta;
const filteredDocList = docMetas
.filter(({ id }) => id !== doc.id)
.filter(({ title }) => isFuzzyMatch(title, query));
@@ -164,7 +164,7 @@ export function createNewDocMenuGroup(
action: () => {
abort();
const docName = query;
- const newDoc = createDefaultDoc(doc.collection, {
+ const newDoc = createDefaultDoc(doc.workspace, {
title: docName,
});
insertLinkedNode({
@@ -213,7 +213,7 @@ export function createNewDocMenuGroup(
toast(editorHost, message);
};
showImportModal({
- collection: doc.collection,
+ collection: doc.workspace,
onSuccess,
onFail,
});
diff --git a/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts b/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts
index 84499fb5c4..36f7f1fc40 100644
--- a/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts
+++ b/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts
@@ -194,7 +194,7 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
showWhen: ({ model }) =>
model.doc.schema.flavourSchemaMap.has('affine:embed-linked-doc'),
action: ({ rootComponent, model }) => {
- const newDoc = createDefaultDoc(rootComponent.doc.collection);
+ const newDoc = createDefaultDoc(rootComponent.doc.workspace);
insertContent(rootComponent.host, model, REFERENCE_NODE, {
reference: {
type: 'LinkedPage',
diff --git a/blocksuite/framework/block-std/src/clipboard/index.ts b/blocksuite/framework/block-std/src/clipboard/index.ts
index b03e1c379c..f86799e2f1 100644
--- a/blocksuite/framework/block-std/src/clipboard/index.ts
+++ b/blocksuite/framework/block-std/src/clipboard/index.ts
@@ -138,7 +138,7 @@ export class Clipboard extends LifeCycleWatcher {
const payload = {
file: item,
assets: job.assetsManager,
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
pageId: doc.id,
};
const result = await adapterInstance.toSlice(
diff --git a/blocksuite/framework/block-std/src/extension/service.ts b/blocksuite/framework/block-std/src/extension/service.ts
index 76786792d6..2bf6aea26c 100644
--- a/blocksuite/framework/block-std/src/extension/service.ts
+++ b/blocksuite/framework/block-std/src/extension/service.ts
@@ -30,7 +30,7 @@ export abstract class BlockService extends Extension {
readonly specSlots = getSlots();
get collection() {
- return this.std.collection;
+ return this.std.workspace;
}
get doc() {
diff --git a/blocksuite/framework/block-std/src/scope/block-std-scope.ts b/blocksuite/framework/block-std/src/scope/block-std-scope.ts
index 34d2e02f1c..6a2bcae6f5 100644
--- a/blocksuite/framework/block-std/src/scope/block-std-scope.ts
+++ b/blocksuite/framework/block-std/src/scope/block-std-scope.ts
@@ -74,8 +74,8 @@ export class BlockStdScope {
return this.get(Clipboard);
}
- get collection() {
- return this.doc.collection;
+ get workspace() {
+ return this.doc.workspace;
}
get command() {
@@ -170,12 +170,12 @@ export class BlockStdScope {
getJob(middlewares: JobMiddleware[] = []) {
return new Job({
- schema: this.collection.schema,
- blobCRUD: this.collection.blobSync,
+ schema: this.workspace.schema,
+ blobCRUD: this.workspace.blobSync,
docCRUD: {
- create: (id: string) => this.collection.createDoc({ id }),
- get: (id: string) => this.collection.getDoc(id),
- delete: (id: string) => this.collection.removeDoc(id),
+ create: (id: string) => this.workspace.createDoc({ id }),
+ get: (id: string) => this.workspace.getDoc(id),
+ delete: (id: string) => this.workspace.removeDoc(id),
},
middlewares,
});
diff --git a/blocksuite/framework/block-std/src/selection/manager.ts b/blocksuite/framework/block-std/src/selection/manager.ts
index 64edb93c10..be66a5c0dd 100644
--- a/blocksuite/framework/block-std/src/selection/manager.ts
+++ b/blocksuite/framework/block-std/src/selection/manager.ts
@@ -58,7 +58,7 @@ export class SelectionManager extends LifeCycleWatcher {
};
private get _store() {
- return this.std.collection.awarenessStore;
+ return this.std.workspace.awarenessStore;
}
get id() {
diff --git a/blocksuite/framework/store/src/store/doc/doc.ts b/blocksuite/framework/store/src/store/doc/doc.ts
index d3a0c02a25..340d73c956 100644
--- a/blocksuite/framework/store/src/store/doc/doc.ts
+++ b/blocksuite/framework/store/src/store/doc/doc.ts
@@ -23,7 +23,7 @@ export class Blocks {
runQuery(this._query, block);
};
- protected readonly _blockCollection: Doc;
+ protected readonly _doc: Doc;
protected readonly _blocks = signal<Record<string, Block>>({});
@@ -136,19 +136,19 @@ export class Blocks {
};
private get _yBlocks() {
- return this._blockCollection.yBlocks;
+ return this._doc.yBlocks;
}
get awarenessStore() {
- return this._blockCollection.awarenessStore;
+ return this._doc.awarenessStore;
}
get blobSync() {
- return this.collection.blobSync;
+ return this.workspace.blobSync;
}
- get blockCollection() {
- return this._blockCollection;
+ get doc() {
+ return this._doc;
}
get blocks() {
@@ -160,31 +160,31 @@ export class Blocks {
}
get canRedo() {
- return this._blockCollection.canRedo;
+ return this._doc.canRedo;
}
get canUndo() {
- return this._blockCollection.canUndo;
+ return this._doc.canUndo;
}
get captureSync() {
- return this._blockCollection.captureSync.bind(this._blockCollection);
+ return this._doc.captureSync.bind(this._doc);
}
get clear() {
- return this._blockCollection.clear.bind(this._blockCollection);
+ return this._doc.clear.bind(this._doc);
}
- get collection() {
- return this._blockCollection.collection;
+ get workspace() {
+ return this._doc.workspace;
}
get history() {
- return this._blockCollection.history;
+ return this._doc.history;
}
get id() {
- return this._blockCollection.id;
+ return this._doc.id;
}
get isEmpty() {
@@ -192,40 +192,37 @@ export class Blocks {
}
get loaded() {
- return this._blockCollection.loaded;
+ return this._doc.loaded;
}
get meta() {
- return this._blockCollection.meta;
+ return this._doc.meta;
}
get readonly() {
- if (this._blockCollection.readonly) {
+ if (this._doc.readonly) {
return true;
}
return this._readonly === true;
}
set readonly(value: boolean) {
- this._blockCollection.awarenessStore.setReadonly(
- this._blockCollection,
- value
- );
+ this._doc.awarenessStore.setReadonly(this._doc, value);
if (this._readonly !== undefined && this._readonly !== value) {
this._readonly = value;
}
}
get ready() {
- return this._blockCollection.ready;
+ return this._doc.ready;
}
get redo() {
- return this._blockCollection.redo.bind(this._blockCollection);
+ return this._doc.redo.bind(this._doc);
}
get resetHistory() {
- return this._blockCollection.resetHistory.bind(this._blockCollection);
+ return this._doc.resetHistory.bind(this._doc);
}
get root() {
@@ -235,7 +232,7 @@ export class Blocks {
}
get rootDoc() {
- return this._blockCollection.rootDoc;
+ return this._doc.rootDoc;
}
get schema() {
@@ -243,31 +240,31 @@ export class Blocks {
}
get spaceDoc() {
- return this._blockCollection.spaceDoc;
+ return this._doc.spaceDoc;
}
get transact() {
- return this._blockCollection.transact.bind(this._blockCollection);
+ return this._doc.transact.bind(this._doc);
}
get undo() {
- return this._blockCollection.undo.bind(this._blockCollection);
+ return this._doc.undo.bind(this._doc);
}
get withoutTransact() {
- return this._blockCollection.withoutTransact.bind(this._blockCollection);
+ return this._doc.withoutTransact.bind(this._doc);
}
constructor({ schema, blockCollection, readonly, query }: DocOptions) {
- this._blockCollection = blockCollection;
+ this._doc = blockCollection;
this.slots = {
ready: new Slot(),
rootAdded: new Slot(),
rootDeleted: new Slot(),
blockUpdated: new Slot(),
- historyUpdated: this._blockCollection.slots.historyUpdated,
- yBlockUpdated: this._blockCollection.slots.yBlockUpdated,
+ historyUpdated: this._doc.slots.historyUpdated,
+ yBlockUpdated: this._doc.slots.yBlockUpdated,
};
this._crud = new DocCRUD(this._yBlocks, blockCollection.schema);
@@ -284,7 +281,7 @@ export class Blocks {
this._onBlockAdded(id, true);
});
- this._disposeBlockUpdated = this._blockCollection.slots.yBlockUpdated.on(
+ this._disposeBlockUpdated = this._doc.slots.yBlockUpdated.on(
({ type, id }) => {
switch (type) {
case 'add': {
@@ -424,7 +421,7 @@ export class Blocks {
);
}
- const id = blockProps.id ?? this._blockCollection.collection.idGenerator();
+ const id = blockProps.id ?? this._doc.workspace.idGenerator();
this.transact(() => {
this._crud.addBlock(
@@ -635,7 +632,7 @@ export class Blocks {
}
load(initFn?: () => void) {
- this._blockCollection.load(initFn);
+ this._doc.load(initFn);
this.slots.ready.emit();
return this;
}
diff --git a/blocksuite/framework/store/src/store/workspace.ts b/blocksuite/framework/store/src/store/workspace.ts
index 209f31d7d3..0bbfc82a12 100644
--- a/blocksuite/framework/store/src/store/workspace.ts
+++ b/blocksuite/framework/store/src/store/workspace.ts
@@ -30,17 +30,18 @@ export interface DocMeta {
favorite?: boolean;
}
-export type GetDocOptions = {
+export type GetBlocksOptions = {
query?: Query;
readonly?: boolean;
};
-export type CreateDocOptions = GetDocOptions & {
+export type CreateBlocksOptions = GetBlocksOptions & {
id?: string;
};
export interface WorkspaceMeta {
get docMetas(): DocMeta[];
+ addDocMeta(props: DocMeta, index?: number): void;
getDocMeta(id: string): DocMeta | undefined;
setDocMeta(id: string, props: Partial<DocMeta>): void;
removeDocMeta(id: string): void;
@@ -60,6 +61,10 @@ export interface WorkspaceMeta {
writeVersion(workspace: Workspace): void;
get docs(): unknown[] | undefined;
initialize(): void;
+
+ docMetaAdded: Slot<string>;
+ docMetaRemoved: Slot<string>;
+ docMetaUpdated: Slot;
}
export interface Workspace {
@@ -80,8 +85,8 @@ export interface Workspace {
docRemoved: Slot<string>;
};
- createDoc(options?: CreateDocOptions): Blocks;
- getDoc(docId: string, options?: GetDocOptions): Blocks | null;
+ createDoc(options?: CreateBlocksOptions): Blocks;
+ getDoc(docId: string, options?: GetBlocksOptions): Blocks | null;
removeDoc(docId: string): void;
dispose(): void;
@@ -111,6 +116,7 @@ export interface Doc {
>;
};
+ get history(): Y.UndoManager;
get canRedo(): boolean;
get canUndo(): boolean;
undo(): void;
@@ -121,15 +127,14 @@ export interface Doc {
captureSync(): void;
clear(): void;
- getDoc(options?: GetDocOptions): Blocks;
+ getBlocks(options?: GetBlocksOptions): Blocks;
clearQuery(query: Query, readonly?: boolean): void;
- get history(): Y.UndoManager;
get loaded(): boolean;
get readonly(): boolean;
get awarenessStore(): AwarenessStore;
- get collection(): Workspace;
+ get workspace(): Workspace;
get rootDoc(): BlockSuiteDoc;
get spaceDoc(): Y.Doc;
diff --git a/blocksuite/framework/store/src/test/test-doc.ts b/blocksuite/framework/store/src/test/test-doc.ts
index cc45e05242..18bd1c68a9 100644
--- a/blocksuite/framework/store/src/test/test-doc.ts
+++ b/blocksuite/framework/store/src/test/test-doc.ts
@@ -5,7 +5,7 @@ import * as Y from 'yjs';
import { Blocks } from '../store/doc/doc.js';
import type { YBlock } from '../store/doc/index.js';
import type { Query } from '../store/doc/query.js';
-import type { Doc, GetDocOptions, Workspace } from '../store/workspace.js';
+import type { Doc, GetBlocksOptions, Workspace } from '../store/workspace.js';
import type { AwarenessStore, BlockSuiteDoc } from '../yjs/index.js';
type DocOptions = {
@@ -124,7 +124,7 @@ export class TestDoc implements Doc {
};
get blobSync() {
- return this.collection.blobSync;
+ return this.workspace.blobSync;
}
get canRedo() {
@@ -143,12 +143,12 @@ export class TestDoc implements Doc {
return this._canUndo$;
}
- get collection() {
+ get workspace() {
return this._collection;
}
get docSync() {
- return this.collection.docSync;
+ return this.workspace.docSync;
}
get history() {
@@ -164,7 +164,7 @@ export class TestDoc implements Doc {
}
get meta() {
- return this.collection.meta.getDocMeta(this.id);
+ return this.workspace.meta.getDocMeta(this.id);
}
get readonly(): boolean {
@@ -176,7 +176,7 @@ export class TestDoc implements Doc {
}
get schema() {
- return this.collection.schema;
+ return this.workspace.schema;
}
get spaceDoc() {
@@ -204,8 +204,8 @@ export class TestDoc implements Doc {
private _handleVersion() {
// Initialization from empty yDoc, indicating that the document is new.
- if (!this.collection.meta.hasVersion) {
- this.collection.meta.writeVersion(this.collection);
+ if (!this.workspace.meta.hasVersion) {
+ this.workspace.meta.writeVersion(this.workspace);
}
}
@@ -283,7 +283,7 @@ export class TestDoc implements Doc {
}
}
- getDoc({ readonly, query }: GetDocOptions = {}) {
+ getBlocks({ readonly, query }: GetBlocksOptions = {}) {
const readonlyKey = this._getReadonlyKey(readonly);
const key = JSON.stringify(query);
@@ -294,7 +294,7 @@ export class TestDoc implements Doc {
const doc = new Blocks({
blockCollection: this,
- schema: this.collection.schema,
+ schema: this.workspace.schema,
readonly,
query,
});
@@ -311,7 +311,7 @@ export class TestDoc implements Doc {
this._ySpaceDoc.load();
- if ((this.collection.meta.docs?.length ?? 0) <= 1) {
+ if ((this.workspace.meta.docs?.length ?? 0) <= 1) {
this._handleVersion();
}
diff --git a/blocksuite/framework/store/src/test/test-workspace.ts b/blocksuite/framework/store/src/test/test-workspace.ts
index 47a91a9e7a..83ac564ae3 100644
--- a/blocksuite/framework/store/src/test/test-workspace.ts
+++ b/blocksuite/framework/store/src/test/test-workspace.ts
@@ -18,10 +18,11 @@ import { Awareness } from 'y-protocols/awareness.js';
import type { Schema } from '../schema/index.js';
import {
type Blocks,
- type CreateDocOptions,
+ type CreateBlocksOptions,
DocCollectionMeta,
- type GetDocOptions,
+ type GetBlocksOptions,
type Workspace,
+ type WorkspaceMeta,
} from '../store/index.js';
import { type IdGenerator, nanoid } from '../utils/id-generator.js';
import {
@@ -90,7 +91,7 @@ export class TestWorkspace implements Workspace {
readonly idGenerator: IdGenerator;
- meta: DocCollectionMeta;
+ meta: WorkspaceMeta;
slots = {
docListUpdated: new Slot(),
@@ -191,7 +192,7 @@ export class TestWorkspace implements Workspace {
* If the `init` parameter is passed, a `surface`, `note`, and `paragraph` block
* will be created in the doc simultaneously.
*/
- createDoc(options: CreateDocOptions = {}) {
+ createDoc(options: CreateBlocksOptions = {}) {
const { id: docId = this.idGenerator(), query, readonly } = options;
if (this._hasDoc(docId)) {
throw new BlockSuiteError(
@@ -229,9 +230,9 @@ export class TestWorkspace implements Workspace {
return space ?? null;
}
- getDoc(docId: string, options?: GetDocOptions): Blocks | null {
+ getDoc(docId: string, options?: GetBlocksOptions): Blocks | null {
const collection = this.getBlockCollection(docId);
- return collection?.getDoc(options) ?? null;
+ return collection?.getBlocks(options) ?? null;
}
removeDoc(docId: string) {
diff --git a/blocksuite/framework/store/src/transformer/slice.ts b/blocksuite/framework/store/src/transformer/slice.ts
index b3889a8bb6..d205485380 100644
--- a/blocksuite/framework/store/src/transformer/slice.ts
+++ b/blocksuite/framework/store/src/transformer/slice.ts
@@ -25,7 +25,7 @@ export class Slice {
static fromModels(doc: Blocks, models: DraftModel[]) {
return new Slice({
content: models,
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
pageId: doc.id,
});
}
diff --git a/blocksuite/playground/apps/_common/components/docs-panel.ts b/blocksuite/playground/apps/_common/components/docs-panel.ts
index 4a9c290e02..531ccc48cb 100644
--- a/blocksuite/playground/apps/_common/components/docs-panel.ts
+++ b/blocksuite/playground/apps/_common/components/docs-panel.ts
@@ -6,7 +6,7 @@ import {
} from '@blocksuite/blocks';
import { WithDisposable } from '@blocksuite/global/utils';
import type { AffineEditorContainer } from '@blocksuite/presets';
-import type { BlockCollection, DocCollection } from '@blocksuite/store';
+import type { Doc, Workspace } from '@blocksuite/store';
import { css, html, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
@@ -64,23 +64,23 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
`;
createDoc = () => {
- createDocBlock(this.editor.doc.collection);
+ createDocBlock(this.editor.doc.workspace);
};
- gotoDoc = (doc: BlockCollection) => {
+ gotoDoc = (doc: Doc) => {
const url = this.editor.std
.getOptional(GenerateDocUrlProvider)
?.generateDocUrl(doc.id);
if (url) history.pushState({}, '', url);
- this.editor.doc = doc.getDoc();
+ this.editor.doc = doc.getBlocks();
this.editor.doc.load();
this.editor.doc.resetHistory();
this.requestUpdate();
};
private get collection() {
- return this.editor.doc.collection;
+ return this.editor.doc.workspace;
}
private get docs() {
@@ -110,7 +110,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
});
this.disposables.add(
- this.editor.doc.collection.slots.docListUpdated.on(() => {
+ this.editor.doc.workspace.slots.docListUpdated.on(() => {
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 doc
if (isDeleteCurrent) {
- this.editor.doc = this.docs[0].getDoc();
+ this.editor.doc = this.docs[0].getBlocks();
}
};
return html`<div class="doc-item" @click="${click}" style="${style}">
@@ -169,7 +169,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
accessor onClose!: () => void;
}
-function createDocBlock(collection: DocCollection) {
+function createDocBlock(collection: Workspace) {
const id = collection.idGenerator();
createDefaultDoc(collection, { id });
}
diff --git a/blocksuite/playground/apps/_common/history.ts b/blocksuite/playground/apps/_common/history.ts
index f25b1206b6..83947fe826 100644
--- a/blocksuite/playground/apps/_common/history.ts
+++ b/blocksuite/playground/apps/_common/history.ts
@@ -1,11 +1,11 @@
import type { DocModeProvider } from '@blocksuite/blocks';
import { assertExists } from '@blocksuite/global/utils';
import type { AffineEditorContainer } from '@blocksuite/presets';
-import type { BlockCollection, Doc, DocCollection } from '@blocksuite/store';
+import type { Blocks, Doc, Workspace } from '@blocksuite/store';
import type { LitElement } from 'lit';
-export function getDocFromUrlParams(collection: DocCollection, url: URL) {
- let doc: Doc | null = null;
+export function getDocFromUrlParams(collection: Workspace, url: URL) {
+ let doc: Blocks | null = null;
const docId = decodeURIComponent(url.hash.slice(1));
@@ -13,10 +13,9 @@ export function getDocFromUrlParams(collection: DocCollection, url: URL) {
doc = collection.getDoc(docId);
}
if (!doc) {
- const blockCollection = collection.docs.values().next()
- .value as BlockCollection;
+ const blockCollection = collection.docs.values().next().value as Doc;
assertExists(blockCollection, 'Need to create a doc first');
- doc = blockCollection.getDoc();
+ doc = blockCollection.getBlocks();
}
doc.load();
@@ -41,7 +40,7 @@ export function setDocModeFromUrlParams(
}
export function listenHashChange(
- collection: DocCollection,
+ collection: Workspace,
editor: AffineEditorContainer,
panel?: LitElement
) {
diff --git a/blocksuite/playground/apps/default/utils/editor.ts b/blocksuite/playground/apps/default/utils/editor.ts
index edd1a20323..8f91943d18 100644
--- a/blocksuite/playground/apps/default/utils/editor.ts
+++ b/blocksuite/playground/apps/default/utils/editor.ts
@@ -14,7 +14,7 @@ import {
SpecProvider,
} from '@blocksuite/blocks';
import { AffineEditorContainer } from '@blocksuite/presets';
-import type { DocCollection } from '@blocksuite/store';
+import type { Workspace } from '@blocksuite/store';
import { AttachmentViewerPanel } from '../../_common/components/attachment-viewer-panel.js';
import { CollabDebugMenu } from '../../_common/components/collab-debug-menu.js';
@@ -36,7 +36,7 @@ import {
} from '../../_common/mock-services.js';
import { getExampleSpecs } from '../specs-examples/index.js';
-export async function mountDefaultDocEditor(collection: DocCollection) {
+export async function mountDefaultDocEditor(collection: Workspace) {
const app = document.getElementById('app');
if (!app) return;
diff --git a/blocksuite/playground/apps/env.d.ts b/blocksuite/playground/apps/env.d.ts
index e7b01efa55..5b9296f7b6 100644
--- a/blocksuite/playground/apps/env.d.ts
+++ b/blocksuite/playground/apps/env.d.ts
@@ -1,7 +1,7 @@
import type { EditorHost } from '@blocksuite/block-std';
import type { TestUtils } from '@blocksuite/blocks';
import type { AffineEditorContainer } from '@blocksuite/presets';
-import type { BlockSchema, Doc, DocCollection, Job } from '@blocksuite/store';
+import type { BlockSchema, Blocks, Workspace, Job } from '@blocksuite/store';
import type { z } from 'zod';
import type * as Y from 'yjs';
@@ -14,8 +14,8 @@ declare global {
interface Window {
editor: AffineEditorContainer;
- doc: Doc;
- collection: DocCollection;
+ doc: Blocks;
+ collection: Workspace;
blockSchemas: z.infer<typeof BlockSchema>[];
job: Job;
Y: typeof Y;
diff --git a/blocksuite/presets/src/__tests__/main/snapshot.spec.ts b/blocksuite/presets/src/__tests__/main/snapshot.spec.ts
index f2eeeb5598..2991a6a00d 100644
--- a/blocksuite/presets/src/__tests__/main/snapshot.spec.ts
+++ b/blocksuite/presets/src/__tests__/main/snapshot.spec.ts
@@ -37,7 +37,7 @@ const snapshotTest = async (snapshotUrl: string, elementsCount: number) => {
throw e;
});
const [newDoc] = await transformer.importDocs(
- window.editor.doc.collection,
+ window.editor.doc.workspace,
snapshotFile
);
diff --git a/blocksuite/presets/src/__tests__/utils/setup.ts b/blocksuite/presets/src/__tests__/utils/setup.ts
index 104dfd5ef1..81add31fc4 100644
--- a/blocksuite/presets/src/__tests__/utils/setup.ts
+++ b/blocksuite/presets/src/__tests__/utils/setup.ts
@@ -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.getDoc();
+ const doc = blockCollection.getBlocks();
const editor = new AffineEditorContainer();
editor.doc = doc;
editor.mode = mode;
diff --git a/blocksuite/presets/src/fragments/comment/comment-manager.ts b/blocksuite/presets/src/fragments/comment/comment-manager.ts
index 3c53565d97..907ce10d14 100644
--- a/blocksuite/presets/src/fragments/comment/comment-manager.ts
+++ b/blocksuite/presets/src/fragments/comment/comment-manager.ts
@@ -44,7 +44,7 @@ export class CommentManager {
}
const { quote, range } = parseResult;
- const id = this.host.doc.collection.idGenerator();
+ const id = this.host.doc.workspace.idGenerator();
const comment: Comment = {
id,
date: Date.now(),
diff --git a/blocksuite/presets/src/fragments/doc-title/doc-title.ts b/blocksuite/presets/src/fragments/doc-title/doc-title.ts
index c5114ad43c..dff9720442 100644
--- a/blocksuite/presets/src/fragments/doc-title/doc-title.ts
+++ b/blocksuite/presets/src/fragments/doc-title/doc-title.ts
@@ -84,7 +84,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {
};
private readonly _updateTitleInMeta = () => {
- this.doc.collection.meta.setDocMeta(this.doc.id, {
+ this.doc.workspace.meta.setDocMeta(this.doc.id, {
title: this._rootModel.title.toString(),
});
};
diff --git a/blocksuite/presets/src/fragments/outline/card/outline-preview.ts b/blocksuite/presets/src/fragments/outline/card/outline-preview.ts
index 6a0a506e7a..88cd799bdc 100644
--- a/blocksuite/presets/src/fragments/outline/card/outline-preview.ts
+++ b/blocksuite/presets/src/fragments/outline/card/outline-preview.ts
@@ -170,7 +170,7 @@ export class OutlineBlockPreview extends SignalWatcher(
if (delta.attributes?.reference) {
// If linked doc, render linked doc icon and the doc title.
const refAttribute = delta.attributes.reference;
- const refMeta = block.doc.collection.meta.docMetas.find(
+ const refMeta = block.doc.workspace.meta.docMetas.find(
doc => doc.id === refAttribute.pageId
);
const unavailable = !refMeta;
diff --git a/blocksuite/tests-legacy/embed-synced-doc.spec.ts b/blocksuite/tests-legacy/embed-synced-doc.spec.ts
index 547fe0382c..f615117b09 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!.getDoc();
+ const doc2 = doc2Collection!.getBlocks();
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.ts
index cd8f001d1f..a268033cd8 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?.getDoc() as
+ const firstDoc = collection.docs.values().next().value?.getBlocks() as
| ReturnType<typeof collection.createDoc>
| undefined;
if (firstDoc) {
diff --git a/packages/frontend/apps/ios/src/app.tsx b/packages/frontend/apps/ios/src/app.tsx
index a89c1c265c..90ba46a01e 100644
--- a/packages/frontend/apps/ios/src/app.tsx
+++ b/packages/frontend/apps/ios/src/app.tsx
@@ -174,16 +174,16 @@ const frameworkProvider = framework.provider();
const blockSuiteDoc = doc.blockSuiteDoc;
const job = new Job({
- schema: blockSuiteDoc.collection.schema,
- blobCRUD: blockSuiteDoc.collection.blobSync,
+ schema: blockSuiteDoc.workspace.schema,
+ blobCRUD: blockSuiteDoc.workspace.blobSync,
docCRUD: {
- create: (id: string) => blockSuiteDoc.collection.createDoc({ id }),
- get: (id: string) => blockSuiteDoc.collection.getDoc(id),
- delete: (id: string) => blockSuiteDoc.collection.removeDoc(id),
+ create: (id: string) => blockSuiteDoc.workspace.createDoc({ id }),
+ get: (id: string) => blockSuiteDoc.workspace.getDoc(id),
+ delete: (id: string) => blockSuiteDoc.workspace.removeDoc(id),
},
middlewares: [
- docLinkBaseURLMiddleware(blockSuiteDoc.collection.id),
- titleMiddleware(blockSuiteDoc.collection.meta.docMetas),
+ docLinkBaseURLMiddleware(blockSuiteDoc.workspace.id),
+ titleMiddleware(blockSuiteDoc.workspace.meta.docMetas),
],
});
const snapshot = job.docToSnapshot(blockSuiteDoc);
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.ts
index 3d3ab28eea..bb3503a7f0 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
@@ -195,7 +195,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
if (this._answers.length > 0) {
const latestAnswer = this._answers.pop();
this._answers = [];
- const schema = this.schema ?? this.host?.std.doc.collection.schema;
+ const schema = this.schema ?? this.host?.std.doc.workspace.schema;
let provider: ServiceProvider;
if (this.host) {
provider = this.host.std.provider;
@@ -220,11 +220,11 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
)
.then(doc => {
this.disposeDoc();
- this._doc = doc.blockCollection.getDoc({
+ this._doc = doc.doc.getBlocks({
query: this._query,
});
this.disposables.add(() => {
- doc.blockCollection.clearQuery(this._query);
+ doc.doc.clearQuery(this._query);
});
this._doc.readonly = true;
this.requestUpdate();
@@ -256,7 +256,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
private disposeDoc() {
this._doc?.dispose();
- this._doc?.collection.dispose();
+ this._doc?.workspace.dispose();
}
override disconnectedCallback() {
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.ts
index df01db3bd1..678dbbddf3 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
@@ -1,4 +1,4 @@
-import { WorkspaceImpl } from '@affine/core/modules/workspace/impl/workspace';
+import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace';
import type {
EditorHost,
TextRangePoint,
@@ -80,15 +80,15 @@ export async function getContentFromSlice(
type: 'markdown' | 'plain-text' = 'markdown'
) {
const job = new Job({
- schema: host.std.doc.collection.schema,
- blobCRUD: host.std.doc.collection.blobSync,
+ schema: host.std.doc.workspace.schema,
+ blobCRUD: host.std.doc.workspace.blobSync,
docCRUD: {
- create: (id: string) => host.std.doc.collection.createDoc({ id }),
- get: (id: string) => host.std.doc.collection.getDoc(id),
- delete: (id: string) => host.std.doc.collection.removeDoc(id),
+ create: (id: string) => host.std.doc.workspace.createDoc({ id }),
+ get: (id: string) => host.std.doc.workspace.getDoc(id),
+ delete: (id: string) => host.std.doc.workspace.removeDoc(id),
},
middlewares: [
- titleMiddleware(host.std.doc.collection.meta.docMetas),
+ titleMiddleware(host.std.doc.workspace.meta.docMetas),
embedSyncedDocMiddleware('content'),
],
});
@@ -110,14 +110,14 @@ export async function getContentFromSlice(
export async function getPlainTextFromSlice(host: EditorHost, slice: Slice) {
const job = new Job({
- schema: host.std.doc.collection.schema,
- blobCRUD: host.std.doc.collection.blobSync,
+ schema: host.std.doc.workspace.schema,
+ blobCRUD: host.std.doc.workspace.blobSync,
docCRUD: {
- create: (id: string) => host.std.doc.collection.createDoc({ id }),
- get: (id: string) => host.std.doc.collection.getDoc(id),
- delete: (id: string) => host.std.doc.collection.removeDoc(id),
+ create: (id: string) => host.std.doc.workspace.createDoc({ id }),
+ get: (id: string) => host.std.doc.workspace.getDoc(id),
+ delete: (id: string) => host.std.doc.workspace.removeDoc(id),
},
- middlewares: [titleMiddleware(host.std.doc.collection.meta.docMetas)],
+ middlewares: [titleMiddleware(host.std.doc.workspace.meta.docMetas)],
});
const snapshot = job.sliceToSnapshot(slice);
if (!snapshot) {
@@ -137,12 +137,12 @@ export const markdownToSnapshot = async (
host: EditorHost
) => {
const job = new Job({
- schema: host.std.doc.collection.schema,
- blobCRUD: host.std.doc.collection.blobSync,
+ schema: host.std.doc.workspace.schema,
+ blobCRUD: host.std.doc.workspace.blobSync,
docCRUD: {
- create: (id: string) => host.std.doc.collection.createDoc({ id }),
- get: (id: string) => host.std.doc.collection.getDoc(id),
- delete: (id: string) => host.std.doc.collection.removeDoc(id),
+ create: (id: string) => host.std.doc.workspace.createDoc({ id }),
+ get: (id: string) => host.std.doc.workspace.getDoc(id),
+ delete: (id: string) => host.std.doc.workspace.removeDoc(id),
},
middlewares: [defaultImageProxyMiddleware, pasteMiddleware(host.std)],
});
@@ -150,7 +150,7 @@ export const markdownToSnapshot = async (
const payload = {
file: markdown,
assets: job.assetsManager,
- workspaceId: host.std.doc.collection.id,
+ workspaceId: host.std.doc.workspace.id,
pageId: host.std.doc.id,
};
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.ts
index 38e13e5471..bc53ffed29 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
@@ -107,7 +107,7 @@ export async function constructRootChatBlockMessages(
// Convert chat messages to AI chat block messages
const userInfo = await AIProvider.userInfo;
const forkMessages = await queryHistoryMessages(
- doc.collection.id,
+ doc.workspace.id,
doc.id,
forkSessionId
);
@@ -171,7 +171,7 @@ function addAIChatBlock(
messages: JSON.stringify(messages),
index,
sessionId,
- rootWorkspaceId: doc.collection.id,
+ rootWorkspaceId: doc.workspace.id,
rootDocId: doc.id,
},
surfaceBlock.id
@@ -330,7 +330,7 @@ const SAVE_CHAT_TO_BLOCK_ACTION: ChatAction = {
try {
const newSessionId = await AIProvider.forkChat?.({
- workspaceId: host.doc.collection.id,
+ workspaceId: host.doc.workspace.id,
docId: host.doc.id,
sessionId: parentSessionId,
latestMessageId: messageId,
@@ -425,7 +425,7 @@ const CREATE_AS_DOC = {
toast: 'New doc created',
handler: (host: EditorHost, content: string) => {
reportResponse('result:add-page');
- const newDoc = host.doc.collection.createDoc();
+ const newDoc = host.doc.workspace.createDoc();
newDoc.load();
const rootId = newDoc.addBlock('affine:page');
newDoc.addBlock('affine:surface', {}, rootId);
@@ -479,7 +479,7 @@ const CREATE_AS_LINKED_DOC = {
}
// Create a new doc and add the content to it
- const newDoc = host.doc.collection.createDoc();
+ const newDoc = host.doc.workspace.createDoc();
newDoc.load();
const rootId = newDoc.addBlock('affine:page');
newDoc.addBlock('affine:surface', {}, rootId);
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/doc-handler.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/doc-handler.ts
index 14f38ecb7e..8560053d26 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/actions/doc-handler.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/doc-handler.ts
@@ -107,7 +107,7 @@ export function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
control,
where,
docId: host.doc.id,
- workspaceId: host.doc.collection.id,
+ workspaceId: host.doc.workspace.id,
} as Parameters<typeof action>[0];
// @ts-expect-error TODO(@Peng): maybe fix this
stream = action(options);
@@ -238,7 +238,7 @@ export function handleInlineAskAIAction(host: EditorHost) {
where: 'inline-chat-panel',
control: 'chat-send',
docId: host.doc.id,
- workspaceId: host.doc.collection.id,
+ workspaceId: host.doc.workspace.id,
});
bindTextStream(stream, { update, finish, signal });
})
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts
index 2ccce8790a..b473e292b6 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts
@@ -189,7 +189,7 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
models,
host,
docId: host.doc.id,
- workspaceId: host.doc.collection.id,
+ workspaceId: host.doc.workspace.id,
} as Parameters<typeof action>[0];
const content = ctx.get().content;
@@ -230,7 +230,7 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
control: 'format-bar',
host,
docId: host.doc.id,
- workspaceId: host.doc.collection.id,
+ workspaceId: host.doc.workspace.id,
} as Parameters<typeof action>[0];
// @ts-expect-error TODO(@Peng): maybe fix this
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts
index 72573cd68e..7a80e414bb 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts
@@ -488,7 +488,7 @@ export class ChatPanelInput extends WithDisposable(LitElement) {
input: content,
docId: doc.id,
attachments: images,
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
host: this.host,
stream: true,
signal: abortController.signal,
@@ -519,7 +519,7 @@ export class ChatPanelInput extends WithDisposable(LitElement) {
const last = items[items.length - 1] as ChatMessage;
if (!last.id) {
const historyIds = await AIProvider.histories?.ids(
- doc.collection.id,
+ doc.workspace.id,
doc.id,
{ sessionId: this.chatContextValue.chatSessionId }
);
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-messages.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-messages.ts
index 8339650e4c..1c2e62bf30 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-messages.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-messages.ts
@@ -426,7 +426,7 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
sessionId: chatSessionId,
retry: true,
docId: doc.id,
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
host: this.host,
stream: true,
signal: abortController.signal,
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.ts
index a4943a1fa2..d64b752f53 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
@@ -107,8 +107,8 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
const { doc } = this;
const [histories, actions] = await Promise.all([
- AIProvider.histories?.chats(doc.collection.id, doc.id, { fork: false }),
- AIProvider.histories?.actions(doc.collection.id, doc.id),
+ AIProvider.histories?.chats(doc.workspace.id, doc.id, { fork: false }),
+ AIProvider.histories?.actions(doc.workspace.id, doc.id),
]);
if (counter !== this._resettingCounter) return;
@@ -175,7 +175,7 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
cancelText: 'Cancel',
})
) {
- await AIProvider.histories?.cleanup(this.doc.collection.id, this.doc.id, [
+ await AIProvider.histories?.cleanup(this.doc.workspace.id, this.doc.id, [
this.chatContextValue.chatSessionId ?? '',
...(
this.chatContextValue.items.filter(
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.ts
index 62ce944713..b4b65058ef 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
@@ -1,4 +1,4 @@
-import { WorkspaceImpl } from '@affine/core/modules/workspace/impl/workspace';
+import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace';
import { BlockStdScope, type EditorHost } from '@blocksuite/affine/block-std';
import {
type AffineAIPanelWidgetConfig,
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.ts
index ba941b0331..df34c7fae7 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
@@ -1,4 +1,4 @@
-import { WorkspaceImpl } from '@affine/core/modules/workspace/impl/workspace.js';
+import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace.js';
import { BlockStdScope, type EditorHost } from '@blocksuite/affine/block-std';
import {
MarkdownAdapter,
@@ -239,12 +239,12 @@ export const markdownToMindmap = (
) => {
let result: Node | null = null;
const job = new Job({
- schema: doc.collection.schema,
- blobCRUD: doc.collection.blobSync,
+ schema: doc.workspace.schema,
+ blobCRUD: doc.workspace.blobSync,
docCRUD: {
- create: (id: string) => doc.collection.createDoc({ id }),
- get: (id: string) => doc.collection.getDoc(id),
- delete: (id: string) => doc.collection.removeDoc(id),
+ create: (id: string) => doc.workspace.createDoc({ id }),
+ get: (id: string) => doc.workspace.getDoc(id),
+ delete: (id: string) => doc.workspace.removeDoc(id),
},
});
const markdown = new MarkdownAdapter(job, provider);
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts b/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts
index 5b1d73f462..b51a768bbe 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts
@@ -403,7 +403,7 @@ export class ChatBlockInput extends LitElement {
let chatSessionId = currentSessionId;
if (!chatSessionId) {
const forkSessionId = await AIProvider.forkChat?.({
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
docId: doc.id,
sessionId: this.parentSessionId,
latestMessageId: this.latestMessageId,
@@ -421,7 +421,7 @@ export class ChatBlockInput extends LitElement {
sessionId: chatSessionId,
docId: doc.id,
attachments: images,
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
host: this.host,
stream: true,
signal: abortController.signal,
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.ts
index ad5d3d51a8..af12fec74d 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
@@ -269,7 +269,7 @@ export class AIChatBlockPeekView extends LitElement {
) {
const { doc } = this.host;
if (currentSessionId) {
- await AIProvider.histories?.cleanup(doc.collection.id, doc.id, [
+ await AIProvider.histories?.cleanup(doc.workspace.id, doc.id, [
currentSessionId,
]);
}
@@ -323,7 +323,7 @@ export class AIChatBlockPeekView extends LitElement {
sessionId: currentSessionId,
retry: true,
docId: doc.id,
- workspaceId: doc.collection.id,
+ workspaceId: doc.workspace.id,
host: this.host,
stream: true,
signal: abortController.signal,
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts
index 1a78116072..0cc176b6b6 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts
@@ -155,6 +155,6 @@ export const copyText = async (host: EditorHost, text: string) => {
const slice = Slice.fromModels(previewDoc, models);
await host.std.clipboard.copySlice(slice);
previewDoc.dispose();
- previewDoc.collection.dispose();
+ previewDoc.workspace.dispose();
return true;
};
diff --git a/packages/frontend/core/src/components/affine/page-history-modal/data.ts b/packages/frontend/core/src/components/affine/page-history-modal/data.ts
index 68913b3fbc..d9781ec228 100644
--- a/packages/frontend/core/src/components/affine/page-history-modal/data.ts
+++ b/packages/frontend/core/src/components/affine/page-history-modal/data.ts
@@ -2,7 +2,7 @@ import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-
import { useDocCollectionPage } from '@affine/core/components/hooks/use-block-suite-workspace-page';
import { FetchService, GraphQLService } from '@affine/core/modules/cloud';
import { getAFFiNEWorkspaceSchema } from '@affine/core/modules/workspace';
-import { WorkspaceImpl } from '@affine/core/modules/workspace/impl/workspace';
+import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace';
import { DebugLogger } from '@affine/debug';
import type { ListHistoryQuery } from '@affine/graphql';
import { listHistoryQuery, recoverDocMutation } from '@affine/graphql';
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx
index 89ceb70edf..352ae5a4e6 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
@@ -41,7 +41,7 @@ const BlockSuiteEditorImpl = ({
}: EditorProps) => {
useEffect(() => {
const disposable = page.slots.blockUpdated.once(() => {
- page.collection.meta.setDocMeta(page.id, {
+ page.workspace.meta.setDocMeta(page.id, {
updatedDate: Date.now(),
});
});
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.ts
index 56c6e2accb..9931f5ea8a 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
@@ -59,16 +59,16 @@ async function exportDoc(
config: AdapterConfig
) {
const job = new Job({
- schema: doc.collection.schema,
- blobCRUD: doc.collection.blobSync,
+ schema: doc.workspace.schema,
+ blobCRUD: doc.workspace.blobSync,
docCRUD: {
- create: (id: string) => doc.collection.createDoc({ id }),
- get: (id: string) => doc.collection.getDoc(id),
- delete: (id: string) => doc.collection.removeDoc(id),
+ create: (id: string) => doc.workspace.createDoc({ id }),
+ get: (id: string) => doc.workspace.getDoc(id),
+ delete: (id: string) => doc.workspace.removeDoc(id),
},
middlewares: [
- docLinkBaseURLMiddleware(doc.collection.id),
- titleMiddleware(doc.collection.meta.docMetas),
+ docLinkBaseURLMiddleware(doc.workspace.id),
+ titleMiddleware(doc.workspace.meta.docMetas),
embedSyncedDocMiddleware('content'),
],
});
@@ -148,7 +148,7 @@ async function exportHandler({
await exportToMarkdown(page, editorRoot?.std);
return;
case 'snapshot':
- await ZipTransformer.exportDocs(page.collection, [page]);
+ await ZipTransformer.exportDocs(page.workspace, [page]);
return;
case 'pdf':
await printToPdf(editorContainer);
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.ts
index aed99bcbd1..8eb50ffddd 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,4 +1,4 @@
-import { WorkspaceImpl } from '@affine/core/modules/workspace/impl/workspace';
+import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace';
import { AffineSchemas } from '@blocksuite/affine/blocks';
import type { Blocks, DocSnapshot } from '@blocksuite/affine/store';
import { Job, Schema } from '@blocksuite/affine/store';
diff --git a/packages/frontend/core/src/desktop/pages/workspace/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/index.tsx
index 36e084cba1..518725573b 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.getDoc())
+ .map(doc => doc.getBlocks())
);
};
window.importWorkspaceSnapshot = async () => {
diff --git a/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts b/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts
index 645903c5e9..e62e509194 100644
--- a/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts
+++ b/packages/frontend/core/src/modules/docs-search/worker/in-worker.ts
@@ -34,7 +34,7 @@ import {
} from 'yjs';
import { getAFFiNEWorkspaceSchema } from '../../workspace/global-schema';
-import { WorkspaceImpl } from '../../workspace/impl/workspace';
+import { WorkspaceImpl } from '../../workspace/impls/workspace';
import type { BlockIndexSchema, DocIndexSchema } from '../schema';
import type {
WorkerIngoingMessage,
diff --git a/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts b/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts
index 0631612d3f..8560bbb8f5 100644
--- a/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts
+++ b/packages/frontend/core/src/modules/workspace-engine/impls/cloud.ts
@@ -41,7 +41,7 @@ import {
type WorkspaceMetadata,
type WorkspaceProfileInfo,
} from '../../workspace';
-import { WorkspaceImpl } from '../../workspace/impl/workspace';
+import { WorkspaceImpl } from '../../workspace/impls/workspace';
import type { WorkspaceEngineStorageProvider } from '../providers/engine';
import { BroadcastChannelAwarenessConnection } from './engine/awareness-broadcast-channel';
import { CloudAwarenessConnection } from './engine/awareness-cloud';
diff --git a/packages/frontend/core/src/modules/workspace-engine/impls/local.ts b/packages/frontend/core/src/modules/workspace-engine/impls/local.ts
index 48a8de388f..6138138e39 100644
--- a/packages/frontend/core/src/modules/workspace-engine/impls/local.ts
+++ b/packages/frontend/core/src/modules/workspace-engine/impls/local.ts
@@ -19,7 +19,7 @@ import {
type WorkspaceMetadata,
type WorkspaceProfileInfo,
} from '../../workspace';
-import { WorkspaceImpl } from '../../workspace/impl/workspace';
+import { WorkspaceImpl } from '../../workspace/impls/workspace';
import type { WorkspaceEngineStorageProvider } from '../providers/engine';
import { BroadcastChannelAwarenessConnection } from './engine/awareness-broadcast-channel';
import { StaticBlobStorage } from './engine/blob-static';
diff --git a/packages/frontend/core/src/modules/workspace/entities/workspace.ts b/packages/frontend/core/src/modules/workspace/entities/workspace.ts
index d96a2e5343..6ef752e3e7 100644
--- a/packages/frontend/core/src/modules/workspace/entities/workspace.ts
+++ b/packages/frontend/core/src/modules/workspace/entities/workspace.ts
@@ -5,7 +5,7 @@ import type { Awareness } from 'y-protocols/awareness.js';
import { WorkspaceDBService } from '../../db';
import { getAFFiNEWorkspaceSchema } from '../global-schema';
-import { WorkspaceImpl } from '../impl/workspace';
+import { WorkspaceImpl } from '../impls/workspace';
import type { WorkspaceScope } from '../scopes/workspace';
import { WorkspaceEngineService } from '../services/engine';
diff --git a/packages/frontend/core/src/modules/workspace/impl/doc.ts b/packages/frontend/core/src/modules/workspace/impls/doc.ts
similarity index 94%
rename from packages/frontend/core/src/modules/workspace/impl/doc.ts
rename to packages/frontend/core/src/modules/workspace/impls/doc.ts
index 039d8bddc3..ff3fd409c8 100644
--- a/packages/frontend/core/src/modules/workspace/impl/doc.ts
+++ b/packages/frontend/core/src/modules/workspace/impls/doc.ts
@@ -4,7 +4,7 @@ import {
Blocks,
type BlockSuiteDoc,
type Doc,
- type GetDocOptions,
+ type GetBlocksOptions,
type Query,
type Workspace,
type YBlock,
@@ -128,7 +128,7 @@ export class DocImpl implements Doc {
};
get blobSync() {
- return this.collection.blobSync;
+ return this.workspace.blobSync;
}
get canRedo() {
@@ -139,12 +139,12 @@ export class DocImpl implements Doc {
return this._canUndo.peek();
}
- get collection() {
+ get workspace() {
return this._collection;
}
get docSync() {
- return this.collection.docSync;
+ return this.workspace.docSync;
}
get history() {
@@ -160,7 +160,7 @@ export class DocImpl implements Doc {
}
get meta() {
- return this.collection.meta.getDocMeta(this.id);
+ return this.workspace.meta.getDocMeta(this.id);
}
get readonly(): boolean {
@@ -172,7 +172,7 @@ export class DocImpl implements Doc {
}
get schema() {
- return this.collection.schema;
+ return this.workspace.schema;
}
get spaceDoc() {
@@ -200,8 +200,8 @@ export class DocImpl implements Doc {
private _handleVersion() {
// Initialization from empty yDoc, indicating that the document is new.
- if (!this.collection.meta.hasVersion) {
- this.collection.meta.writeVersion(this.collection);
+ if (!this.workspace.meta.hasVersion) {
+ this.workspace.meta.writeVersion(this.workspace);
}
}
@@ -279,7 +279,7 @@ export class DocImpl implements Doc {
}
}
- getDoc({ readonly, query }: GetDocOptions = {}) {
+ getBlocks({ readonly, query }: GetBlocksOptions = {}) {
const readonlyKey = this._getReadonlyKey(readonly);
const key = JSON.stringify(query);
@@ -290,7 +290,7 @@ export class DocImpl implements Doc {
const doc = new Blocks({
blockCollection: this,
- schema: this.collection.schema,
+ schema: this.workspace.schema,
readonly,
query,
});
@@ -307,7 +307,7 @@ export class DocImpl implements Doc {
this._ySpaceDoc.load();
- if ((this.collection.meta.docs?.length ?? 0) <= 1) {
+ if ((this.workspace.meta.docs?.length ?? 0) <= 1) {
this._handleVersion();
}
diff --git a/packages/frontend/core/src/modules/workspace/impl/workspace.ts b/packages/frontend/core/src/modules/workspace/impls/workspace.ts
similarity index 95%
rename from packages/frontend/core/src/modules/workspace/impl/workspace.ts
rename to packages/frontend/core/src/modules/workspace/impls/workspace.ts
index 69dfad5ca2..ed45527611 100644
--- a/packages/frontend/core/src/modules/workspace/impl/workspace.ts
+++ b/packages/frontend/core/src/modules/workspace/impls/workspace.ts
@@ -8,14 +8,15 @@ import {
AwarenessStore,
type Blocks,
BlockSuiteDoc,
- type CreateDocOptions,
+ type CreateBlocksOptions,
type Doc,
DocCollectionMeta,
- type GetDocOptions,
+ type GetBlocksOptions,
type IdGenerator,
nanoid,
type Schema,
type Workspace,
+ type WorkspaceMeta,
} from '@blocksuite/affine/store';
import {
AwarenessEngine,
@@ -74,7 +75,7 @@ export class WorkspaceImpl implements Workspace {
readonly idGenerator: IdGenerator;
- meta: DocCollectionMeta;
+ meta: WorkspaceMeta;
slots = {
docListUpdated: new Slot(),
@@ -153,7 +154,7 @@ export class WorkspaceImpl implements Workspace {
* If the `init` parameter is passed, a `surface`, `note`, and `paragraph` block
* will be created in the doc simultaneously.
*/
- createDoc(options: CreateDocOptions = {}) {
+ createDoc(options: CreateBlocksOptions = {}) {
const { id: docId = this.idGenerator(), query, readonly } = options;
if (this._hasDoc(docId)) {
throw new BlockSuiteError(
@@ -191,9 +192,9 @@ export class WorkspaceImpl implements Workspace {
return space ?? null;
}
- getDoc(docId: string, options?: GetDocOptions): Blocks | null {
+ getDoc(docId: string, options?: GetBlocksOptions): Blocks | null {
const collection = this.getBlockCollection(docId);
- return collection?.getDoc(options) ?? null;
+ return collection?.getBlocks(options) ?? null;
}
removeDoc(docId: string) {