mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	feat(pdf): suggest proper file name
This commit is contained in:
		| @@ -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 }) { | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user