2020-05-20 14:21:08 +00:00
|
|
|
import {
|
|
|
|
defineComponent,
|
2020-05-24 15:33:25 +00:00
|
|
|
provide,
|
2020-12-27 21:32:43 +00:00
|
|
|
shallowReactive,
|
|
|
|
} from 'vue';
|
2021-03-08 15:29:35 +00:00
|
|
|
import { SymBlockLibrary} from '../use-dynamic-blocks';
|
2020-05-24 15:33:25 +00:00
|
|
|
|
2020-12-30 20:17:34 +00:00
|
|
|
import { SbBlock } from './Block';
|
2020-05-24 20:00:14 +00:00
|
|
|
|
2021-03-08 16:45:21 +00:00
|
|
|
import './Main.scss';
|
2020-05-27 13:57:57 +00:00
|
|
|
|
2021-03-08 15:29:35 +00:00
|
|
|
export const SbMain = defineComponent({
|
|
|
|
name: 'sb-main',
|
2020-05-20 14:21:08 +00:00
|
|
|
|
2021-03-08 17:03:18 +00:00
|
|
|
model: {
|
|
|
|
prop: 'block',
|
|
|
|
event: 'update',
|
|
|
|
},
|
2020-05-20 14:21:08 +00:00
|
|
|
|
|
|
|
props: {
|
2021-03-08 15:29:35 +00:00
|
|
|
customBlocks: {
|
2021-03-08 17:13:18 +00:00
|
|
|
type: Array,
|
2021-03-08 15:29:35 +00:00
|
|
|
default: () => [],
|
|
|
|
},
|
|
|
|
block: {
|
2021-03-08 17:13:18 +00:00
|
|
|
type: Object,
|
2021-03-08 15:29:35 +00:00
|
|
|
required: true,
|
|
|
|
},
|
2020-05-20 14:21:08 +00:00
|
|
|
},
|
|
|
|
|
2021-03-08 17:13:18 +00:00
|
|
|
setup(props) {
|
|
|
|
const blockLibrary = shallowReactive({
|
2020-05-24 15:33:25 +00:00
|
|
|
...props.customBlocks.reduce(
|
2021-03-08 17:13:18 +00:00
|
|
|
(blocks, block) => ({ ...blocks, [block.name]: block }),
|
2020-05-24 15:33:25 +00:00
|
|
|
{},
|
|
|
|
),
|
|
|
|
});
|
2020-12-27 21:32:43 +00:00
|
|
|
|
2021-03-08 15:29:35 +00:00
|
|
|
provide(SymBlockLibrary, blockLibrary);
|
2020-05-20 14:21:08 +00:00
|
|
|
|
2021-03-08 17:24:06 +00:00
|
|
|
return () => <SbBlock block={props.block} />;
|
2020-05-20 14:21:08 +00:00
|
|
|
},
|
|
|
|
});
|