import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import ReactMarkdown, { defaultUrlTransform } from "react-markdown"; import remarkGfm from "remark-gfm"; // react-markdown's default transform only keeps http(s)/irc(s)/mailto/xmpp // URLs, which would strip the inline `data:image/...` sources the markdown // serializer produces for attachments. Allow exactly those data images and // defer everything else to the default sanitization. Raw HTML embedded in // message text stays inert because react-markdown ignores html nodes. // // The allow-list is raster subtypes only, not a bare `data:image/` prefix: // an image block's mimeType comes from unvalidated message content (tool // output, a collaborator's message), so a `data:image/svg+xml` source could // otherwise reach the text/html clipboard flavor verbatim — SVG is an XML // document that can carry