From 9b7d828209092e7d49cbb08bf87f42c680db7616 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sat, 16 Mar 2024 15:13:45 -0600 Subject: [PATCH] Set folder to current active folder if Excalidraw Folder name starts with "./" and embedUseExcalidrawFolder is true. --- src/main.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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);