web-manager 3.2.64 → 3.2.65
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/utilities.js +23 -8
- 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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
86
|
+
navigator.clipboard.writeText(text);
|
86
87
|
} catch (e) {
|
87
|
-
|
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