mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { TemplateResult } from 'lit';
|
||||
|
||||
import { PeekViewProvider } from './service.js';
|
||||
import type { PeekableClass, PeekViewService } from './type.js';
|
||||
|
||||
export class PeekableController<T extends PeekableClass> {
|
||||
private _getPeekViewService = (): PeekViewService | null => {
|
||||
return this.target.std.getOptional(PeekViewProvider);
|
||||
};
|
||||
|
||||
peek = (template?: TemplateResult) => {
|
||||
return Promise.resolve<void>(
|
||||
this._getPeekViewService()?.peek({
|
||||
target: this.target,
|
||||
template,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
get peekable() {
|
||||
return (
|
||||
!!this._getPeekViewService() &&
|
||||
(this.enable ? this.enable(this.target) : true)
|
||||
);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private target: T,
|
||||
private enable?: (e: T) => boolean
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user