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