summaryrefslogtreecommitdiff
path: root/src/web/app/common/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/app/common/scripts')
-rw-r--r--src/web/app/common/scripts/copy-to-clipboard.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/web/app/common/scripts/copy-to-clipboard.js b/src/web/app/common/scripts/copy-to-clipboard.js
new file mode 100644
index 0000000000..2e67024c85
--- /dev/null
+++ b/src/web/app/common/scripts/copy-to-clipboard.js
@@ -0,0 +1,13 @@
+/**
+ * Clipboardに値をコピー(TODO: 文字列以外も対応)
+ */
+module.exports = val => {
+ const form = document.createElement('textarea');
+ form.textContent = val;
+ document.body.appendChild(form);
+ form.select();
+ const result = document.execCommand('copy');
+ document.body.removeChild(form);
+
+ return result;
+};