@@ -6,13 +6,13 @@ import RehypeKatex from "rehype-katex";
66import RemarkGfm from "remark-gfm" ;
77import RehypeHighlight from "rehype-highlight" ;
88import { useRef , useState , RefObject , useEffect , useMemo } from "react" ;
9- import { copyToClipboard } from "../utils" ;
9+ import { copyToClipboard , useWindowSize } from "../utils" ;
1010import mermaid from "mermaid" ;
1111
1212import LoadingIcon from "../icons/three-dots.svg" ;
1313import React from "react" ;
1414import { useDebouncedCallback } from "use-debounce" ;
15- import { showImageModal } from "./ui-lib" ;
15+ import { showImageModal , FullScreen } from "./ui-lib" ;
1616import { ArtifactShareButton , HTMLPreview } from "./artifact" ;
1717
1818export function Mermaid ( props : { code : string } ) {
@@ -66,6 +66,7 @@ export function PreCode(props: { children: any }) {
6666 const refText = ref . current ?. innerText ;
6767 const [ mermaidCode , setMermaidCode ] = useState ( "" ) ;
6868 const [ htmlCode , setHtmlCode ] = useState ( "" ) ;
69+ const { height } = useWindowSize ( ) ;
6970
7071 const renderArtifacts = useDebouncedCallback ( ( ) => {
7172 if ( ! ref . current ) return ;
@@ -104,20 +105,17 @@ export function PreCode(props: { children: any }) {
104105 < Mermaid code = { mermaidCode } key = { mermaidCode } />
105106 ) }
106107 { htmlCode . length > 0 && (
107- < div
108- className = "no-dark html"
109- style = { {
110- overflow : "auto" ,
111- position : "relative" ,
112- } }
113- onClick = { ( e ) => e . stopPropagation ( ) }
114- >
108+ < FullScreen className = "no-dark html" right = { 60 } >
115109 < ArtifactShareButton
116110 style = { { position : "absolute" , right : 10 , top : 10 } }
117111 getCode = { ( ) => htmlCode }
118112 />
119- < HTMLPreview code = { htmlCode } />
120- </ div >
113+ < HTMLPreview
114+ code = { htmlCode }
115+ autoHeight = { ! document . fullscreenElement }
116+ height = { ! document . fullscreenElement ? 600 : height }
117+ />
118+ </ FullScreen >
121119 ) }
122120 </ >
123121 ) ;
0 commit comments