"use client" import { Link, RotateCw, UnfoldVertical } from "lucide-react" import { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from "react" import { toast } from "sonner" export default forwardRef(function PreviewWindow( { collapsed, open, src, }: { collapsed: boolean open: () => void src: string }, ref: React.Ref<{ refreshIframe: () => void }> ) { const frameRef = useRef(null) const [iframeKey, setIframeKey] = useState(0) const refreshIframe = () => { setIframeKey((prev) => prev + 1) } // Refresh the preview when the URL changes. useEffect(refreshIframe, [src]) // Expose refreshIframe method to the parent. useImperativeHandle(ref, () => ({ refreshIframe })) return ( <>
Preview
{collapsed ? ( ) : ( <> { navigator.clipboard.writeText(src) toast.info("Copied preview link to clipboard") }} > )}
) }) function PreviewButton({ children, disabled = false, onClick, }: { children: React.ReactNode disabled?: boolean onClick: () => void }) { return (
{children}
) }