From c82229078bf9a0210ba7cfd20de5ae1c993d47bf Mon Sep 17 00:00:00 2001 From: Flatulent Fowl Date: Tue, 12 May 2026 23:10:47 +0200 Subject: [PATCH] feat: add mimeType setting and modernize settings UI components with improved path resolution --- .DS_Store | Bin 0 -> 6148 bytes src/main.ts | 28 +++++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..feca8613504bcd7430524202412f605a970dd548 GIT binary patch literal 6148 zcmeH~JqiLr422VS3&Cbf%V|7-HyA`u-~~i21wpZ&qx41vI)z6#m+=T zbn`f`MFtU>!%bynVPcAXCwIBY>3lz3j@RpDteEA>YT$!Ro{xoGkN^pg011!)3H%HJ zJGWu;MJOW)kN^pc1nmD%;HEXTh5D}p!AAgSkF*=sK1)E0C7?C6g(3sfXoW_r`WRw) zZ-`o{NKSp&Hs}YZb^Uy{)~Y3 z+x>QfkIJ+4?ei>u$gHg!9O~r=FP8vp>?mHs-SE8F0$NjBC^9f!1RMhc34E2n6Mwc5 Aa{vGU literal 0 HcmV?d00001 diff --git a/src/main.ts b/src/main.ts index 9c3a015..3b6870d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -44,6 +44,7 @@ interface DocDropSettings { docIntelEndpoint: string; docIntelApiKey: string; charset: string; + mimeType: string; } const DEFAULT_SETTINGS: DocDropSettings = { @@ -59,6 +60,7 @@ const DEFAULT_SETTINGS: DocDropSettings = { docIntelEndpoint: "", docIntelApiKey: "", charset: "", + mimeType: "", }; // ─── Overwrite Confirmation Modal ──────────────────────────────────────────── @@ -178,7 +180,7 @@ class DocDropSettingTab extends PluginSettingTab { ); } - containerEl.createEl("h3", { text: "Conversion options" }); + new Setting(containerEl).setName("Conversion").setHeading(); new Setting(containerEl) .setName("Keep images") @@ -231,7 +233,7 @@ class DocDropSettingTab extends PluginSettingTab { // ── markitdown-ocr ────────────────────────────────────────────────────── - containerEl.createEl("h3", { text: "markitdown-ocr plugin (optional)" }); + new Setting(containerEl).setName("markitdown-ocr plugin (optional)").setHeading(); containerEl.createEl("p", { text: @@ -239,9 +241,9 @@ class DocDropSettingTab extends PluginSettingTab { "OpenAI's GPT-4o) to read text from images inside PDFs — useful for scanned documents or " + "PDFs that are just pictures of pages. Install it first with: pip install markitdown-ocr. " + "You will need an OpenAI account (or a compatible service) to provide the AI." - ); + }); - new Setting(ocrDetails) + new Setting(containerEl) .setName("Enable markitdown-ocr") .setDesc( "Activate any installed markitdown plugins, including markitdown-ocr. " + @@ -259,7 +261,7 @@ class DocDropSettingTab extends PluginSettingTab { ); if (this.plugin.settings.usePlugins) { - new Setting(ocrDetails) + new Setting(containerEl) .setName("OpenAI API key") .setDesc( "Your secret API key from OpenAI (or a compatible service). " + @@ -278,7 +280,7 @@ class DocDropSettingTab extends PluginSettingTab { text.inputEl.type = "password"; }); - new Setting(ocrDetails) + new Setting(containerEl) .setName("AI model") .setDesc( "The vision-capable AI model markitdown-ocr will use to read images. " + @@ -296,7 +298,7 @@ class DocDropSettingTab extends PluginSettingTab { }) ); - new Setting(ocrDetails) + new Setting(containerEl) .setName("OpenAI API base URL (optional)") .setDesc( "Override the API server markitdown-ocr connects to. " + @@ -318,7 +320,7 @@ class DocDropSettingTab extends PluginSettingTab { // ── Azure Document Intelligence ───────────────────────────────────────── - containerEl.createEl("h3", { text: "Azure Document Intelligence (optional)" }); + new Setting(containerEl).setName("Azure Document Intelligence (optional)").setHeading(); containerEl.createEl("p", { text: @@ -326,7 +328,7 @@ class DocDropSettingTab extends PluginSettingTab { "much higher accuracy than offline conversion — especially for scanned documents, handwriting, " + "tables, and complex layouts. Requires an Azure account. " + "Leave these blank to use free offline conversion instead." - ); + }); new Setting(containerEl) .setName("Use Document Intelligence") @@ -345,7 +347,7 @@ class DocDropSettingTab extends PluginSettingTab { ); if (this.plugin.settings.useDocIntel) { - new Setting(azureDetails) + new Setting(containerEl) .setName("Endpoint URL") .setDesc( "The URL of your Azure Document Intelligence resource. " + @@ -363,7 +365,7 @@ class DocDropSettingTab extends PluginSettingTab { }) ); - new Setting(azureDetails) + new Setting(containerEl) .setName("API key") .setDesc( "The secret key that authenticates you with Azure Document Intelligence. " + @@ -408,7 +410,7 @@ export default class DocDropPlugin extends Plugin { new Notice(`DocDrop does not support .${activeFile.extension} files.`); return; } - this.convertPdf(activeFile); + void this.convertFile(activeFile); }, }); @@ -440,7 +442,7 @@ export default class DocDropPlugin extends Plugin { private async convertFile(pdfFile: TFile): Promise { const adapter = this.app.vault.adapter; - const basePath = (adapter as any).getBasePath() as string; + const basePath = (adapter as FileSystemAdapter).getBasePath(); const absolutePdfPath = `${basePath}/${pdfFile.path}`; const outputVaultPath = this.resolveOutputPath(pdfFile);