mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
24 lines
609 B
TypeScript
24 lines
609 B
TypeScript
import { createIdentifier } from '@blocksuite/global/di';
|
|
import type { ExtensionType } from '@blocksuite/store';
|
|
|
|
import type { SurfaceBlockModel } from '../surface-model';
|
|
|
|
export type SurfaceMiddleware = (surface: SurfaceBlockModel) => () => void;
|
|
|
|
export const surfaceMiddlewareIdentifier = createIdentifier<{
|
|
middleware: SurfaceMiddleware;
|
|
}>('surface-middleware');
|
|
|
|
export function surfaceMiddlewareExtension(
|
|
id: string,
|
|
middleware: SurfaceMiddleware
|
|
): ExtensionType {
|
|
return {
|
|
setup: di => {
|
|
di.addImpl(surfaceMiddlewareIdentifier(id), {
|
|
middleware,
|
|
});
|
|
},
|
|
};
|
|
}
|