mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-13 04:13:19 +08:00
feat(pdf): suggest proper file name
This commit is contained in:
parent
414a4d7b17
commit
615218513a
@ -298,7 +298,9 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { ipcRenderer } = utils.dynamicRequire("electron");
|
const { ipcRenderer } = utils.dynamicRequire("electron");
|
||||||
ipcRenderer.send("export-as-pdf");
|
ipcRenderer.send("export-as-pdf", {
|
||||||
|
title: this.note.title
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
hoistedNoteChangedEvent({ ntxId }) {
|
hoistedNoteChangedEvent({ ntxId }) {
|
||||||
|
@ -10,7 +10,7 @@ import keyboardActionsService from "./keyboard_actions.js";
|
|||||||
import remoteMain from "@electron/remote/main/index.js";
|
import remoteMain from "@electron/remote/main/index.js";
|
||||||
import { BrowserWindow, type App, type BrowserWindowConstructorOptions, type WebContents } from "electron";
|
import { BrowserWindow, type App, type BrowserWindowConstructorOptions, type WebContents } from "electron";
|
||||||
import { dialog, ipcMain } 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 { fileURLToPath } from "url";
|
||||||
import { dirname } from "path";
|
import { dirname } from "path";
|
||||||
@ -47,13 +47,18 @@ ipcMain.on("create-extra-window", (event, arg) => {
|
|||||||
createExtraWindow(arg.extraWindowHash);
|
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);
|
const browserWindow = BrowserWindow.fromWebContents(e.sender);
|
||||||
if (!browserWindow) {
|
if (!browserWindow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filePath = dialog.showSaveDialogSync(browserWindow, {
|
const filePath = dialog.showSaveDialogSync(browserWindow, {
|
||||||
|
defaultPath: formatDownloadTitle(opts.title, "file", "application/pdf"),
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "PDF",
|
name: "PDF",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user