Skip to content

fix: render proper HTML tags for CMS-bound rich text on canvas#71

Merged
liamwalder merged 2 commits intodevelopfrom
fix/rich-text-cms-canvas-tags
Mar 24, 2026
Merged

fix: render proper HTML tags for CMS-bound rich text on canvas#71
liamwalder merged 2 commits intodevelopfrom
fix/rich-text-cms-canvas-tags

Conversation

@lunenas
Copy link
Copy Markdown
Collaborator

@lunenas lunenas commented Mar 20, 2026

Summary

Fix canvas rendering of CMS-bound rich text fields where all block elements (headings, paragraphs, lists) were incorrectly rendered as <span> instead of their proper HTML tags. Also fix the layers tree not showing the collapse arrow for CMS-bound rich text layers.

Closes #69

Changes

  • Propagate useSpanForParagraphs flag through renderInlineContent and renderNestedRichTextContent instead of hardcoding true
  • Rich text layers (<div>) now render CMS content with proper block tags (<h1>, <p>, etc.)
  • Restrictive tags (<p>, headings) still use <span> to avoid invalid HTML nesting
  • Add hasRichTextContent() helper that detects CMS field bindings for collapsibility without requiring resolved data
  • Use hasRichTextContent() in LayersTree for collapse arrow visibility

Test plan

  • Create a CMS page with a rich text layer bound to a rich-text field
  • Verify headings render as <h1>-<h6>, paragraphs as <p>, lists as <ul>/<ol> on the canvas
  • Verify no <p> cannot be a descendant of <p> console errors
  • Verify the rich text layer shows the collapse arrow in the layers tree when bound to a CMS field
  • Verify expanding the layer shows the correct sublayers from the CMS content
  • Verify non-CMS rich text layers still work correctly (proper tags, collapsible)
  • Verify a <p> text layer bound to a rich-text CMS field still uses <span> (no nesting errors)

Made with Cursor

Closes #69

CMS rich-text field content rendered all elements as <span> on the
canvas because renderNestedRichTextContent always forced spans. Now
the useSpanForParagraphs flag propagates correctly: rich text layers
(div) get proper block tags, while restrictive tags (p, h1-h6) keep
spans to avoid invalid nesting. Also fix layers tree collapsibility
for CMS-bound rich text layers.

Made-with: Cursor
@liamwalder liamwalder merged commit f130f17 into develop Mar 24, 2026
2 checks passed
@liamwalder liamwalder deleted the fix/rich-text-cms-canvas-tags branch March 24, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: wrong HTML tags in canvas for rich-text

2 participants