fix(xl-pdf-exporter): fix emoji rendering for ZWJ sequences in PDF export#2871
fix(xl-pdf-exporter): fix emoji rendering for ZWJ sequences in PDF export#2871nperez0111 wants to merge 1 commit into
Conversation
…port Switch from archived Twemoji 14.0.2 CDN to jdecked/twemoji v17.0.3 and use a builder function that correctly handles variation selectors (fe0f) in ZWJ emoji sequences like 🚶♀️ and 🏃♀️. Fixes #1978
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe default PDF Exporter Emoji Source
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@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
commit: |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx (1)
100-108: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPlease add regression coverage for this normalization branch.
The
200d/fe0frewrite is easy to regress. Add explicit cases inpackages/xl-pdf-exporter/src/pdf/pdfExporter.test.tsxfor at least one ZWJ sequence and one standalone variation-selector emoji so future CDN/version bumps do not silently reintroduce 404s.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx` around lines 100 - 108, Add regression tests for the Twemoji normalization logic in pdfExporter.tsx. Update pdfExporter.test.tsx to cover both branches of the builder function: one ZWJ sequence containing 200d should keep fe0f intact, and one standalone emoji with fe0f should strip it before building the CDN URL. Use the existing pdfExporter builder behavior as the target so future CDN or version changes do not break this normalization silently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx`:
- Around line 100-108: Add regression tests for the Twemoji normalization logic
in pdfExporter.tsx. Update pdfExporter.test.tsx to cover both branches of the
builder function: one ZWJ sequence containing 200d should keep fe0f intact, and
one standalone emoji with fe0f should strip it before building the CDN URL. Use
the existing pdfExporter builder behavior as the target so future CDN or version
changes do not break this normalization silently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a247c4e4-f9d1-4101-8147-5d0b0ba9a7a3
📒 Files selected for processing (1)
packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx
Summary
Fix PDF export failures for emojis that use ZWJ (Zero Width Joiner) sequences, such as 🚶♀️ and 🏃♀️.
Fixes #1978
Rationale
The PDF exporter used
@react-pdf/renderer'sFont.registerEmojiSource()with a simple URL pointing to the archived Twemoji 14.0.2 CDN. React-pdf strips variation selectors (U+FE0F) from emoji codepoints by default, but Twemoji filenames for ZWJ sequences requirefe0f— causing 404s when fetching emoji images during export.Changes
builderfunction withwithVariationSelectors: true, which correctly preservesfe0fin ZWJ sequences while stripping it for standalone emojis (matching Twemoji's naming convention).jdecked/twemojiv17.0.3 on jsDelivr — the actively maintained fork with Unicode 16 support.Impact
emojiSourcewith their own config are unaffected.Testing
xl-pdf-exportertests pass.Checklist
Summary by CodeRabbit