2020-12-30 01:32:46 +00:00
|
|
|
import {
|
|
|
|
ref,
|
|
|
|
inject,
|
|
|
|
reactive,
|
|
|
|
} from 'vue';
|
2022-03-11 16:50:50 +00:00
|
|
|
import { IBlockLibrary } from './types';
|
2022-03-15 23:38:33 +00:00
|
|
|
import { SymMode, SbMode } from './mode';
|
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() {
|
2022-03-15 23:38:33 +00:00
|
|
|
const mode = inject(SymMode, ref(SbMode.Edit));
|
2022-03-11 16:50:50 +00:00
|
|
|
const customBlocks: IBlockLibrary = 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 {
|
|
|
|
mode,
|
|
|
|
customBlocks,
|
|
|
|
getBlock,
|
|
|
|
};
|
|
|
|
}
|