diff --git a/src/@types/ExcalidrawAutomate.d.ts b/src/@types/ExcalidrawAutomate.d.ts new file mode 100644 index 00000000..57333d1c --- /dev/null +++ b/src/@types/ExcalidrawAutomate.d.ts @@ -0,0 +1,49 @@ +export declare class ExcalidrawAutomate { + /** + * + * @param templatePath + * @param embedFont + * @param exportSettings use ExcalidrawAutomate.getExportSettings(boolean,boolean) + * @param loader use ExcalidrawAutomate.getEmbeddedFilesLoader(boolean?) + * @param theme + * @param padding + * @returns + */ + createSVG( + templatePath?: string, + embedFont?: boolean, + exportSettings?: ExportSettings, + loader?: any, + theme?: string, + padding?: number + ): Promise; + + /** + * utility function to generate EmbeddedFilesLoader object + * @param isDark + * @returns + */ + getEmbeddedFilesLoader(isDark?: boolean): any; + + /** + * utility function to generate ExportSettings object + * @param withBackground + * @param withTheme + * @returns + */ + getExportSettings(withBackground: boolean, withTheme: boolean): ExportSettings; +} + +interface ExportSettings { + withBackground: boolean; + withTheme: boolean; + isMask: boolean; + frameRendering?: { + //optional, overrides relevant appState settings for rendering the frame + enabled: boolean; + name: boolean; + outline: boolean; + clip: boolean; + }; + skipInliningFonts?: boolean; +} diff --git a/src/conversion/compiler/excalidraw.ts b/src/conversion/compiler/excalidraw.ts index ee187fcf..94d9c041 100644 --- a/src/conversion/compiler/excalidraw.ts +++ b/src/conversion/compiler/excalidraw.ts @@ -1,12 +1,19 @@ import type { App, TFile } from "obsidian"; +import type {ExcalidrawAutomate} from "../../@types/ExcalidrawAutomate"; +/** + * @param file + * @param app + */ export async function convertToHTMLSVG(file: TFile, app: App) { try { const excalidraw = app.plugins.getPlugin("obsidian-excalidraw-plugin"); if (!excalidraw) return null; // @ts-ignore - const ea = excalidraw.ea; - const svg = await ea.createSVG(file.path, ea.getExportSettings(true, true)); + const ea = excalidraw.ea as ExcalidrawAutomate; + const settings = ea.getExportSettings(true, true); + const embeddedFilesLoader = ea.getEmbeddedFilesLoader(true); + const svg = await ea.createSVG(file.path, true, settings, embeddedFilesLoader); return svg.outerHTML as string; } catch (e) { console.error(e);