diff --git a/front/package-lock.json b/front/package-lock.json index 4a48f9c19..5cbe72e30 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -24,6 +24,7 @@ "allof-merge": "^0.6.6", "biblatex-csl-converter": "^1.11.0", "clsx": "^1.2.1", + "copy-to-clipboard": "^3.3.3", "core-js": "^3.38", "diff-match-patch": "^1.0.5", "downshift": "^6.1.12", @@ -39,7 +40,6 @@ "pagedjs": "^0.4.0", "prop-types": "^15.8.1", "react": "~18.3", - "react-copy-to-clipboard": "^5.0.3", "react-dnd": "16.0.1", "react-dnd-html5-backend": "16.0.1", "react-dom": "~18.3", @@ -4308,6 +4308,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz", "integrity": "sha512-2KV8NhB5JqC3ky0r9PMCAZKbUHSwtEo4CwCs0KXgruG43gX5PMqDEBbVU4OUzw2MuAWUfsuFmWvEKG5QRfSnJA==", + "license": "MIT", "dependencies": { "toggle-selection": "^1.0.6" } @@ -8466,18 +8467,6 @@ "node": ">=0.10.0" } }, - "node_modules/react-copy-to-clipboard": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz", - "integrity": "sha512-k61RsNgAayIJNoy9yDsYzDe/yAZAzEbEgcz3DZMhF686LEyukcE1hzurxe85JandPUG+yTfGVFzuEw3xt8WP/A==", - "dependencies": { - "copy-to-clipboard": "^3.3.1", - "prop-types": "^15.8.1" - }, - "peerDependencies": { - "react": "^15.3.0 || 16 || 17 || 18" - } - }, "node_modules/react-dnd": { "version": "16.0.1", "resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-16.0.1.tgz", @@ -9866,7 +9855,8 @@ "node_modules/toggle-selection": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", - "integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==" + "integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==", + "license": "MIT" }, "node_modules/tough-cookie": { "version": "5.1.0", diff --git a/front/package.json b/front/package.json index 918459327..6b84c5690 100644 --- a/front/package.json +++ b/front/package.json @@ -42,6 +42,7 @@ "allof-merge": "^0.6.6", "biblatex-csl-converter": "^1.11.0", "clsx": "^1.2.1", + "copy-to-clipboard": "^3.3.3", "core-js": "^3.38", "diff-match-patch": "^1.0.5", "downshift": "^6.1.12", @@ -57,7 +58,6 @@ "pagedjs": "^0.4.0", "prop-types": "^15.8.1", "react": "~18.3", - "react-copy-to-clipboard": "^5.0.3", "react-dnd": "16.0.1", "react-dnd-html5-backend": "16.0.1", "react-dom": "~18.3", diff --git a/front/src/components/UserInfos.jsx b/front/src/components/UserInfos.jsx index 8befd8a3f..59ea3f579 100644 --- a/front/src/components/UserInfos.jsx +++ b/front/src/components/UserInfos.jsx @@ -1,8 +1,7 @@ import React, { useState, useCallback } from 'react' -import { Check, Clipboard, Loader } from 'react-feather' +import { Check, Loader } from 'react-feather' import { useTranslation } from 'react-i18next' import { useSelector, useDispatch, shallowEqual } from 'react-redux' -import { CopyToClipboard } from 'react-copy-to-clipboard' import { Helmet } from 'react-helmet' import { useGraphQLClient } from '../helpers/graphQL' @@ -168,19 +167,12 @@ export default function UserInfos() { label={t('user.account.apiKey')} className={styles.apiKeyField} > - <> - - {sessionToken} - - - - - + + {sessionToken} + {activeUser._id} diff --git a/front/src/components/Write/Reference.jsx b/front/src/components/Write/Reference.jsx index 8b68dcae5..bcd1bc2c1 100644 --- a/front/src/components/Write/Reference.jsx +++ b/front/src/components/Write/Reference.jsx @@ -1,19 +1,45 @@ -import React, { memo } from 'react' -import { CopyToClipboard } from 'react-copy-to-clipboard' +import React, { memo, useCallback } from 'react' +import copy from 'copy-to-clipboard' import { useTranslation } from 'react-i18next' +import { useToasts } from '@geist-ui/core' import { Clipboard } from 'react-feather' import styles from './reference.module.scss' import ReferenceTypeIcon from '../ReferenceTypeIcon' import Button from '../Button' -const BibliographyReference = memo(function BibliographyReference({ entry }) { - const { key, title, type, date, authorName } = entry +const CopyButton = memo(function ReferenceCopyButton({ text }) { const { t } = useTranslation() + const { setToast } = useToasts() + + const handleCopy = useCallback(() => { + copy(text) + setToast({ + type: 'default', + text: t('write.copyReferenceToClipboard.successToast', { text }), + }) + }) + + return ( + + ) +}) + +export default function BibliographyReference({ entry }) { + const { key, title, type, date, authorName } = entry + const text = `[@${key}]` return (
+

- - - + +
) -}) - -export default BibliographyReference +} diff --git a/front/src/locales/en/translation.json b/front/src/locales/en/translation.json index 9ea1d1b88..b5eb51313 100644 --- a/front/src/locales/en/translation.json +++ b/front/src/locales/en/translation.json @@ -216,7 +216,8 @@ "write.sidebar.manageButton": "Manage", "write.biblioModal.title": "Bibliography manager", "write.searchFieldBiblio.placeholder": "Search", - "write.copyClipboard.referenceButton": "Copy to clipboard", + "write.copyReferenceToClipboard.Button": "Copy '{{text}}' to clipboard", + "write.copyReferenceToClipboard.successToast": "'{{text}}' copied to clipboard", "write.showBiblio.button": "Show all", "write.titleVersion.sidebar": "Versions", "write.newVersion.button": "New version", diff --git a/front/src/locales/es/translation.json b/front/src/locales/es/translation.json index d7190bc3a..211e65ae0 100644 --- a/front/src/locales/es/translation.json +++ b/front/src/locales/es/translation.json @@ -141,7 +141,8 @@ "write.sidebar.manageButton": "Gestión", "write.biblioModal.title": "Gestor de referencias bibliográficas", "write.searchFieldBiblio.placeholder": "Buscar", - "write.copyClipboard.referenceButton": "Copiar al portapapeles", + "write.copyReferenceToClipboard.Button": "Copiar '{{text}}' al portapapeles", + "write.copyReferenceToClipboard.successToast": "'{{text}}' copiado al portapapeles", "write.showBiblio.button": "Ver todos", "write.titleVersion.sidebar": "Versiones", "write.newVersion.button": "Nueva versión", diff --git a/front/src/locales/fr/translation.json b/front/src/locales/fr/translation.json index 31d71a97e..acd6a30b7 100644 --- a/front/src/locales/fr/translation.json +++ b/front/src/locales/fr/translation.json @@ -213,7 +213,8 @@ "write.sidebar.manageButton": "Gestion", "write.biblioModal.title": "Gestionnaire de références bibliographiques", "write.searchFieldBiblio.placeholder": "Rechercher", - "write.copyClipboard.referenceButton": "Copier dans le presse-papiers", + "write.copyReferenceToClipboard.Button": "Copier '{{text}}' dans le presse-papiers", + "write.copyReferenceToClipboard.successToast": "'{{text}}' copié dans le presse-papiers", "write.showBiblio.button": "Afficher tout", "write.titleVersion.sidebar": "Versions", "write.newVersion.button": "Nouvelle version",