fix: print as PDF renders blank page#124
Conversation
Two issues caused Print as PDF to produce a blank page: 1. The editor scroll container uses absolute positioning (absolute inset-0) which collapses to zero height when print styles set the parent to height: auto. Fixed by adding data-editor-content-area and data-editor-scroll attributes and overriding to position: static in the print media query. 2. The sidebar-hiding rule (#root > div > div:first-child) also hid the entire editor in preview mode (files opened directly in Scratch), where the editor is the first child. Fixed by targeting a [data-sidebar] attribute instead of :first-child. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThis PR adjusts print/PDF layout through comprehensive CSS changes with page margins and width constraints, implements a Cmd/Ctrl+Shift+P keyboard shortcut for printing with custom event handling, modifies Cmd/Ctrl+P behavior to require Shift not pressed, and adds semantic data attributes to editor layout elements for print targeting. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Add @page margin (0.75in) for proper PDF margins and override editor padding (pt-8/pb-24/px-6) in print CSS to prevent stacking - Content exceeding printable area: add width constraints on containers, table-layout: fixed, and overflow-wrap: break-word - Allow lists (ul/ol) to break across pages to avoid large whitespace gaps - Hide format bar and toolbar via data attributes instead of fragile :has() selector that Tailwind v4 purges during build - Add Cmd+P keyboard shortcut for print (standard shortcut), move command palette to Cmd+Shift+P - Cmd+P and print menu work in both library notes and preview mode (files opened directly) - Show toast before print dialog noting preview margin quirk (WebKit renders @page margins differently in preview vs actual output); dismiss toast immediately when dialog closes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/App.css`:
- Around line 1123-1125: Replace deprecated usage of "word-break: break-word" by
removing it or setting "word-break: normal" and rely on the existing
"overflow-wrap: break-word" to achieve the desired behavior; update every
occurrence (e.g., the block containing "overflow-wrap: break-word !important;"
and the adjacent "word-break: break-word !important;" as well as the similar
blocks around the other reported locations) so Stylelint no longer flags the
deprecated value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 11e6c057-a739-4527-af83-f5ac38ce9ad7
📒 Files selected for processing (5)
src/App.csssrc/App.tsxsrc/components/editor/Editor.tsxsrc/components/preview/PreviewApp.tsxsrc/services/pdf.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/App.tsx
- src/components/editor/Editor.tsx
…rence Cmd+P now opens the command palette (more standard), Cmd+Shift+P triggers print. Also blocks the browser print dialog in preview mode and adds the print shortcut to the Settings > Shortcuts reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolve merge conflicts with shortcut centralization (lib/shortcuts.ts). Remove print toast and 150ms delay, remove deprecated word-break: break-word. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
erictli
left a comment
There was a problem hiding this comment.
@jordanlee - thanks for this fix (and for improving some of the existing code)! I resolved some conflicts with parallel PRs and removed the toast because I didn't feel it was necessary.
Summary
Cmd+P→ command palette (standard),Cmd+Shift+P→ print/export as PDFTest plan
Cmd+Shift+P— PDF renders with correct content and marginsCmd+Popens command palette in main appCmd+Pis blocked in preview mode (no browser print dialog)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Improvements