diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 8b4b5bb66..7b8fe7b7a 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -298,7 +298,9 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { } const { ipcRenderer } = utils.dynamicRequire("electron"); - ipcRenderer.send("export-as-pdf"); + ipcRenderer.send("export-as-pdf", { + title: this.note.title + }); } hoistedNoteChangedEvent({ ntxId }) { diff --git a/src/services/window.ts b/src/services/window.ts index a2638b9b5..acff5b4e8 100644 --- a/src/services/window.ts +++ b/src/services/window.ts @@ -10,7 +10,7 @@ import keyboardActionsService from "./keyboard_actions.js"; import remoteMain from "@electron/remote/main/index.js"; import { BrowserWindow, type App, type BrowserWindowConstructorOptions, type WebContents } from "electron"; import { dialog, ipcMain } from "electron"; -import { isDev, isMac, isWindows } from "./utils.js"; +import { formatDownloadTitle, isDev, isMac, isWindows } from "./utils.js"; import { fileURLToPath } from "url"; import { dirname } from "path"; @@ -47,13 +47,18 @@ ipcMain.on("create-extra-window", (event, arg) => { createExtraWindow(arg.extraWindowHash); }); -ipcMain.on("export-as-pdf", async (e) => { +interface ExportAsPdfOpts { + title: string; +} + +ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => { const browserWindow = BrowserWindow.fromWebContents(e.sender); if (!browserWindow) { return; } const filePath = dialog.showSaveDialogSync(browserWindow, { + defaultPath: formatDownloadTitle(opts.title, "file", "application/pdf"), filters: [ { name: "PDF",