fix(core): render Table cell content through Portable Text pipeline#534
fix(core): render Table cell content through Portable Text pipeline#534ascorbic merged 1 commit intoemdash-cms:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 61d786b The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
All contributors have signed the CLA ✍️ ✅ |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Pull request overview
Updates the core Portable Text Table block renderer so table cell content is rendered through the astro-portabletext pipeline (restoring inline marks/links handling), and adjusts table styling to use themeable CSS custom properties with fallbacks.
Changes:
- Render table header/body cell content via
PortableTextusing EmDash mark components (incl. sanitized links). - Add a helper to wrap cell inline spans into a Portable Text block structure.
- Replace hard-coded table colors with CSS custom properties and remove default paragraph margins inside cells.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const markComponents = { | ||
| mark: { | ||
| link: LinkMark, | ||
| underline: UnderlineMark, | ||
| "strike-through": StrikeThroughMark, |
There was a problem hiding this comment.
markComponents duplicates the mark mapping already defined in emdashComponents.mark (packages/core/src/components/index.ts:104-110). To avoid the two lists drifting over time, consider extracting a shared emdashMarkComponents (or similar) constant from a small module that both index.ts and Table.astro import.
There was a problem hiding this comment.
This is mostly fair, should it be done?
b7d1da2 to
43f2ff6
Compare
Table cells now render through the standard Portable Text pipeline instead of hand-rolling HTML. This gives cells all registered mark components (bold, italic, links, code, superscript, etc.) with proper sanitization via sanitizeHref for link marks. CSS uses custom properties with fallbacks for site theming.
43f2ff6 to
61d786b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What does this PR do?
The Table block component was rendering cell content as plain text, stripping all marks. This rewrites it to render cells through the
astro-portabletextpipeline with EmDash's mark components, so all marks work (bold, italic, code, underline, strikethrough, superscript, subscript, links) and links go throughsanitizeHref(). Also switches table styles to CSS properties, making it compatible with dark mode.Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runpnpm locale:extracthas been run (if applicable)AI-generated code disclosure
Testing
Added a test page to the simple demo with hardcoded PT table data covering all mark types and a
javascript:href XSS attempt. All marks rendered correctly and the XSS link was sanitized to#.