Skip to content

Commit

Permalink
feat: add copy button to code (langgenius#3719)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywoola authored Apr 24, 2024
1 parent 7d9c558 commit a23a191
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion web/app/components/app/chat/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
display: none;
}

pre:hover .copyBtn {
display: block;
}

.answerWrapWrap,
.questionWrapWrap {
width: 0;
Expand Down Expand Up @@ -129,4 +133,4 @@

.textArea:focus+div .sendBtn {
background-image: url(./icons/send-active.svg);
}
}
3 changes: 1 addition & 2 deletions web/app/components/base/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ const useLazyLoad = (ref: RefObject<Element>): boolean => {
}

export function Markdown(props: { content: string; className?: string }) {
const [isCopied, setIsCopied] = useState(false)
const [isSVG, setIsSVG] = useState(false)
return (
<div className={cn(props.className, 'markdown-body')}>
Expand All @@ -92,7 +91,7 @@ export function Markdown(props: { content: string; className?: string }) {
RehypeKatex,
]}
components={{
code({ node, inline, className, children, ...props }) {
code({ inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || '')
const language = match?.[1]
const languageShowName = getCorrectCapitalizationLanguageName(language || '')
Expand Down

0 comments on commit a23a191

Please sign in to comment.