diff --git a/src/main.ts b/src/main.ts index d4f3b58..487079f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -98,7 +98,7 @@ import { isCallerFromTemplaterPlugin, decompress, } from "./utils/Utils"; -import { extractSVGPNGFileName, getActivePDFPageNumberFromPDFView, getAttachmentsFolderAndFilePath, getNewOrAdjacentLeaf, getParentOfClass, isObsidianThemeDark, openLeaf } from "./utils/ObsidianUtils"; +import { extractSVGPNGFileName, getActivePDFPageNumberFromPDFView, getAttachmentsFolderAndFilePath, getCurrentActiveDirectory, getNewOrAdjacentLeaf, getParentOfClass, isObsidianThemeDark, openLeaf } from "./utils/ObsidianUtils"; import { ExcalidrawElement, ExcalidrawEmbeddableElement, ExcalidrawImageElement, ExcalidrawTextElement, FileId } from "@zsviczian/excalidraw/types/excalidraw/element/types"; import { ScriptEngine } from "./Scripts"; import { @@ -1093,7 +1093,7 @@ export default class ExcalidrawPlugin extends Plugin { this.settings, ); const folder = this.settings.embedUseExcalidrawFolder - ? null + ? (this.settings.folder && this.settings.folder.startsWith("./")) ? getCurrentActiveDirectory(activeView.file.path, this.settings.folder) : null : ( await getAttachmentsFolderAndFilePath( this.app, @@ -1101,6 +1101,7 @@ export default class ExcalidrawPlugin extends Plugin { filename, ) ).folder; + const file = await this.createDrawing(filename, folder); await this.embedDrawing(file); this.openDrawing(file, location, true, undefined, true);