2020-12-30 01:32:46 +00:00
|
|
|
import {
|
|
|
|
inject,
|
|
|
|
reactive,
|
|
|
|
} from 'vue';
|
2021-03-08 15:29:35 +00:00
|
|
|
import { BlockLibrary } from './types';
|
2020-12-30 01:32:46 +00:00
|
|
|
|
2021-03-08 15:29:35 +00:00
|
|
|
export const SymBlockLibrary = Symbol('Schlechtenburg block library');
|
2020-12-30 01:32:46 +00:00
|
|
|
export function useDynamicBlocks() {
|
2021-03-08 15:29:35 +00:00
|
|
|
const customBlocks: BlockLibrary = inject(SymBlockLibrary, reactive({}));
|
2021-02-22 23:12:06 +00:00
|
|
|
const getBlock = (name: string) => customBlocks[name];
|
2020-12-30 01:32:46 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
customBlocks,
|
|
|
|
getBlock,
|
|
|
|
};
|
|
|
|
}
|