copy mac fixed
This commit is contained in:
@@ -83,19 +83,55 @@ const LatestTransactions = () => {
|
||||
setTotalItems(transCount?.data?.transactionCount);
|
||||
}, [transCount]);
|
||||
|
||||
// function copyToClipboard(text) {
|
||||
// navigator.clipboard
|
||||
// .writeText(text)
|
||||
// .then(() => {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"warn"} message={"Text copied to clipboard"} />
|
||||
// ),
|
||||
// });
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.error("Failed to copy text: ", err);
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function copyToClipboard(text) {
|
||||
navigator.clipboard
|
||||
.writeText(text)
|
||||
.then(() => {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard
|
||||
.writeText(text)
|
||||
.then(() => {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"warn"} message={"Text copied to clipboard"} />
|
||||
),
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Failed to copy text: ", err);
|
||||
});
|
||||
} else {
|
||||
// Fallback method for unsupported browsers
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
try {
|
||||
document.execCommand("copy");
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"warn"} message={"Text copied to clipboard"} />
|
||||
),
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Failed to copy text: ", err);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Fallback: Failed to copy text: ", err);
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
}
|
||||
|
||||
const handleRefreshClick = () => {
|
||||
|
||||
Reference in New Issue
Block a user