feat: add conditional caching and allow-same-origin to file preview, add PreviewHtmlButton

This commit is contained in:
Chris Scott committed 2026-06-20 20:52:08 -04:00
1 parent 7f9403ce5e
commit ba08f5c24a
10 files changed
+155 -63

No files matched your search

+4 -6
View File
@@ -6,6 +6,7 @@ import rehypeRaw from 'rehype-raw'
import mermaid from 'mermaid'
import { Maximize2, X, AlertCircle } from 'lucide-react'
import { CopyButton } from '@/components/ui/copy-button'
import { PreviewHtmlButton } from '@/components/html-preview/PreviewHtmlButton'
import type { components } from '@/api/opencode-types'
import type { OpenHtmlArtifactInput } from '@/lib/htmlArtifacts'
import { useTheme } from '@/hooks/useTheme'
@@ -181,13 +182,10 @@ function CodeBlock({ children, className, onHtmlArtifactOpen, ...props }: CodeBl
</pre>
<div className="absolute top-2 right-2 flex gap-1">
{isHtmlCode && onHtmlArtifactOpen && (
<button
<PreviewHtmlButton
onClick={() => onHtmlArtifactOpen({ source: 'inline', html: codeContent, title: 'HTML artifact' })}
className="p-1.5 rounded bg-card hover:bg-card-hover text-muted-foreground hover:text-foreground text-xs"
title="Preview HTML artifact"
>
Preview HTML
</button>
className="p-1.5"
/>
)}
<CopyButton content={rawCodeContent} title="Copy code" />
</div>