mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 16:49:02 +08:00
feat: add copy button to code (#3719)
This commit is contained in:
parent
7d9c5586f9
commit
a23a191615
@ -44,6 +44,10 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre:hover .copyBtn {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.answerWrapWrap,
|
.answerWrapWrap,
|
||||||
.questionWrapWrap {
|
.questionWrapWrap {
|
||||||
width: 0;
|
width: 0;
|
||||||
|
@ -82,7 +82,6 @@ const useLazyLoad = (ref: RefObject<Element>): boolean => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Markdown(props: { content: string; className?: string }) {
|
export function Markdown(props: { content: string; className?: string }) {
|
||||||
const [isCopied, setIsCopied] = useState(false)
|
|
||||||
const [isSVG, setIsSVG] = useState(false)
|
const [isSVG, setIsSVG] = useState(false)
|
||||||
return (
|
return (
|
||||||
<div className={cn(props.className, 'markdown-body')}>
|
<div className={cn(props.className, 'markdown-body')}>
|
||||||
@ -92,7 +91,7 @@ export function Markdown(props: { content: string; className?: string }) {
|
|||||||
RehypeKatex,
|
RehypeKatex,
|
||||||
]}
|
]}
|
||||||
components={{
|
components={{
|
||||||
code({ node, inline, className, children, ...props }) {
|
code({ inline, className, children, ...props }) {
|
||||||
const match = /language-(\w+)/.exec(className || '')
|
const match = /language-(\w+)/.exec(className || '')
|
||||||
const language = match?.[1]
|
const language = match?.[1]
|
||||||
const languageShowName = getCorrectCapitalizationLanguageName(language || '')
|
const languageShowName = getCorrectCapitalizationLanguageName(language || '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user