Implement native print dialog for PDF export

- Replaced jsPDF client-side generation with Tauri's native print dialog
- Created PrintView component that renders note content in a print-optimized layout
- Added print-export window capability with webview creation and print permissions
- Implemented event-based communication between main window and print window
- Moved shared print/export utilities to printExport.ts (title extraction, filename sanitization)
- Changed export button icon from download
This commit is contained in:
drelich
2026-04-05 21:30:31 +02:00
parent f5b448808d
commit 42eec85826
5 changed files with 499 additions and 156 deletions

28
src/printExport.ts Normal file
View File

@@ -0,0 +1,28 @@
export interface PrintExportPayload {
fileName: string;
title: string;
html: string;
previewFont: string;
previewFontSize: number;
}
export const PRINT_EXPORT_QUERY_PARAM = 'printJob';
const PRINT_EXPORT_STORAGE_PREFIX = 'print-export:';
export const getPrintExportStorageKey = (jobId: string) =>
`${PRINT_EXPORT_STORAGE_PREFIX}${jobId}`;
export const getNoteTitleFromContent = (content: string) => {
const firstLine = content
.split('\n')
.map((line) => line.trim())
.find((line) => line.length > 0);
return (firstLine || 'Untitled').replace(/^#+\s*/, '').trim();
};
export const sanitizeFileName = (name: string) =>
name
.replace(/[\\/:*?"<>|]/g, '-')
.replace(/\s+/g, ' ')
.trim() || 'note';