schlechtenburg/packages/core/lib/use-dynamic-blocks.ts

17 lines
378 B
TypeScript

import {
inject,
reactive,
} from 'vue';
import { BlockLibrary } from './types';
export const SymBlockLibrary = Symbol('Schlechtenburg block library');
export function useDynamicBlocks() {
const customBlocks: BlockLibrary = inject(SymBlockLibrary, reactive({}));
const getBlock = (name: string) => customBlocks[name];
return {
customBlocks,
getBlock,
};
}