Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
"use client";
/**
* HtmlPreviewBody — an HTML document in the sandboxed preview iframe, for the
* attachment viewer's html kind (the caller has already fetched the text).
*
* Owns the three things every HTML attachment preview needs:
*
* - srcDoc + sandbox="allow-scripts" via CodeBlockIframe
* - withFragmentNavShim() so anchor links inside the iframe scroll instead
* of silently failing in the sandbox's opaque origin
* - the address bridge, so the document loads at the address bar's
* address (`location`, owned by the stage — useHtmlPreviewLocation)
*
* A ```html block in a message body is a dynamic block instead
* (html-block-preview.tsx): it adds theme tokens and a size/error bridge.
*/
import { CodeBlockIframe } from "./code-block-iframe";
import type { HtmlPreviewLocation } from "./hooks/use-html-preview-location";
import { withFragmentNavShim } from "./utils/iframe-fragment-nav";
interface HtmlPreviewBodyProps {
html: string;
/** iframe title attribute (a11y). */
title: string;
location: HtmlPreviewLocation;
/** Tailwind height/sizing classes for the iframe (e.g. "h-full"). */
className?: string;
/** Override iframe styling (border / radius). Tailwind-merge resolves
* conflicts so callers can pass "rounded-none border-0" for full-screen. */
iframeClassName?: string;
}
export function HtmlPreviewBody({
html,
title,
location,
className,
iframeClassName,
}: HtmlPreviewBodyProps) {
return (
<CodeBlockIframe
// A new frame for every fresh load at a new address.
key={location.frameKey}
ref={location.frameRef}
html={location.withAddress(withFragmentNavShim(html))}
title={title}
heightClassName={className}
className={iframeClassName}
/>
);
}