Repository navigation
feat(export): export the current document as an A4 PDF - #81
project820 wants to merge 3 commits into
Conversation
Adds File > Export as PDF... (Shift+Cmd+E). Renders the Markdown source with the preview's markdown-it config into a fixed light print document, prints it to A4 with a page-number footer in a hidden script-free window, and saves it atomically. Adds a pdf-export e2e runner to CI.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8789cad141
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }); | ||
|
|
||
| installDocumentLinkBackstop(ctx.preview.el, (url) => void window.api.openExternal(url)); | ||
| wirePdfExport(window.api, () => ctx.editor.getDoc(), ctx.setStatus); |
There was a problem hiding this comment.
Flush pending preview edits before exporting
If the user edits the rich preview and immediately invokes Export as PDF, the preview edit can still be waiting in the 350 ms synchronization debounce, but this callback reads CodeMirror directly without calling flushPendingPreviewToSource. The resulting PDF therefore omits edits that are visibly present in the current document; flush the preview into the canonical Markdown before rendering, and fail the export if that synchronization cannot complete.
AGENTS.md reference: AGENTS.md:L14-L14
Useful? React with 👍 / 👎.
…em (#79) Export now applies DOM-only rich-preview edits before rendering and fails without writing when the source cannot be synchronized. The menu label comes from the renderer's five-locale dictionaries and is rebuilt on locale change. The e2e runner covers both.
index.html ships lang=ko, so <html lang> does not reflect an English renderer locale; read the locale from the localized success status instead.
Adds File > Export as PDF… (⇧⌘E). It writes the current Markdown document to a PDF using the agreed defaults from #79:
Before exporting, the renderer applies any rich-preview edit still waiting for its sync to the Markdown source, the same flush the save path uses. If that sync fails, or saving is blocked during a close, the export stops and writes nothing. The renderer then renders the up-to-date Markdown with the preview's
markdown-itconfiguration. The main process opens a save dialog that defaults to<document name>.pdfnext to the document. It prints the HTML in a hidden window with JavaScript disabled, usingprintToPDF, and saves it withatomicWriteso a failed export leaves no partial file.The menu label comes from the renderer's five locale dictionaries and is rebuilt when the language changes. The status line also reports progress, success, or failure in all five locales.
Closes #79
Validation
test:pdf-export-e2e(added to CI) boots the app with a long Korean/English document, switches the renderer to the dark theme, and drives the menu path with a stubbed save dialog. It checks four scenarios:typecheck,test(2442 passed),build,knip,test:security-e2e,test:converter-e2e,test:html-export-direct,test:roundtrip-smoke, andtest:close-dialog-smokeall pass. The smoke run covers all 10 scenarios becausesrc/renderer/main.tschanged.npm audit --omit=dev --audit-level=highfails on existing dependency advisories; this PR adds no dependencies.