fix: code block copy button missing

This commit is contained in:
kangfenmao 2024-11-25 13:56:41 +08:00
parent dcf57651fe
commit 1171100417
2 changed files with 4 additions and 2 deletions

View File

@ -39,7 +39,6 @@ const ExpandButton: React.FC<{
const CodeBlock: React.FC<CodeBlockProps> = ({ children, className }) => {
const match = /language-(\w+)/.exec(className || '')
const showFooterCopyButton = children && children.length > 500
const { codeShowLineNumbers, fontSize, codeCollapsible } = useSettings()
const language = match?.[1] ?? 'text'
const [html, setHtml] = useState<string>('')
@ -48,6 +47,8 @@ const CodeBlock: React.FC<CodeBlockProps> = ({ children, className }) => {
const [shouldShowExpandButton, setShouldShowExpandButton] = useState(false)
const codeContentRef = useRef<HTMLDivElement>(null)
const showFooterCopyButton = children && children.length > 500 && !codeCollapsible
useEffect(() => {
const loadHighlightedCode = async () => {
const highlightedHtml = await codeToHtml(children, language)
@ -196,6 +197,7 @@ const CodeFooter = styled.div`
flex-direction: row;
justify-content: flex-end;
align-items: center;
position: relative;
.copy {
cursor: pointer;
color: var(--color-text-3);

View File

@ -44,7 +44,7 @@ const Messages: FC<Props> = ({ assistant, topic, setActiveTopic }) => {
const showRightTopics = showTopics && topicPosition === 'right'
const minusAssistantsWidth = showAssistants ? '- var(--assistants-width)' : ''
const minusRightTopicsWidth = showRightTopics ? '- var(--assistants-width)' : ''
return `calc(100vw - var(--sidebar-width) ${minusAssistantsWidth} ${minusRightTopicsWidth})`
return `calc(100vw - var(--sidebar-width) ${minusAssistantsWidth} ${minusRightTopicsWidth} - 5px)`
}, [showAssistants, showTopics, topicPosition])
const scrollToBottom = useCallback(() => {