2022-03-17 17:59:51 +00:00
|
|
|
import {
|
|
|
|
defineComponent,
|
|
|
|
PropType,
|
|
|
|
} from 'vue';
|
|
|
|
import {
|
|
|
|
OnUpdateBlockCb,
|
|
|
|
IBlockDefinition,
|
|
|
|
IBlockData,
|
|
|
|
SbMode,
|
|
|
|
SbMain,
|
|
|
|
} from '@schlechtenburg/core';
|
|
|
|
|
|
|
|
export interface ISchlechtenburgProps {
|
|
|
|
availableBlocks: IBlockDefinition<any>[];
|
|
|
|
block: IBlockData<any>;
|
|
|
|
onUpdate: OnUpdateBlockCb;
|
|
|
|
mode: SbMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Schlechtenburg = defineComponent({
|
|
|
|
name: 'schlechtenburg',
|
|
|
|
|
|
|
|
props: {
|
|
|
|
availableBlocks: {
|
|
|
|
type: Array as PropType<IBlockDefinition<any>[]>,
|
|
|
|
default: () => [],
|
|
|
|
},
|
|
|
|
block: {
|
|
|
|
type: Object as PropType<IBlockData<any>>,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Called when the block should be updated.
|
|
|
|
*/
|
|
|
|
onUpdate: {
|
|
|
|
type: (null as unknown) as PropType<OnUpdateBlockCb>,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
mode: {
|
|
|
|
type: String as PropType<SbMode>,
|
|
|
|
validator(value: any) {
|
|
|
|
return Object.values(SbMode).includes(value);
|
|
|
|
},
|
|
|
|
default: SbMode.Edit,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
setup(props: ISchlechtenburgProps) {
|
|
|
|
return () => <SbMain
|
|
|
|
block={props.block}
|
2022-03-20 13:49:44 +00:00
|
|
|
availableBlocks={props.availableBlocks}
|
2022-03-17 17:59:51 +00:00
|
|
|
onUpdate={props.onUpdate}
|
|
|
|
mode={props.mode}
|
|
|
|
/>;
|
|
|
|
},
|
|
|
|
});
|