Repository navigation
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Priority: Severity of issue fixed: Medium 🚥 Pre-merge checks | ✅ 5
Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — the fix works. Minor suggestions inline.
Reviewed changes
- Print-only SVG height cap — adds
.orca-export-root svg { max-height: 10.19in; }to the@media printblock inexport-css.ts, capping tall Mermaid SVGs to the A4 printable box so they can be placed on a page instead of forcing a blank page before the preceding heading. - Regression test — asserts the literal rule string is present in the built export HTML.
I reproduced the original bug and confirmed the fix in headless Chromium with the real EXPORT_CSS, A4 plus 0.75in margins: the uncapped stylesheet produced blank pages, the capped one produced none, and the rendered drawing kept its viewBox aspect ratio exactly (no squash). One note on the chosen cap value is inline.
ℹ️ Nitpicks
- The test at
markdown-export-html.test.ts:39matches the rule as an exact, whitespace-sensitive string and cannot exercise print layout. That mirrors the file's existing style, so it's optional, but asserting the rule sits inside the@media printblock (or matching a looser pattern) would let it survive reformatting. - The same
page-break-inside: avoidpath applies toimg,pre, andtable; a portrait image taller than the page reproduces the blank-page bug. Out of scope for this issue, but worth a follow-up if tall images show the same symptom.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
b235646 to
6581aee
Compare
Sync update (
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Lowered the print SVG cap —
export-css.ts:143now usesmax-height: 9.5ininstead of10.19in, reserving roughly 0.69in so a preceding heading can share the page with a tall diagram rather than being orphaned onto a heading-only page. - Documented the cap derivation — the comment now states that A4 minus the PDF margins is
10.19in, so the value tracks the geometry owned bysrc/main/lib/html-to-pdf.ts:67. - Updated the regression test — asserts the new literal rule string, consistent with the file's existing assertions.
The change directly addresses the prior inline note: 9.5in was the measured value that kept each heading with its diagram in the headless-Chromium repro, and the reasoning is now in the comment. The mechanism is unchanged from what was already validated, so no new review of the rendering behavior was needed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
21a33bb to
b12ac04
Compare
b12ac04 to
203077d
Compare
[Low impact] Adjusts print styling for exported diagrams. The PR should not merge until the height cap reliably accommodates the preceding heading in the pagination case it is intended to fix. Findings
SummaryThis PR adds a print-media height limit for exported SVGs to scale tall Mermaid diagrams within an A4 PDF page and adds a regression assertion for the generated stylesheet.
Reviews (1) · Last reviewed commit: "fix(export): leave room for PDF diagram ..." · Reviewed by Greptile |
| @media print { | ||
| pre, code, table, img, svg { page-break-inside: avoid; } | ||
| /* Why: A4 minus the PDF margins is 10.19in, so reserve heading space to keep a tall diagram on its page. */ | ||
| .orca-export-root svg { max-height: 9.5in; } |
There was a problem hiding this comment.
The 9.5-inch cap leaves only 0.69 inches of the 10.19-inch printable area for the preceding heading. The existing heading styles require more space for common headings: a one-line h1, for example, occupies about 1.2 inches including its margins. A maximum-height diagram therefore still cannot share a page with an h1, h2, or h3 despite page-break-after: avoid, so Chromium may separate the heading or reproduce the blank-page pagination this change is intended to prevent. Reserve enough space for the largest supported heading and test the combined heading-and-diagram layout rather than only the CSS string.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Keep the existing copy button and annotation wrapper while checking the original HAST code class. This removes the extra empty page reproduced in Markdown Preview PDF export without shrinking labels. Credit gum798 for #21310 and #21377, innocarpe for #21328, and m13v for the label-readability review. The height-cap proposals were evaluated but this fix keeps the existing diagram sizing.
Keep the existing copy button and annotation wrapper while checking the original HAST code class. This removes the extra empty page reproduced in Markdown Preview PDF export without shrinking labels. Credit gum798 for #21310 and #21377, innocarpe for #21328, and m13v for the label-readability review. The height-cap proposals were evaluated but this fix keeps the existing diagram sizing.
* Render Mermaid Preview outside its code pre wrapper Keep the existing copy button and annotation wrapper while checking the original HAST code class. This removes the extra empty page reproduced in Markdown Preview PDF export without shrinking labels. Credit gum798 for #21310 and #21377, innocarpe for #21328, and m13v for the label-readability review. The height-cap proposals were evaluated but this fix keeps the existing diagram sizing. * fix(editor): keep a diagram's copy button beside its expand button Trim the wrapper test to the regression cases and mock the runtime target hook main now uses.
|
Thanks for this. The blank page before a tall Mermaid diagram was fixed in #25621 by removing the extra |
Keep the existing copy button and annotation wrapper while checking the original HAST code class. This removes the extra empty page reproduced in Markdown Preview PDF export without shrinking labels. Credit gum798 for stablyai#21310 and stablyai#21377, innocarpe for stablyai#21328, and m13v for the label-readability review. The height-cap proposals were evaluated but this fix keeps the existing diagram sizing.

What this changes
Mermaid diagrams in exported Markdown PDFs now receive a printable-height limit in print media. The limit preserves the SVG aspect ratio while allowing a diagram taller than the A4 content area to scale down instead of forcing the browser to move it to a new page and leave a blank page behind the preceding heading.
Why
webContents.printToPDF()uses A4 paper with 0.75-inch margins, leaving a printable height of about 10.19 inches. Export CSS already avoids breaking inside SVGs and constrains their width, but an unusually tall Mermaid SVG could fit on no page. The heading'spage-break-after: avoidthen made the page before the diagram completely blank.Linked issue
Fixes #21310
Testing
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/editor/markdown-export-html.test.tspnpm run typecheck:webORCA_CODE_QUALITY_BASE=upstream/main pnpm run check:code-quality:changedpnpm exec oxfmt --check src/renderer/src/components/editor/export-css.ts src/renderer/src/components/editor/markdown-export-html.test.tsAI disclosure
Implemented with AI assistance and reviewed against the existing PDF export margins and stylesheet behavior.
Checklist