mirror of https://github.com/buster-so/buster.git
Update CodeCard.tsx
This commit is contained in:
parent
d4b6f2719a
commit
f417ada44a
|
@ -33,7 +33,11 @@ export const CodeCard: React.FC<{
|
||||||
error = ''
|
error = ''
|
||||||
}) => {
|
}) => {
|
||||||
const ShownButtons =
|
const ShownButtons =
|
||||||
buttons === true ? <CardButtons fileName={fileName} code={code} /> : buttons;
|
buttons === true ? (
|
||||||
|
<CardButtons fileName={fileName} code={code} language={language} />
|
||||||
|
) : (
|
||||||
|
buttons
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={cn('h-full', className)}>
|
<Card className={cn('h-full', className)}>
|
||||||
|
@ -66,7 +70,8 @@ CodeCard.displayName = 'CodeCard';
|
||||||
const CardButtons: React.FC<{
|
const CardButtons: React.FC<{
|
||||||
fileName: string;
|
fileName: string;
|
||||||
code: string;
|
code: string;
|
||||||
}> = React.memo(({ fileName, code }) => {
|
language: string;
|
||||||
|
}> = React.memo(({ fileName, code, language }) => {
|
||||||
const { openInfoMessage, openErrorMessage } = useBusterNotifications();
|
const { openInfoMessage, openErrorMessage } = useBusterNotifications();
|
||||||
|
|
||||||
const handleCopyCode = useMemoizedFn(async () => {
|
const handleCopyCode = useMemoizedFn(async () => {
|
||||||
|
@ -84,7 +89,7 @@ const CardButtons: React.FC<{
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.download = fileName;
|
link.download = `${fileName}.${language}`; //this is actually not a good idea...
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
|
|
Loading…
Reference in New Issue