mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
33 lines
979 B
TypeScript
33 lines
979 B
TypeScript
import type { ExtensionType } from '@blocksuite/store';
|
|
|
|
import { WidgetViewMapIdentifier } from '../identifier.js';
|
|
import type { WidgetViewMapType } from '../spec/type.js';
|
|
|
|
/**
|
|
* Create a widget view map extension.
|
|
*
|
|
* @param flavour The flavour of the block that the widget view map is for.
|
|
* @param widgetViewMap A map of widget names to widget view lit literal.
|
|
*
|
|
* A widget view map is to provide a map of widgets to a block.
|
|
* For every target block, it's view will be rendered with the widget views.
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* import { WidgetViewMapExtension } from '@blocksuite/block-std';
|
|
*
|
|
* const MyWidgetViewMapExtension = WidgetViewMapExtension('my-flavour', {
|
|
* 'my-widget': literal`my-widget-view`
|
|
* });
|
|
*/
|
|
export function WidgetViewMapExtension(
|
|
flavour: BlockSuite.Flavour,
|
|
widgetViewMap: WidgetViewMapType
|
|
): ExtensionType {
|
|
return {
|
|
setup: di => {
|
|
di.addImpl(WidgetViewMapIdentifier(flavour), () => widgetViewMap);
|
|
},
|
|
};
|
|
}
|