aboutsummaryrefslogtreecommitdiffstats
path: root/apps/Notes/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'apps/Notes/helpers')
-rw-r--r--apps/Notes/helpers/copyToClipboard.js19
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