diff options
Diffstat (limited to 'apps/Notes/helpers/copyToClipboard.js')
-rw-r--r-- | apps/Notes/helpers/copyToClipboard.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/Notes/helpers/copyToClipboard.js b/apps/Notes/helpers/copyToClipboard.js new file mode 100644 index 0000000..608d299 --- /dev/null +++ b/apps/Notes/helpers/copyToClipboard.js @@ -0,0 +1,19 @@ +const copyToClipboard = (text, setPopup) => { + navigator + .clipboard.writeText(text) + .then(() => { + setPopup({ + content: 'Note content was copied to clipboard', + time: 2000, + }) + }) + .catch(() => { + setPopup({ + content: 'Could not copy to clipboard', + time: 2000, + error: true + }) + }) +} + +export default copyToClipboard |