schlechtenburg/packages/standalone/lib/main.ts

41 lines
819 B
TypeScript
Raw Normal View History

2022-03-21 00:53:25 +00:00
import { createApp } from 'vue'
import { ISbMainProps } from '@schlechtenburg/core';
import getWrapper from './get-wrapper';
2022-03-17 17:59:51 +00:00
/**
2022-03-22 22:02:56 +00:00
* Initializes the Schlechtenburg editor
2022-03-17 17:59:51 +00:00
*
2022-03-22 22:02:56 +00:00
* @param el The element on which the editor schould be mounted
* @param props The Schlechtenburg props
*
* @returns A set of functions to interact with the live Schlechtenburg instance
*
* @See ISbMainProps
* @See SbMain
2022-03-17 17:59:51 +00:00
*/
export const startSchlechtenburg = async (
el:HTMLElement|string,
2022-03-20 13:49:44 +00:00
props:ISbMainProps,
2022-03-17 17:59:51 +00:00
) => {
2022-03-21 00:53:25 +00:00
const {
SchlechtenburgWrapper,
getBlock,
setBlock,
getMode,
setMode,
} = getWrapper();
const app = createApp(
SchlechtenburgWrapper,
{ ...props, } 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 {
2022-03-21 00:53:25 +00:00
getBlock,
setBlock,
getMode,
setMode,
2022-03-20 13:49:44 +00:00
};
2022-03-17 17:59:51 +00:00
}