mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
388641bc89
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Unified internal data access by replacing all references from `doc` to `store` across all components, blocks, widgets, and utilities. This affects how readonly state, block operations, and service retrieval are handled throughout the application. - **Tests** - Updated all test utilities and test cases to use `store` instead of `doc` for document-related operations. - **Chores** - Updated context providers and property names to reflect the change from `doc` to `store` for improved consistency and maintainability. No user-facing features or behaviors have changed. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
47 lines
838 B
TypeScript
47 lines
838 B
TypeScript
import { MenuContext } from '@blocksuite/affine-components/toolbar';
|
|
|
|
import type { CodeBlockComponent } from '../code-block';
|
|
|
|
export class CodeBlockToolbarContext extends MenuContext {
|
|
override close = () => {
|
|
this.abortController.abort();
|
|
};
|
|
|
|
get doc() {
|
|
return this.blockComponent.store;
|
|
}
|
|
|
|
get host() {
|
|
return this.blockComponent.host;
|
|
}
|
|
|
|
get selectedBlockModels() {
|
|
if (this.blockComponent.model) return [this.blockComponent.model];
|
|
return [];
|
|
}
|
|
|
|
get std() {
|
|
return this.blockComponent.std;
|
|
}
|
|
|
|
constructor(
|
|
public blockComponent: CodeBlockComponent,
|
|
public abortController: AbortController,
|
|
public setActive: (active: boolean) => void
|
|
) {
|
|
super();
|
|
}
|
|
|
|
isEmpty() {
|
|
return false;
|
|
}
|
|
|
|
isMultiple() {
|
|
return false;
|
|
}
|
|
|
|
isSingle() {
|
|
return true;
|
|
}
|
|
}
|