diff --git a/src/components/editor/file-preview.tsx b/src/components/editor/file-preview.tsx index da8e5296..21d6628c 100644 --- a/src/components/editor/file-preview.tsx +++ b/src/components/editor/file-preview.tsx @@ -40,6 +40,8 @@ export function FilePreview({ filePath, textContent }: FilePreviewProps) { return case "audio": return + case "html": + return case "pdf": return case "code": @@ -254,6 +256,35 @@ function TextPreview({ filePath, content, label }: { filePath: string; content: ) } +function HtmlPreview({ filePath, content }: { filePath: string; content: string }) { + const iframeRef = useRef(null) + + useEffect(() => { + const iframe = iframeRef.current + if (!iframe) return + const doc = iframe.contentDocument + if (!doc) return + doc.open() + doc.write(content) + doc.close() + }, [content]) + + return ( +
+
+ {filePath} + HTML +
+