diff --git a/studio/frontend/src/components/assistant-ui/markdown-text.tsx b/studio/frontend/src/components/assistant-ui/markdown-text.tsx index d2c6208fda..c43e9383b1 100644 --- a/studio/frontend/src/components/assistant-ui/markdown-text.tsx +++ b/studio/frontend/src/components/assistant-ui/markdown-text.tsx @@ -3,6 +3,7 @@ "use client"; +import { ArtifactCard } from "@/features/chat"; import { copyToClipboard } from "@/lib/copy-to-clipboard"; import { preprocessLaTeX } from "@/lib/latex"; import { openLink } from "@/lib/open-link"; @@ -12,7 +13,7 @@ import { HugeiconsIcon } from "@hugeicons/react"; import { createCodePlugin } from "./code-plugin"; import { createMathPlugin } from "@streamdown/math"; import { mermaid } from "@streamdown/mermaid"; -import { DownloadIcon, Maximize2Icon, Minimize2Icon } from "lucide-react"; +import { DownloadIcon } from "lucide-react"; import { useEffect, useMemo, useRef, useState } from "react"; import { Block, type BlockProps, Streamdown } from "streamdown"; import "katex/dist/katex.min.css"; @@ -26,11 +27,7 @@ const code = createCodePlugin({ const { withSmoothContextProvider } = INTERNAL; const STREAMDOWN_COMPONENTS = { - a: ({ - href, - children, - ...props - }: React.ComponentProps<"a">) => ( + a: ({ href, children, ...props }: React.ComponentProps<"a">) => ( ]|on\w+\s*=|javascript:|]|]|]|]/i; +const UNSAFE_SVG_RE = + /]|on\w+\s*=|javascript:|]|]|]|]/i; function sanitizeSvg(source: string): string | null { if (UNSAFE_SVG_RE.test(source)) return null; @@ -145,96 +143,6 @@ function SvgPreview({ source }: { source: string }) { ); } -const HTML_PREVIEW_DEFAULT_HEIGHT = 400; -const HTML_PREVIEW_MAX_HEIGHT = 800; - -function HtmlPreview({ source }: { source: string }) { - const iframeRef = useRef(null); - const [height, setHeight] = useState(HTML_PREVIEW_DEFAULT_HEIGHT); - const [enlarged, setEnlarged] = useState(false); - - useEffect(() => { - const handler = (e: MessageEvent) => { - if (e.source !== iframeRef.current?.contentWindow) return; - if (typeof e.data?.htmlPreviewHeight === "number") { - setHeight(Math.min(Math.max(e.data.htmlPreviewHeight, 100), HTML_PREVIEW_MAX_HEIGHT)); - } - }; - window.addEventListener("message", handler); - return () => window.removeEventListener("message", handler); - }, []); - - useEffect(() => { - if (!enlarged) return; - const handler = (e: KeyboardEvent) => { - if (e.key === "Escape") setEnlarged(false); - }; - window.addEventListener("keydown", handler); - return () => window.removeEventListener("keydown", handler); - }, [enlarged]); - - const resizeScript = ``; - - const srcDoc = source + resizeScript; - - if (enlarged) { - return ( - <> -
- {/* Placeholder keeps layout stable while overlay is shown */} -
-
{ if (e.target === e.currentTarget) setEnlarged(false); }} - > -
- -
-
-