mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 03:33:06 +08:00
feat(infra): add convenience api to get workspace from doc (#7934)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import type { RootBlockModel } from '@blocksuite/blocks';
|
import type { RootBlockModel } from '@blocksuite/blocks';
|
||||||
|
|
||||||
import { Entity } from '../../../framework';
|
import { Entity } from '../../../framework';
|
||||||
|
import type { WorkspaceService } from '../../workspace';
|
||||||
import type { DocScope } from '../scopes/doc';
|
import type { DocScope } from '../scopes/doc';
|
||||||
import type { DocsStore } from '../stores/docs';
|
import type { DocsStore } from '../stores/docs';
|
||||||
import type { DocMode } from './record';
|
import type { DocMode } from './record';
|
||||||
@@ -8,11 +9,19 @@ import type { DocMode } from './record';
|
|||||||
export class Doc extends Entity {
|
export class Doc extends Entity {
|
||||||
constructor(
|
constructor(
|
||||||
public readonly scope: DocScope,
|
public readonly scope: DocScope,
|
||||||
private readonly store: DocsStore
|
private readonly store: DocsStore,
|
||||||
|
private readonly workspaceService: WorkspaceService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* for convenience
|
||||||
|
*/
|
||||||
|
get workspace() {
|
||||||
|
return this.workspaceService.workspace;
|
||||||
|
}
|
||||||
|
|
||||||
get id() {
|
get id() {
|
||||||
return this.scope.props.docId;
|
return this.scope.props.docId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,6 @@ export function configureDocModule(framework: Framework) {
|
|||||||
.entity(DocRecord, [DocsStore])
|
.entity(DocRecord, [DocsStore])
|
||||||
.entity(DocRecordList, [DocsStore])
|
.entity(DocRecordList, [DocsStore])
|
||||||
.scope(DocScope)
|
.scope(DocScope)
|
||||||
.entity(Doc, [DocScope, DocsStore])
|
.entity(Doc, [DocScope, DocsStore, WorkspaceService])
|
||||||
.service(DocService);
|
.service(DocService);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user