mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-06 07:49:17 +00:00
29 lines
735 B
TypeScript
29 lines
735 B
TypeScript
import { ClipboardIcon } from "lucide-react";
|
|
import handleCopy from "./handleCopy";
|
|
|
|
export default function TextCopyBlock(description: string) {
|
|
const pattern = /`([^`]*)`/g;
|
|
const parts = description.split(pattern);
|
|
|
|
const formattedDescription = parts.map((part: string, index: number) => {
|
|
if (index % 2 === 1) {
|
|
return (
|
|
<span
|
|
key={index}
|
|
className="bg-secondary py-1 px-2 rounded-lg inline-flex items-center gap-2"
|
|
>
|
|
{part}
|
|
<ClipboardIcon
|
|
className="size-3 cursor-pointer"
|
|
onClick={() => handleCopy("command", part)}
|
|
/>
|
|
</span>
|
|
);
|
|
} else {
|
|
return part;
|
|
}
|
|
});
|
|
|
|
return formattedDescription;
|
|
}
|