import { useTranslation } from "react-i18next"; import { cn } from "@/lib/cn"; import { formatBytes } from "@/lib/formatters"; // Enough to recognise which snippet is on the clipboard without turning the // preview into a text editor; the box clamps to three lines on top of this. const PREVIEW_CHARS = 280; export const ClipboardPreview = ({ text, className }: { text: string; className?: string }) => { const { t } = useTranslation(); const clipped = text.length > PREVIEW_CHARS; const bytes = new TextEncoder().encode(text).length; return (
{clipped ? `${text.slice(0, PREVIEW_CHARS)}…` : text}
{formatBytes(bytes)}