web-manager 3.2.64 → 3.2.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/utilities.js +23 -8
  2. package/package.json +1 -1
package/lib/utilities.js CHANGED
@@ -76,17 +76,32 @@ Utilities.set = function (obj, path, value) {
76
76
  // https://dzone.com/articles/cross-browser-javascript-copy-and-paste
77
77
  // https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
78
78
  Utilities.clipboardCopy = function (input) {
79
- var el = document.createElement('textarea');
80
- el.setAttribute('style','width:1px;border:0;opacity:0;');
81
- el.value = input && input.nodeType ? input.value || input.innerText || input.innerHTML : input;
82
- document.body.appendChild(el);
83
- el.select();
79
+ // Get the text from the input
80
+ var text = input && input.nodeType
81
+ ? input.value || input.innerText || input.innerHTML
82
+ : input;
83
+
84
+ // Try to use the modern clipboard API
84
85
  try {
85
- document.execCommand('copy');
86
+ navigator.clipboard.writeText(text);
86
87
  } catch (e) {
87
- alert('Please press Ctrl/Cmd+C to copy');
88
+ // Try creating a textarea and copying the text to it
89
+ var el = document.createElement('textarea');
90
+ el.setAttribute('style','width:1px;border:0;opacity:0;');
91
+ el.value = text;
92
+ document.body.appendChild(el);
93
+ el.select();
94
+
95
+ // Try to copy the text
96
+ try {
97
+ document.execCommand('copy');
98
+ } catch (e) {
99
+ alert('Please press Ctrl+C/Cmd+C to copy');
100
+ }
101
+
102
+ // Remove the textarea
103
+ document.body.removeChild(el);
88
104
  }
89
- document.body.removeChild(el);
90
105
  }
91
106
 
92
107
  // Escape HTML
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.64",
3
+ "version": "3.2.65",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {