schlechtenburg/packages/standalone/lib/main.ts

40 lines
644 B
TypeScript
Raw Normal View History

2022-03-17 17:59:51 +00:00
import {
2022-03-20 13:49:44 +00:00
createApp,
} from 'vue'
import {
ISbMainProps,
IBlockData,
SbMain,
} from '@schlechtenburg/core';
2022-03-17 17:59:51 +00:00
/**
*
*/
export const startSchlechtenburg = async (
/**
* The element on which the editor schould be mounted
*/
el:HTMLElement|string,
/**
* The schlechtenburg props
*/
2022-03-20 13:49:44 +00:00
props:ISbMainProps,
2022-03-17 17:59:51 +00:00
) => {
2022-03-20 13:49:44 +00:00
let block = { ...props.block };
const app = createApp(SbMain, {
...props,
onUpdate: (update: IBlockData<any>) => {
block = update;
props.onUpdate(update);
},
}as unknown as Record<string, unknown>);
2022-03-17 17:59:51 +00:00
app.mount(el);
2022-03-20 13:49:44 +00:00
return {
getBlock() {
return block;
},
};
2022-03-17 17:59:51 +00:00
}