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

This commit is contained in:
Saul-Mirone
2025-01-04 12:51:56 +00:00
parent 650e4fb6b2
commit c773982ced
83 changed files with 293 additions and 290 deletions
@@ -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),
@@ -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();
})
);
@@ -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);
})
);
@@ -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();
})
);