diff --git a/package-lock.json b/package-lock.json index 14e63dd..480956c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "folio", - "version": "0.1.3", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "folio", - "version": "0.1.3", + "version": "0.1.2", "license": "MIT", "dependencies": { "@tiptap/core": "^2.27.2", diff --git a/package.json b/package.json index ac9f264..5561b17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "folio", - "version": "0.1.3", + "version": "0.1.2", "description": "A simple, local, open-source desktop writing app.", "productName": "Folio", "author": "Folio Contributors", diff --git a/src/main/index.ts b/src/main/index.ts index cabf016..169a3d4 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -502,36 +502,14 @@ function currentBookTitle(): string { } } -// GTK save dialogs started with a bare filename (no directory) re-synthesize -// the name from the last-browsed folder when the user navigates, producing -// names like "Some Folder/.odt". Always hand them an absolute path. The last -// export folder is remembered so exports reopen where the user left them. -function exportDefaultPath(filename: string): string { - const last = getSetting("lastExportDir", ""); - const dir = - last && fs.existsSync(last) && fs.statSync(last).isDirectory() - ? last - : app.getPath("documents"); - return path.join(dir, filename); -} - -function rememberExportDir(filePath: string): void { - try { - setSetting("lastExportDir", path.dirname(filePath)); - } catch { - // best-effort only - } -} - handleIpc("folio:exportMarkdown", async () => { const bp = requireBook(); const { canceled, filePath } = await showSaveDialog({ title: "Export combined Markdown", - defaultPath: exportDefaultPath(`${currentBookTitle()}.md`), + defaultPath: `${currentBookTitle()}.md`, filters: [{ name: "Markdown", extensions: ["md"] }], }); if (canceled || !filePath) return { canceled: true } as const; - rememberExportDir(filePath); fs.writeFileSync(filePath, combineMarkdown(bp), "utf-8"); return { ok: true, filePath }; }); @@ -540,11 +518,10 @@ handleIpc("folio:exportZip", async () => { const bp = requireBook(); const { canceled, filePath } = await showSaveDialog({ title: "Export book bundle (ZIP)", - defaultPath: exportDefaultPath(`${currentBookTitle()}.zip`), + defaultPath: `${currentBookTitle()}.zip`, filters: [{ name: "ZIP Archive", extensions: ["zip"] }], }); if (canceled || !filePath) return { canceled: true } as const; - rememberExportDir(filePath); const buf = await buildZip(bp); fs.writeFileSync(filePath, buf); return { ok: true, filePath }; @@ -572,12 +549,11 @@ requireBook(); } else { const { canceled, filePath: chosen } = await showSaveDialog({ title: "Export as PDF", - defaultPath: exportDefaultPath(`${base}${suffix}.pdf`), + defaultPath: `${base}${suffix}.pdf`, filters: [{ name: "PDF Document", extensions: ["pdf"] }], }); if (canceled || !chosen) return { canceled: true } as const; filePath = chosen.endsWith(".pdf") ? chosen : `${chosen}.pdf`; - rememberExportDir(filePath); } const win = getWindow(); if (!win) return { error: "No window is open." }; @@ -614,7 +590,7 @@ async function exportOffice(format: "docx" | "odt", chapterIds?: string[] | null } else { const { canceled, filePath: chosen } = await showSaveDialog({ title: `Export${selected ? " Selected Chapters" : " Full Book"} as ${format.toUpperCase()}`, - defaultPath: exportDefaultPath(`${base}${suffix}.${ext}`), + defaultPath: `${base}${suffix}.${ext}`, filters: [ { name: format === "docx" ? "Word Document" : "OpenDocument Text", @@ -624,7 +600,6 @@ async function exportOffice(format: "docx" | "odt", chapterIds?: string[] | null }); if (canceled || !chosen) return { canceled: true } as const; filePath = chosen.endsWith(`.${ext}`) ? chosen : `${chosen}.${ext}`; - rememberExportDir(filePath); } const meta = loadBook(bp); const chapters = selected @@ -656,11 +631,10 @@ handleIpc("folio:saveChapterAs", async (_e, id: string) => { if (!entry) return { error: "Chapter not found" }; const { canceled, filePath } = await showSaveDialog({ title: "Save Chapter As", - defaultPath: exportDefaultPath(`${entry.title}.md`), + defaultPath: `${entry.title}.md`, filters: [{ name: "Markdown", extensions: ["md"] }], }); if (canceled || !filePath) return { canceled: true } as const; - rememberExportDir(filePath); const content = getChapterContent(bp, id); fs.writeFileSync(filePath, content, "utf-8"); return { ok: true, filePath };