mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 17:24:00 +01:00
parent
ad90d99299
commit
2d1139e3d2
|
@ -19,6 +19,7 @@ import TickIcon from '@icon/TickIcon';
|
|||
import CrossIcon from '@icon/CrossIcon';
|
||||
import RefreshIcon from '@icon/RefreshIcon';
|
||||
import DownChevronArrow from '@icon/DownChevronArrow';
|
||||
import CopyIcon from '@icon/CopyIcon';
|
||||
|
||||
import useSubmit from '@hooks/useSubmit';
|
||||
|
||||
|
@ -126,6 +127,10 @@ const ContentView = React.memo(
|
|||
handleSubmit();
|
||||
};
|
||||
|
||||
const handleCopy = () => {
|
||||
navigator.clipboard.writeText(content);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='markdown prose w-full break-words dark:prose-invert dark share-gpt-message'>
|
||||
|
@ -167,6 +172,7 @@ const ContentView = React.memo(
|
|||
<DownButton onClick={handleMoveDown} />
|
||||
)}
|
||||
|
||||
<CopyButton onClick={handleCopy} />
|
||||
<EditButton setIsEdit={setIsEdit} />
|
||||
<DeleteButton setIsDelete={setIsDelete} />
|
||||
</>
|
||||
|
@ -279,6 +285,7 @@ const UpButton = ({
|
|||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const RefreshButton = ({
|
||||
onClick,
|
||||
}: {
|
||||
|
@ -286,6 +293,28 @@ const RefreshButton = ({
|
|||
}) => {
|
||||
return <MessageButton icon={<RefreshIcon />} onClick={onClick} />;
|
||||
};
|
||||
|
||||
const CopyButton = ({
|
||||
onClick,
|
||||
}: {
|
||||
onClick: React.MouseEventHandler<HTMLButtonElement>;
|
||||
}) => {
|
||||
const [isCopied, setIsCopied] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<MessageButton
|
||||
icon={isCopied ? <TickIcon /> : <CopyIcon />}
|
||||
onClick={(e) => {
|
||||
onClick(e);
|
||||
setIsCopied(true);
|
||||
window.setTimeout(() => {
|
||||
setIsCopied(false);
|
||||
}, 3000);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const EditView = ({
|
||||
content,
|
||||
setIsEdit,
|
||||
|
|
Loading…
Reference in a new issue