11"use client" ;
22
3- import { useRef , useState , useCallback } from "react" ;
3+ import { useRef , useState , useCallback , useEffect } from "react" ;
44import { MarkdownEditor } from "@/components/markdown-editor" ;
55import { MarkdownPreview } from "@/components/markdown-preview" ;
66import { usePdfExport } from "@/lib/use-pdf-export" ;
@@ -14,7 +14,7 @@ import {
1414 SelectValue ,
1515} from "@/components/ui/select" ;
1616import { Separator } from "@/components/ui/separator" ;
17- import { Loader2 , DownloadIcon } from "lucide-react" ;
17+ import { Loader2 , DownloadIcon , EyeIcon , XIcon , Maximize2Icon , Minimize2Icon } from "lucide-react" ;
1818
1919type PageSize = "a4" | "letter" | "legal" ;
2020
@@ -28,11 +28,21 @@ export default function Home() {
2828 const [ markdown , setMarkdown ] = useState ( defaultMarkdown ) ;
2929 const [ pageSize , setPageSize ] = useState < PageSize > ( "a4" ) ;
3030 const [ editorWidth , setEditorWidth ] = useState ( 35 ) ;
31+ const [ previewOnly , setPreviewOnly ] = useState ( false ) ;
3132 const dragging = useRef ( false ) ;
3233 const previewRef = useRef < HTMLDivElement > ( null ) ;
3334 const containerRef = useRef < HTMLDivElement > ( null ) ;
3435 const { exportPdf, exporting } = usePdfExport ( previewRef , pageSize ) ;
3536
37+ useEffect ( ( ) => {
38+ if ( ! previewOnly ) return ;
39+ const handleKeyDown = ( e : KeyboardEvent ) => {
40+ if ( e . key === "Escape" ) setPreviewOnly ( false ) ;
41+ } ;
42+ document . addEventListener ( "keydown" , handleKeyDown ) ;
43+ return ( ) => document . removeEventListener ( "keydown" , handleKeyDown ) ;
44+ } , [ previewOnly ] ) ;
45+
3646 const clampWidth = ( pct : number ) => Math . min ( 80 , Math . max ( 20 , pct ) ) ;
3747
3848 const handleMouseDown = useCallback ( ( e : React . MouseEvent ) => {
@@ -98,6 +108,17 @@ export default function Home() {
98108 </ div >
99109
100110 < div className = "flex items-center gap-2" >
111+ < Button
112+ variant = "outline"
113+ size = "icon"
114+ onClick = { ( ) => setPreviewOnly ( true ) }
115+ title = "Preview only"
116+ >
117+ < Maximize2Icon className = "size-4" />
118+ </ Button >
119+
120+ < Separator orientation = "vertical" className = "h-6" />
121+
101122 < Select
102123 value = { pageSize }
103124 onValueChange = { ( v ) => setPageSize ( v as PageSize ) }
@@ -179,6 +200,28 @@ export default function Home() {
179200 </ div >
180201 </ div >
181202
203+ { /* Preview-only fullscreen modal */ }
204+ { previewOnly && (
205+ < div className = "fixed inset-0 z-50 flex flex-col bg-white" >
206+ < div className = "flex shrink-0 justify-end p-4" >
207+ < Button
208+ variant = "outline"
209+ size = "icon"
210+ onClick = { ( ) => setPreviewOnly ( false ) }
211+ >
212+ < Minimize2Icon className = "size-4" />
213+ </ Button >
214+ </ div >
215+ < div className = "flex-1 overflow-auto px-8 pb-8" >
216+ < MarkdownPreview
217+ fluid
218+ content = { markdown }
219+ pageSize = { pageSize }
220+ />
221+ </ div >
222+ </ div >
223+ ) }
224+
182225 { /* SEO content — visible to crawlers, visually hidden from app UI */ }
183226 < footer className = "sr-only" aria-label = "About MarkBloom" >
184227 < h2 > What is MarkBloom?</ h2 >
0 commit comments