mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
30
blocksuite/framework/block-std/src/extension/config.ts
Normal file
30
blocksuite/framework/block-std/src/extension/config.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ConfigIdentifier } from '../identifier.js';
|
||||
import type { ExtensionType } from './extension.js';
|
||||
|
||||
/**
|
||||
* Create a config extension.
|
||||
* A config extension provides a configuration object for a block flavour.
|
||||
* The configuration object can be used like:
|
||||
* ```ts
|
||||
* const config = std.provider.get(ConfigIdentifier('my-flavour'));
|
||||
* ```
|
||||
*
|
||||
* @param flavor The flavour of the block that the config is for.
|
||||
* @param config The configuration object.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { ConfigExtension } from '@blocksuite/block-std';
|
||||
* const MyConfigExtension = ConfigExtension('my-flavour', config);
|
||||
* ```
|
||||
*/
|
||||
export function ConfigExtension(
|
||||
flavor: BlockSuite.Flavour,
|
||||
config: Record<string, unknown>
|
||||
): ExtensionType {
|
||||
return {
|
||||
setup: di => {
|
||||
di.addImpl(ConfigIdentifier(flavor), () => config);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user