import { Tooltip, ActionIcon, CopyButton, Flex } from "@mantine/core"; import { IconCheck, IconGitCommit, IconFileDiff, IconColumnInsertRight, IconReplace, IconCopy } from "@tabler/icons-react"; import React, { useState } from "react"; import ReactMarkdown from "react-markdown"; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { okaidia } from "react-syntax-highlighter/dist/esm/styles/prism"; import messageUtil from '../../util/MessageUtil'; const CodeBlock = (props: any) => { const { messageText } = props; const LanguageCorner = (props: any) => { const { language } = props; return (
{language && (
{language}
)}
); }; const CodeButtons = (props: any) => { const { language, code } = props; const CommitButton = () => { const [commited, setCommited] = useState(false); return ( { messageUtil.sendMessage({ command: 'doCommit', content: code }); setCommited(true); setTimeout(() => { setCommited(false); }, 2000); }}> {commited ? : } ); }; const DiffButton = () => { return ( { messageUtil.sendMessage({ command: 'show_diff', content: code }); }}> ); }; const CodeApplyButton = () => { return ( { messageUtil.sendMessage({ command: 'code_apply', content: code }); }}> ); }; const FileApplyButton = () => { return ( { messageUtil.sendMessage({ command: 'code_file_apply', content: code }); }}> ); }; const CodeCopyButton = () => { return ( {({ copied, copy }) => ( {copied ? : } )} ); }; return ( {language && language === 'commitmsg' ? : (<> )} ); }; return ( {value} ) : ( {children} ); } }} > {messageText} ); }; export default CodeBlock;