Skip to content

feat: Add HTML preview button for code blocks#35

Merged
qduc merged 2 commits intomainfrom
claude/add-html-preview-button-Iby4j
Dec 27, 2025
Merged

feat: Add HTML preview button for code blocks#35
qduc merged 2 commits intomainfrom
claude/add-html-preview-button-Iby4j

Conversation

@qduc
Copy link
Copy Markdown
Owner

@qduc qduc commented Dec 27, 2025

Add a preview button that appears on HTML code blocks containing full HTML pages.
When clicked, it opens a modal with an iframe to render the HTML securely.

Changes:

  • Add Eye icon import from lucide-react for preview button
  • Add Modal component import for preview popup
  • Add state management for HTML preview modal
  • Add helper function to detect full HTML pages (checks for DOCTYPE, html tags, or head/body tags)
  • Add preview button in code block header (conditionally shown for HTML pages)
  • Add modal with iframe for secure HTML rendering using srcDoc
  • Use sandbox attribute on iframe for security (allow-scripts allow-same-origin)

The preview button appears alongside existing code block actions (wrap, copy, collapse)
and uses the existing Modal component with a larger max-width (max-w-6xl) for better viewing.

Add a preview button that appears on HTML code blocks containing full HTML pages.
When clicked, it opens a modal with an iframe to render the HTML securely.

Changes:
- Add Eye icon import from lucide-react for preview button
- Add Modal component import for preview popup
- Add state management for HTML preview modal
- Add helper function to detect full HTML pages (checks for DOCTYPE, html tags, or head/body tags)
- Add preview button in code block header (conditionally shown for HTML pages)
- Add modal with iframe for secure HTML rendering using srcDoc
- Use sandbox attribute on iframe for security (allow-scripts allow-same-origin)

The preview button appears alongside existing code block actions (wrap, copy, collapse)
and uses the existing Modal component with a larger max-width (max-w-6xl) for better viewing.
@qduc qduc merged commit a42ab4f into main Dec 27, 2025
3 checks passed
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.

2 participants