import * as React from 'react'; import type { SxProps } from '@mui/joy/styles/types'; import { Box, Button, Tooltip, Typography } from '@mui/joy'; import ContentCopyIcon from '@mui/icons-material/ContentCopy'; import WebIcon from '@mui/icons-material/Web'; import { copyToClipboard } from '~/common/util/clipboardUtils'; import type { HtmlBlock } from '../blocks.types'; import { OverlayButton, overlayButtonsActiveSx, overlayButtonsClassName, overlayButtonsSx } from '../OverlayButton'; import { RenderCodeHtmlIFrame } from '../code/RenderCodeHtmlIFrame'; // this is used by the blocks parser (for full text detection) and by the Code component (for inline rendering) export function heuristicIsBlockTextHTML(text: string): boolean { return [' text.startsWith(start)); } export function RenderHtmlResponse(props: { htmlBlock: HtmlBlock, sx?: SxProps }) { const [showHTML, setShowHTML] = React.useState(false); // remove the font* properties from sx const sx: any = props.sx || {}; for (const key in sx) if (key.startsWith('font')) delete sx[key]; const handleCopyToClipboard = (e: React.MouseEvent) => { e.stopPropagation(); copyToClipboard(props.htmlBlock.html, 'HTML'); }; return ( ${overlayButtonsClassName}`]: overlayButtonsActiveSx, ...sx, }} > {/* Highlighted Code / SVG render */} {showHTML ? : CAUTION - The content you are about to access is an HTML page. It is possible that an unauthorized entity is monitoring this connection and has generated this content. Please exercise caution and do not trust the contents blindly. Be aware that proceeding may pose potential risks. Click the button to view the content, if you wish to proceed. } {/* External HTML Buttons */} setShowHTML(!showHTML)}> ); }