Repository navigation
fix(xl-typst-exporter): keep headings with the block that follows them - #3365
Conversation
Typst headings are sticky, but stickiness doesn't carry out of the block the exporter wraps every block in for its spacing, so a heading could be left alone at the bottom of a page. Make the wrapper block of a heading sticky, including headings with children or a background.
|
@notluquis is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
nperez0111
left a comment
There was a problem hiding this comment.
This is a nice QOL of change. Thanks @notluquis for the submission
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
Summary
In the Typst PDF export, make the spacing block that wraps a heading
sticky, so a heading is never left alone at the bottom of a page. Closes #3364.Rationale
wrapBlock→applyBlockPropswraps every block in#block(width: 100%, inset: …)for its spacing. Typst keeps a heading with the next block (headingis sticky by default) only while the heading is a direct child of the flow; inside the wrapper it isn't, so the wrapper can end a page on its own. Marking the wrappersticky: truerestores Typst's own behavior one level up.Measured with the default schema, mappings and options (A4), sweeping the number of short paragraphs before the heading:
At every other position the per-page text is identical before and after.
Changes
wrapBlockpassessticky: truetoapplyBlockPropsfor headings, on both paths: a heading without children, and a heading's own body when it has children.applyBlockPropsemitssticky: trueon the wrapper block when asked.wrapBackgroundblock of a heading with children stays non-sticky: the sticky block is the heading's own body inside it.Impact
Only heading wrappers change (
sticky: trueis added); no other block type, spacing or alignment changes. A heading now moves to the next page with the block that follows it, which can shift that one heading to the next page. Alignment wraps the sticky block from outside (#align(center)[#block(sticky: true, …)]); a raw Typst check confirmed a centered heading also stays with its content.Testing
testDocument.typsnapshot: 9 lines, all heading wrappers.sticky: true,.pnpm testinpackages/xl-typst-exporter: 14 pass, 1 fails both with and without this change ("spans merged table cells and emits a single multi-row header"), because it needs the built@blocknote/xl-typst-compilerwasm.pnpm lintreports the same 35 errors before and after (unresolved imports from workspace packages that weren't built locally);vp fmt --checkpasses.@blocknote/xl-typst-compiler0.57.0) before and after; see the screenshot.Screenshots/Video
Left: 0.57.0. Right: with this change.
Checklist
main.)Additional Notes
Found while exporting clinical documents with
@blocknote/xl-pdf-exporter; the app currently works around it by rewriting the generated source, which this change makes unnecessary.🤖 Generated with Claude Code
Summary by CodeRabbit