ui: fix types

This commit is contained in:
nick-delirium 2025-05-07 15:13:13 +02:00
parent 4aa75ce14b
commit bb8cf3d280
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
3 changed files with 16 additions and 4 deletions

View file

@ -102,7 +102,7 @@ export function ChatMsg({
<IconButton tooltip="Dislike this answer" onClick={() => onFeedback('dislike', messageId)}>
<ThumbsDown size={16} />
</IconButton>
<CopyButton content={() => bodyRef.current?.innerHTML} isIcon format={'text/html'} />
<CopyButton getHtml={() => bodyRef.current?.innerHTML} content={text} isIcon format={'text/html'} />
<IconButton processing={isProcessing} tooltip="Export as PDF" onClick={onExport}>
<FileDown size={16} />
</IconButton>

View file

@ -3,15 +3,27 @@ import copy from 'copy-to-clipboard';
import { Button, Tooltip } from 'antd';
import { ClipboardCopy, ClipboardCheck } from 'lucide-react';
interface Props {
content: string;
getHtml?: () => any;
variant?: 'text' | 'primary' | 'ghost' | 'link' | 'default';
className?: string;
btnText?: string;
size?: 'small' | 'middle' | 'large';
isIcon?: boolean;
format?: string;
}
function CopyButton({
content,
getHtml,
variant = 'text',
className = 'capitalize mt-2 font-medium text-neutral-400',
btnText = 'copy',
size = 'small',
isIcon = false,
format = 'text/plain',
}) {
}: Props) {
const [copied, setCopied] = useState(false);
const reset = () => {
@ -21,8 +33,8 @@ function CopyButton({
}
const copyHandler = () => {
setCopied(true);
const contentIsGetter = typeof content === 'function'
const textContent = contentIsGetter ? content() : content;
const contentIsGetter = !!getHtml
const textContent = contentIsGetter ? getHtml() : content;
const isHttps = window.location.protocol === 'https:';
if (!isHttps) {
copy(textContent);