diff --git a/web/app/components/app/chat/copy-btn/index.tsx b/web/app/components/app/chat/copy-btn/index.tsx index b72c1ac71a..5e2a9bdaaf 100644 --- a/web/app/components/app/chat/copy-btn/index.tsx +++ b/web/app/components/app/chat/copy-btn/index.tsx @@ -8,32 +8,36 @@ import Tooltip from '@/app/components/base/tooltip' type ICopyBtnProps = { value: string className?: string + isPlain?: boolean } const CopyBtn = ({ value, className, + isPlain, }: ICopyBtnProps) => { const [isCopied, setIsCopied] = React.useState(false) return (
{ copy(value) setIsCopied(true) }} > -
+
diff --git a/web/app/components/base/markdown.tsx b/web/app/components/base/markdown.tsx index b65ff9027f..047cdb99da 100644 --- a/web/app/components/base/markdown.tsx +++ b/web/app/components/base/markdown.tsx @@ -8,6 +8,8 @@ import SyntaxHighlighter from 'react-syntax-highlighter' import { atelierHeathLight } from 'react-syntax-highlighter/dist/esm/styles/hljs' import type { RefObject } from 'react' import { useEffect, useRef, useState } from 'react' +import CopyBtn from '@/app/components/app/chat/copy-btn' + // import { copyToClipboard } from "../utils"; // https://txtfiddle.com/~hlshwya/extract-urls-from-text // const urlRegex = /\b((https?|ftp|file):\/\/|(www|ftp)\.)[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/ig @@ -61,6 +63,7 @@ const useLazyLoad = (ref: RefObject): boolean => { } export function Markdown(props: { content: string }) { + const [isCopied, setIsCopied] = useState(false) return (
{ + if (language) + return language.charAt(0).toUpperCase() + language.substring(1) + + return 'Plain' + })() return (!inline && match) ? ( - +
+
+
{languageShowName}
+ +
+ + {String(children).replace(/\n$/, '')} + +
) : ( diff --git a/web/app/styles/markdown.scss b/web/app/styles/markdown.scss index fbae6da977..7348bc8050 100644 --- a/web/app/styles/markdown.scss +++ b/web/app/styles/markdown.scss @@ -774,6 +774,10 @@ border-radius: 6px; } +.markdown-body pre { + padding: 0; +} + .markdown-body pre code, .markdown-body pre tt { display: inline-block;