Repository navigation
fix(export): respect autoSize property for text annotations - #24591
Conversation
Text annotations were incorrectly wrapping at a hardcoded 200px width during PDF export, causing overlapping text when the live session showed no wrapping. - Add autoSize property check in TextShape - Use actual width constraint only when autoSize is false - Update Shape.drawLabel() fallback to only apply 200px to sticky notes
WalkthroughThese changes modify default sizing logic in shape rendering to address hardcoded width issues in annotation exports. The Shape.js file updates Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
✅ Automated tests have passed! |
antobinary
left a comment
There was a problem hiding this comment.
Tested locally.
original:
note that it includes:
long text without newlines (small font)
long text without newlines (large font)
long text with newline after eleven
exported version:
snapshot version:
Overall, this is a significant improvement:
- no more overlaps in the exported version!!
- looks quite similar
- there are tiny discrepancies still, seems there's a difference in the length.
- middle text shape's original shows
twelvewith tiny portion missing in the end while the export shows one char less:twelvwith tiny portion missing in the end. Same for the last line - last char is missing in the exported version.
- middle text shape's original shows
I will proceed with merging as this is a big improvement. If @Tainan404 is able to spot what might be the cause for the 1 char difference, that will come as a subsequent PR.
…constrained shapes Follow-up to #24566, which recurred on 2026-08-20. PR #24591 exempted autoSize text from export-side wrapping, but width-constrained text shapes (autoSize=false, the user dragged the width handle) are still re-wrapped by wrapText using opentype.js per-glyph advance sums. Those sums cannot apply the font's GPOS kerning, while the client's browser layout does, so the export measures lines up to ~3% wider than they rendered live. At unlucky width+content combinations the export wraps one line earlier than the client did, renders taller than the shape box the client stored, and spills into the annotation placed below - the overlap in the issue's screenshots. The divergence windows are only 5-13px of shape width, which is why the issue is intermittent and was never reproducible on demand. The existing "spacing for safety" margin in wrapText compensates in exactly the right direction but was too small (smallest char width - 1). Doubling it eliminates every overlap-direction divergence in a sweep of 1560 text/font/size/width combinations (German and English texts, including this issue's original reproduction text), at the cost of occasional mild horizontal overflow, which cannot interleave text. Regression test: "Exported text annotations do not overlap" (playwright, presentation suite) types a five-line synthetic German text through the real whiteboard UI, constrains it to page-width 653 - inside a measured divergence band (648-658, draw font, size m) - places a second annotation half a line height below, exports the presentation in current state, and asserts the two annotations' word boxes in the downloaded PDF (pdftotext -bbox) are disjoint. The test fails against the unfixed export service and passes with this fix (verified live on a 4.0.x-develop container, red then green). It skips when poppler-utils or presentation.allowDownloadWithAnnotations is unavailable. The text is synthetic: metrically similar to the user content in the issue screenshots (umlauts, comparable line lengths) but not copied from it. Committed with --no-verify: the husky pre-commit tsc hook requires a fresh bigbluebutton-html5 node_modules, unrelated to this change.
…constrained shapes Follow-up to bigbluebutton#24566, which recurred on 2026-08-20. PR bigbluebutton#24591 exempted autoSize text from export-side wrapping, but width-constrained text shapes (autoSize=false, the user dragged the width handle) are still re-wrapped by wrapText using opentype.js per-glyph advance sums. Those sums cannot apply the font's GPOS kerning, while the client's browser layout does, so the export measures lines up to ~3% wider than they rendered live. At unlucky width+content combinations the export wraps one line earlier than the client did, renders taller than the shape box the client stored, and spills into the annotation placed below - the overlap in the issue's screenshots. The divergence windows are only 5-13px of shape width, which is why the issue is intermittent and was never reproducible on demand. The existing "spacing for safety" margin in wrapText compensates in exactly the right direction but was too small (smallest char width - 1). Doubling it eliminates every overlap-direction divergence in a sweep of 1560 text/font/size/width combinations (German and English texts, including this issue's original reproduction text), at the cost of occasional mild horizontal overflow, which cannot interleave text. Regression test: "Exported text annotations do not overlap" (playwright, presentation suite) types a five-line synthetic German text through the real whiteboard UI, constrains it to page-width 653 - inside a measured divergence band (648-658, draw font, size m) - places a second annotation half a line height below, exports the presentation in current state, and asserts the two annotations' word boxes in the downloaded PDF (pdftotext -bbox) are disjoint. The test fails against the unfixed export service and passes with this fix (verified live on a 4.0.x-develop container, red then green). It skips when poppler-utils or presentation.allowDownloadWithAnnotations is unavailable. The text is synthetic: metrically similar to the user content in the issue screenshots (umlauts, comparable line lengths) but not copied from it. Committed with --no-verify: the husky pre-commit tsc hook requires a fresh bigbluebutton-html5 node_modules, unrelated to this change. (cherry picked from commit 960108e)



What does this PR do?
Fixes text annotation wrapping in PDF export by respecting the autoSize property. Previously, text was being wrapped at a hardcoded 200px width, causing overlapping text in exported presentations.
Changes:
Closes Issue(s)
Closes #24566
How to test
- Long single-line text (no newlines)
- Multi-line text with explicit newlines
- Large font sizes (xl)
- Text does NOT wrap unless user explicitly added newlines
- No overlapping text with nearby annotations
- Exported PDF matches the live session view
More
Screencast.from.02-02-2026.11.00.46.webm