diff --git a/frontend/src/components/CodeBlock.jsx b/frontend/src/components/CodeBlock.jsx new file mode 100644 index 0000000..ea0ce16 --- /dev/null +++ b/frontend/src/components/CodeBlock.jsx @@ -0,0 +1,48 @@ +import React, { useState } from 'react'; +import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; +import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'; +import { CopyOutlined, CheckOutlined } from '@ant-design/icons'; +import { Button, Tooltip } from 'antd'; + +const CodeBlock = ({ language, children, ...props }) => { + const [copied, setCopied] = useState(false); + + const handleCopy = () => { + navigator.clipboard.writeText(String(children).replace(/\n$/, '')); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + + return ( +
{children}
@@ -226,7 +226,7 @@ const ForumDetail = () => {
fontSize: 16,
lineHeight: 1.8,
minHeight: 200,
- }} className="markdown-body">
+ }} className={styles['markdown-body']}>
{
#{index + 1}
-
+