refactor(editor): should not rely on doc collection type (#9501)

This commit is contained in:
Saul-Mirone
2025-01-03 06:30:27 +00:00
parent cb5d7eaabc
commit 897c7d4284
55 changed files with 200 additions and 158 deletions
@@ -23,7 +23,7 @@ export class TagStore extends Store {
subscribe(cb: () => void) {
const disposable =
this.workspaceService.workspace.docCollection.meta.docMetaUpdated.on(cb);
this.workspaceService.workspace.docCollection.slots.docListUpdated.on(cb);
return disposable.dispose;
}
@@ -1,4 +1,7 @@
import { DocCollection } from '@blocksuite/affine/store';
import {
DocCollection,
type Workspace as BSWorkspace,
} from '@blocksuite/affine/store';
import { Entity, LiveData } from '@toeverything/infra';
import { nanoid } from 'nanoid';
import { Observable } from 'rxjs';
@@ -22,7 +25,7 @@ export class Workspace extends Entity {
readonly flavour = this.meta.flavour;
_docCollection: DocCollection | null = null;
_docCollection: BSWorkspace | null = null;
get docCollection() {
if (!this._docCollection) {
@@ -1,4 +1,4 @@
import type { DocCollection } from '@blocksuite/affine/store';
import type { Workspace as BSWorkspace } from '@blocksuite/affine/store';
import {
type AwarenessConnection,
type BlobStorage,
@@ -27,7 +27,7 @@ export interface WorkspaceFlavourProvider {
createWorkspace(
initial: (
docCollection: DocCollection,
docCollection: BSWorkspace,
blobStorage: BlobStorage,
docStorage: DocStorage
) => Promise<void>
@@ -3,8 +3,6 @@ import { Scope } from '@toeverything/infra';
import type { WorkspaceOpenOptions } from '../open-options';
import type { WorkspaceEngineProvider } from '../providers/flavour';
export type { DocCollection } from '@blocksuite/affine/store';
export class WorkspaceScope extends Scope<{
openOptions: WorkspaceOpenOptions;
engineProvider: WorkspaceEngineProvider;
@@ -1,4 +1,4 @@
import type { DocCollection } from '@blocksuite/affine/store';
import type { Workspace } from '@blocksuite/affine/store';
import {
type BlobStorage,
type DocStorage,
@@ -21,7 +21,7 @@ export class WorkspaceFactoryService extends Service {
create = async (
flavour: string,
initial: (
docCollection: DocCollection,
docCollection: Workspace,
blobStorage: BlobStorage,
docStorage: DocStorage
) => Promise<void> = () => Promise.resolve()