Skip to content

fix(core): render Table cell content through Portable Text pipeline#534

Merged
ascorbic merged 1 commit intoemdash-cms:mainfrom
ttmx:fix/table-mark-rendering
Apr 14, 2026
Merged

fix(core): render Table cell content through Portable Text pipeline#534
ascorbic merged 1 commit intoemdash-cms:mainfrom
ttmx:fix/table-mark-rendering

Conversation

@ttmx
Copy link
Copy Markdown
Contributor

@ttmx ttmx commented Apr 13, 2026

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-portabletext pipeline with EmDash's mark components, so all marks work (bold, italic, code, underline, strikethrough, superscript, subscript, links) and links go through sanitizeHref(). Also switches table styles to CSS properties, making it compatible with dark mode.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation and pnpm locale:extract has been run (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion (internal gchat)

AI-generated code disclosure

  • This PR includes AI-generated code

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 #.

Copilot AI review requested due to automatic review settings April 13, 2026 16:49
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: 61d786b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/plugin-embeds Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 13, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@534

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@534

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@534

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@534

emdash

npm i https://pkg.pr.new/emdash@534

create-emdash

npm i https://pkg.pr.new/create-emdash@534

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@534

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@534

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@534

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@534

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@534

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@534

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@534

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@534

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@534

commit: 61d786b

@ttmx
Copy link
Copy Markdown
Contributor Author

ttmx commented Apr 13, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Apr 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PortableText using 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.

Comment on lines +44 to +48
const markComponents = {
mark: {
link: LinkMark,
underline: UnderlineMark,
"strike-through": StrikeThroughMark,
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly fair, should it be done?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

@ttmx ttmx force-pushed the fix/table-mark-rendering branch from b7d1da2 to 43f2ff6 Compare April 13, 2026 17:04
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.
@ttmx ttmx force-pushed the fix/table-mark-rendering branch from 43f2ff6 to 61d786b Compare April 14, 2026 09:08
@ttmx ttmx requested a review from Copilot April 14, 2026 09:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ascorbic ascorbic merged commit ce873f8 into emdash-cms:main Apr 14, 2026
28 of 30 checks passed
@emdashbot emdashbot bot mentioned this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants