You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
720 B

type VditorModule = {
default: new (element: HTMLElement, options: Record<string, unknown>) => {
getValue: () => string
setValue: (value: string, render?: boolean) => void
destroy: () => void
}
}
interface InitializeVditorOptions {
importVditor: () => Promise<VditorModule>
isUnmounted: () => boolean
onReady: (ctor: VditorModule['default']) => void
onError?: (error: unknown) => void
}
export async function initializePostBodyMarkdownEditorVditor(options: InitializeVditorOptions): Promise<void> {
try {
const mod = await options.importVditor()
if (options.isUnmounted()) {
return
}
options.onReady(mod.default)
}
catch (error) {
options.onError?.(error)
}
}