浏览代码

feat: add copy button to code (#3719)

tags/0.6.5
crazywoola 1年前
父节点
当前提交
a23a191615
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 5
    1
      web/app/components/app/chat/style.module.css
  2. 1
    2
      web/app/components/base/markdown.tsx

+ 5
- 1
web/app/components/app/chat/style.module.css 查看文件

@@ -44,6 +44,10 @@
display: none;
}

pre:hover .copyBtn {
display: block;
}

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

.textArea:focus+div .sendBtn {
background-image: url(./icons/send-active.svg);
}
}

+ 1
- 2
web/app/components/base/markdown.tsx 查看文件

@@ -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')}>
@@ -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 || '')

正在加载...
取消
保存