import { useState } from "react"; import { Highlight, themes } from "prism-react-renderer"; import copy from "copy-to-clipboard"; import { Tooltip } from "@mui/material"; import { CodeWrapper, CopyCodeIcon, DisplayCodePre } from "./Common-styles"; import { useTheme } from "@mui/material"; export const DisplayCode = ({ codeBlock, language = "javascript" }) => { const [copyText, setCopyText] = useState("Copy"); const handleCopy = () => { try { copy(codeBlock); setCopyText("Copied!"); setTimeout(() => { setCopyText("Copy!"); }, 3000); } catch (error) {} }; return ( {({ className, style, tokens, getLineProps, getTokenProps }) => ( {tokens.map((line, i) => (
{i + 1} {line.map((token, key) => ( ))}
))}
)}
); };