From 3d0a907b492cc5fd12fc740a96124a4d0529ca7a Mon Sep 17 00:00:00 2001 From: xiaodong zuo <53252747+zuoxiaodong0815@users.noreply.github.com> Date: Mon, 3 Jul 2023 20:11:07 +0800 Subject: [PATCH] fix: dark mode export PDF leaves margin and notification (#2978) --- apps/electron/src/main/export/pdf.ts | 7 +++++ .../page-list/operation-menu-items/export.tsx | 28 +++++++++---------- packages/i18n/src/resources/en.json | 6 +++- packages/i18n/src/resources/zh-Hans.json | 6 +++- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/apps/electron/src/main/export/pdf.ts b/apps/electron/src/main/export/pdf.ts index 9748d98e88..ddb2fc661b 100644 --- a/apps/electron/src/main/export/pdf.ts +++ b/apps/electron/src/main/export/pdf.ts @@ -39,6 +39,13 @@ export async function savePDFFileAs( await BrowserWindow.getFocusedWindow() ?.webContents.printToPDF({ + margins: { + marginType: 'custom', + top: 0, + bottom: 0, + left: 0, + right: 0, + }, pageSize: 'A4', printBackground: true, landscape: false, diff --git a/packages/component/src/components/page-list/operation-menu-items/export.tsx b/packages/component/src/components/page-list/operation-menu-items/export.tsx index c86fc8b7c1..5c6fb21e90 100644 --- a/packages/component/src/components/page-list/operation-menu-items/export.tsx +++ b/packages/component/src/components/page-list/operation-menu-items/export.tsx @@ -38,8 +38,8 @@ const ExportToPdfMenuItem = ({ onSelect?.({ type: 'pdf' }); setPushNotification({ key: 'export-to-pdf', - title: 'export', - message: 'Export success', + title: t['com.affine.export.success.title'](), + message: t['com.affine.export.success.message'](), type: 'success', }); }) @@ -47,8 +47,8 @@ const ExportToPdfMenuItem = ({ console.error(err); setPushNotification({ key: 'export-to-pdf', - title: 'export', - message: 'Export error', + title: t['com.affine.export.error.title'](), + message: t['com.affine.export.error.message'](), type: 'error', }); }); @@ -63,8 +63,8 @@ const ExportToPdfMenuItem = ({ onSelect?.({ type: 'pdf' }); setPushNotification({ key: 'export-to-pdf', - title: 'export', - message: 'Export success', + title: t['com.affine.export.success.title'](), + message: t['com.affine.export.success.message'](), type: 'success', }); }) @@ -72,13 +72,13 @@ const ExportToPdfMenuItem = ({ console.error(err); setPushNotification({ key: 'export-to-pdf', - title: 'export', - message: 'Export error', + title: t['com.affine.export.error.title'](), + message: t['com.affine.export.error.message'](), type: 'error', }); }); } - }, [currentEditor, onSelect, setPushNotification]); + }, [currentEditor, onSelect, setPushNotification, t]); return ( diff --git a/packages/i18n/src/resources/en.json b/packages/i18n/src/resources/en.json index 3ec6c6e05c..fc24f49ab8 100644 --- a/packages/i18n/src/resources/en.json +++ b/packages/i18n/src/resources/en.json @@ -387,5 +387,9 @@ "Members hint": "Manage members here, invite new member by email.", "Workspace Settings with name": "{{name}}'s Settings", "com.affine.settings.workspace": "Workspace", - "com.affine.settings.appearance": "Appearance" + "com.affine.settings.appearance": "Appearance", + "com.affine.export.success.title": "Exported successfully", + "com.affine.export.success.message": "Please open the download folder to check.", + "com.affine.export.error.title": "Export failed due to an unexpected error", + "com.affine.export.error.message": "Please try it again later." } diff --git a/packages/i18n/src/resources/zh-Hans.json b/packages/i18n/src/resources/zh-Hans.json index 1f4e6eca0a..d3e5d8f926 100644 --- a/packages/i18n/src/resources/zh-Hans.json +++ b/packages/i18n/src/resources/zh-Hans.json @@ -388,5 +388,9 @@ "system": "跟随系统", "emptyAllPagesClient": "点击 <1>$t(New Page) 按钮或按 <3>{{shortcut}} 以创建您的第一个页面。", "frameless": "无边框", - "Export to PDF": "导出为 PDF" + "Export to PDF": "导出为 PDF", + "com.affine.export.success.title": "导出成功", + "com.affine.export.success.message": "请打开下载的文件夹查看。", + "com.affine.export.error.title": "导出失败", + "com.affine.export.error.message": "请稍后重试。" }