Skip to content

Commit 4bc4a58

Browse files
committed
feat(infra): add convenience api to get workspace from doc (#7934)
1 parent 2f02f0d commit 4bc4a58

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/common/infra/src/modules/doc/entities/doc.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
import type { RootBlockModel } from '@blocksuite/blocks';
22

33
import { Entity } from '../../../framework';
4+
import type { WorkspaceService } from '../../workspace';
45
import type { DocScope } from '../scopes/doc';
56
import type { DocsStore } from '../stores/docs';
67
import type { DocMode } from './record';
78

89
export class Doc extends Entity {
910
constructor(
1011
public readonly scope: DocScope,
11-
private readonly store: DocsStore
12+
private readonly store: DocsStore,
13+
private readonly workspaceService: WorkspaceService
1214
) {
1315
super();
1416
}
1517

18+
/**
19+
* for convenience
20+
*/
21+
get workspace() {
22+
return this.workspaceService.workspace;
23+
}
24+
1625
get id() {
1726
return this.scope.props.docId;
1827
}

packages/common/infra/src/modules/doc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export function configureDocModule(framework: Framework) {
2828
.entity(DocRecord, [DocsStore])
2929
.entity(DocRecordList, [DocsStore])
3030
.scope(DocScope)
31-
.entity(Doc, [DocScope, DocsStore])
31+
.entity(Doc, [DocScope, DocsStore, WorkspaceService])
3232
.service(DocService);
3333
}

0 commit comments

Comments
 (0)