@@ -6,13 +6,13 @@ import RehypeKatex from "rehype-katex";
6
6
import RemarkGfm from "remark-gfm" ;
7
7
import RehypeHighlight from "rehype-highlight" ;
8
8
import { useRef , useState , RefObject , useEffect , useMemo } from "react" ;
9
- import { copyToClipboard } from "../utils" ;
9
+ import { copyToClipboard , useWindowSize } from "../utils" ;
10
10
import mermaid from "mermaid" ;
11
11
12
12
import LoadingIcon from "../icons/three-dots.svg" ;
13
13
import React from "react" ;
14
14
import { useDebouncedCallback } from "use-debounce" ;
15
- import { showImageModal } from "./ui-lib" ;
15
+ import { showImageModal , FullScreen } from "./ui-lib" ;
16
16
import { ArtifactShareButton , HTMLPreview } from "./artifact" ;
17
17
18
18
export function Mermaid ( props : { code : string } ) {
@@ -66,6 +66,7 @@ export function PreCode(props: { children: any }) {
66
66
const refText = ref . current ?. innerText ;
67
67
const [ mermaidCode , setMermaidCode ] = useState ( "" ) ;
68
68
const [ htmlCode , setHtmlCode ] = useState ( "" ) ;
69
+ const { height } = useWindowSize ( ) ;
69
70
70
71
const renderArtifacts = useDebouncedCallback ( ( ) => {
71
72
if ( ! ref . current ) return ;
@@ -104,20 +105,17 @@ export function PreCode(props: { children: any }) {
104
105
< Mermaid code = { mermaidCode } key = { mermaidCode } />
105
106
) }
106
107
{ 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 } >
115
109
< ArtifactShareButton
116
110
style = { { position : "absolute" , right : 10 , top : 10 } }
117
111
getCode = { ( ) => htmlCode }
118
112
/>
119
- < HTMLPreview code = { htmlCode } />
120
- </ div >
113
+ < HTMLPreview
114
+ code = { htmlCode }
115
+ autoHeight = { ! document . fullscreenElement }
116
+ height = { ! document . fullscreenElement ? 600 : height }
117
+ />
118
+ </ FullScreen >
121
119
) }
122
120
</ >
123
121
) ;
0 commit comments