diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66964b0..efcdea3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 1.4.1 (31 Jul 2024)
+
+## Bugfixes
+- Fix clipboard copy issue
+
# 1.4.0 (18 Mar 2022)
## Enhancements
diff --git a/NOTICE.md b/NOTICE.md
index 853c6c0..e43e8ab 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -2717,10 +2717,6 @@ __make-dir 3.1.0__
* sindresorhus.com
* MIT License
-__copy-text-to-clipboard 3.0.1__
- * https://sindresorhus.com
- * MIT License
-
__watchpack 2.3.1__
* https://github.com/webpack/watchpack
* MIT License
diff --git a/package-lock.json b/package-lock.json
index 7dd5b7f..64335c8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12,7 +12,6 @@
"@nivo/colors": "^0.79.1",
"@nivo/core": "^0.79.0",
"axios": "^0.26.0",
- "copy-text-to-clipboard": "^3.0.1",
"env-cmd": "^10.1.0",
"react": "^17.0.2",
"react-color": "^2.19.3",
@@ -5838,17 +5837,6 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
- "node_modules/copy-text-to-clipboard": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/copy-text-to-clipboard/-/copy-text-to-clipboard-3.0.1.tgz",
- "integrity": "sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q==",
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/core-js": {
"version": "3.21.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.21.1.tgz",
@@ -21336,11 +21324,6 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
- "copy-text-to-clipboard": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/copy-text-to-clipboard/-/copy-text-to-clipboard-3.0.1.tgz",
- "integrity": "sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q=="
- },
"core-js": {
"version": "3.21.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.21.1.tgz",
diff --git a/package.json b/package.json
index 2e65f0c..d77033a 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,12 @@
{
"name": "hits",
- "version": "1.4.0",
+ "version": "1.4.1",
"private": true,
"dependencies": {
"@nivo/calendar": "^0.79.1",
"@nivo/colors": "^0.79.1",
"@nivo/core": "^0.79.0",
"axios": "^0.26.0",
- "copy-text-to-clipboard": "^3.0.1",
"env-cmd": "^10.1.0",
"react": "^17.0.2",
"react-color": "^2.19.3",
diff --git a/pom.xml b/pom.xml
index 78089ce..cbaaed4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
org.silentsoft
hits
- 1.4.0
+ 1.4.1
Hits
Hit Counter for Your GitHub or Any Kind of Websites You Want
diff --git a/src/main/react/components/BadgeCard.js b/src/main/react/components/BadgeCard.js
index cff7f87..ceea4a1 100644
--- a/src/main/react/components/BadgeCard.js
+++ b/src/main/react/components/BadgeCard.js
@@ -1,18 +1,25 @@
import {useRef, useState} from "react";
-import copy from "copy-text-to-clipboard";
export default function BadgeCard(props) {
const valueRef = useRef(null);
const [copied, setCopied] = useState(false);
const copyToClipboard = () => {
- try {
- copy(valueRef.current.textContent);
+ if (navigator.clipboard) {
+ navigator.clipboard.writeText(valueRef.current.textContent).then(() => {
+ setCopied(true);
+ setTimeout(() => {
+ setCopied(false);
+ }, 1500);
+ })
+ } else {
+ const textarea = document.createElement('textarea');
+ textarea.value = valueRef.current.textContent;
+ document.body.appendChild(textarea);
+ textarea.select();
+ document.execCommand('copy');
setCopied(true);
- setTimeout(() => {
- setCopied(false);
- }, 1500);
- } catch (e) {
- console.error(e);
+ setTimeout(() => setCopied(false), 1500);
+ document.body.removeChild(textarea);
}
};
return (