Skip to content

feat(export): Export to PDF — clean-copy print-to-PDF#64

Merged
sam-powers merged 2 commits into
mainfrom
feat/export-pdf
Jun 14, 2026
Merged

feat(export): Export to PDF — clean-copy print-to-PDF#64
sam-powers merged 2 commits into
mainfrom
feat/export-pdf

Conversation

@sam-powers

Copy link
Copy Markdown
Owner

Implements the Export to PDF for sharing backlog item (PRD §7): a one-shot export of the current document to PDF so it can be shared with people who don't have Quill.

Two design decisions, made with Sam up front:

  • Clean copy only — the PDF shows the finished document (pending suggestions rendered as accepted; comment/track-changes markup left out). A review copy (markup visible) is recorded as a deliberate, revisitable non-goal in PRD §7.
  • Webview print-to-PDF — reuse the editor's own DOM + typography through a print stylesheet and the OS print pipeline, rather than a second Markdown→HTML→PDF pipeline that would drift from the editor.

What's in it

  • File → Export to PDF… (Cmd+P) — new native menu item emitting menu-export-pdf, wired through App.tsx's menu-handler ref alongside the other File items. The non-native-menu path (dev/e2e) handles Cmd+P too, so it works in npm run dev.
  • handleExportPdf sets document.title to the document's name (so the OS dialog defaults the filename), calls window.print(), and restores the title after the synchronous dialog. On macOS the dialog's Save as PDF writes the file.
  • @media print block in App.css defines the artifact:
    • Hides all chrome (toolbar, footer, comment layer, find bar, update banner, modals).
    • Collapses the on-screen height:100vh / overflow:hidden scroll + zoom containers so content reflows and paginates naturally on paper; resets the screen zoom and the dashed page-break guide lines.
    • Clean copy of the markup: ins.track-insert → plain text, del.track-deletedisplay:none, comment/find/annotation-focus highlights stripped.
    • US Letter, 0.75in margins; the OS owns pagination.

Docs

  • PRD §3.5 documents the feature; §7 records review-copy export as a deliberate non-goal and drops the old "Export to PDF" backlog entry.
  • USER_GUIDE gets a one-line "Export to PDF" entry under The Basics.

Verification

typecheck, eslint, prettier, vitest (255), cargo fmt/clippy/test (35), and vite build all green locally.

⚠️ The printed artifact itself can't be asserted in CI (it's the OS print pipeline + a print stylesheet). It needs a manual print-preview pass in the Tauri app — confirm chrome is gone, deletions vanish, insertions read as plain text, and pagination looks right — before merge.

🤖 Generated with Claude Code

sam-powers and others added 2 commits June 14, 2026 11:14
…to PDF…)

A one-shot export of the current document to PDF for sharing with people
who don't have Quill (PRD §7 backlog item). Two decisions, made with Sam:
clean copy only, and the webview print-to-PDF rendering path (reuses the
editor's own typography, no second styling pipeline to drift).

How it works:
- New `File → Export to PDF…` native menu item (Cmd+P), emitting
  `menu-export-pdf`, wired through App's menu-handler ref like the other
  File items. The non-native-menu path (dev/e2e) handles Cmd+P too.
- `handleExportPdf` sets document.title to the doc's name (so the OS
  dialog defaults the filename) and calls window.print(); macOS offers
  "Save as PDF". Title is restored after the (synchronous) dialog.
- An `@media print` block in App.css defines the artifact: hide all chrome
  (toolbar, footer, comment layer, find bar, banners, modals); collapse
  the height:100vh / overflow:hidden scroll+zoom containers so content
  reflows and paginates on paper; reset the screen zoom and page-break
  guide lines. Clean copy of the suggesting-mode markup — insertions
  render as plain text, pending deletions (<del>) are display:none, and
  comment/find/focus highlights are stripped. US Letter, 0.75in margins;
  the OS owns pagination.

Docs: PRD §3.5 documents the feature and §7 records review-copy export as
a deliberate (revisitable) non-goal; USER_GUIDE gets a one-liner.

The printed artifact can't be asserted in CI; verified by build + the full
check bar, and needs a manual print-preview pass in the Tauri app.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Closes the CI gap for Export to PDF: the OS print dialog and the binary
PDF can't be driven in CI, but the artifact is defined entirely by the
`@media print` rules, so Playwright emulates print media and reads
computed styles to assert the clean-copy contract directly.

Three specs: app chrome (toolbar/footer/comment layer) goes display:none;
a tracked deletion is removed (<del> display:none) while a tracked
insertion renders as plain text (no decoration, no background); a comment
highlight loses its background and underline. Builds the markup through
the real editor (type → suggesting mode → delete/insert; select → comment)
rather than fixtures.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sam-powers sam-powers merged commit d7b5ae6 into main Jun 14, 2026
3 checks passed
@sam-powers sam-powers deleted the feat/export-pdf branch June 14, 2026 16:57
@sam-powers sam-powers mentioned this pull request Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant