diff --git a/src/App.css b/src/App.css index 53b97ba..3b3904d 100644 --- a/src/App.css +++ b/src/App.css @@ -1055,6 +1055,10 @@ table.not-prose th { } /* Print styles for clean PDF export */ +@page { + margin: 0.75in; +} + @media print { /* Disable all transitions to prevent color flashing after print */ *, @@ -1087,6 +1091,8 @@ table.not-prose th { height: auto !important; overflow: visible !important; max-height: none !important; + width: 100% !important; + max-width: 100% !important; border: none !important; border-top: none !important; border-bottom: none !important; @@ -1097,8 +1103,8 @@ table.not-prose th { padding: 0 !important; } - /* Hide sidebar - target the first flex child that contains Sidebar */ - #root > div > div:first-child { + /* Hide sidebar when printing */ + [data-sidebar] { display: none !important; } @@ -1118,26 +1124,10 @@ table.not-prose th { display: none !important; } - /* Hide the toolbar div with drag region */ - [data-tauri-drag-region] { - display: none !important; - visibility: hidden !important; - opacity: 0 !important; - height: 0 !important; - max-height: 0 !important; - margin: 0 !important; - padding: 0 !important; - position: absolute !important; - pointer-events: none !important; - overflow: hidden !important; - } - - /* Hide format bar by targeting its wrapper */ - .flex-1 > div:has(> div[class*="border-b"]) { + /* Hide toolbar and format bar when printing */ + [data-tauri-drag-region], + [data-format-bar] { display: none !important; - height: 0 !important; - max-height: 0 !important; - overflow: hidden !important; } /* Make editor container expand for printing */ @@ -1146,20 +1136,35 @@ table.not-prose th { height: auto !important; } - /* Make editor full width for printing */ + /* The editor content area and scroll container use absolute positioning + which collapses to zero height in print. Switch to static flow. */ + [data-editor-content-area] { + position: static !important; + overflow: visible !important; + height: auto !important; + } + + [data-editor-scroll] { + position: static !important; + overflow: visible !important; + height: auto !important; + } + + /* Make editor full width for printing and remove editor padding */ .ProseMirror { max-width: 100% !important; padding: 0 !important; margin: 0 !important; overflow: visible !important; height: auto !important; + overflow-wrap: break-word !important; } - /* Add padding to prose content for proper margins */ .prose { max-width: 100% !important; - padding: 0.75in 1in !important; + padding: 0 !important; margin: 0 !important; + overflow-wrap: break-word !important; } /* Ensure page breaks work well */ @@ -1176,8 +1181,6 @@ table.not-prose th { p, blockquote, pre, - ul, - ol, table { page-break-inside: avoid; break-inside: avoid; @@ -1233,6 +1236,10 @@ table.not-prose th { table { border: 1px solid #d0d0d0 !important; border-collapse: collapse !important; + width: 100% !important; + max-width: 100% !important; + table-layout: fixed !important; + overflow-wrap: break-word !important; } th, diff --git a/src/App.tsx b/src/App.tsx index 05cb953..6bbf132 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -279,12 +279,19 @@ function AppContent() { } // Cmd+P - Open command palette - if ((e.metaKey || e.ctrlKey) && e.key === "p") { + if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.key === "p") { e.preventDefault(); setPaletteOpen(true); return; } + // Cmd+Shift+P - Print + if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "p") { + e.preventDefault(); + window.dispatchEvent(new CustomEvent("print-note")); + return; + } + // Cmd+/ - Open keyboard shortcuts if ((e.metaKey || e.ctrlKey) && e.key === "/") { e.preventDefault(); @@ -464,6 +471,7 @@ function AppContent() { ) : ( <>
diff --git a/src/components/editor/Editor.tsx b/src/components/editor/Editor.tsx index 9135a8d..dcf0716 100644 --- a/src/components/editor/Editor.tsx +++ b/src/components/editor/Editor.tsx @@ -1856,14 +1856,19 @@ export function Editor({ if (!editor || !currentNote) return; try { await downloadPdf(editor, currentNote.title); - // Note: window.print() opens the print dialog but doesn't wait for user action - // No success toast needed - the print dialog provides its own feedback } catch (error) { console.error("Failed to open print dialog:", error); toast.error("Failed to open print dialog"); } }, [editor, currentNote]); + // Listen for Cmd+P print shortcut + useEffect(() => { + const handler = () => handleDownloadPdf(); + window.addEventListener("print-note", handler); + return () => window.removeEventListener("print-note", handler); + }, [handleDownloadPdf]); + const handleDownloadMarkdown = useCallback(async () => { if (!editor || !currentNote) return; try { @@ -2354,6 +2359,7 @@ export function Editor({ {/* Format Bar – transition only after initial mount to avoid height animation on note load */}
{/* Editor content area with resize handles overlay */} -
+
{!focusMode && !sourceMode && ( )}
{ if (!editor) throw new Error("Editor not available"); - // Trigger native print dialog - // The user can choose "Save as PDF" in the print dialog window.print(); }