@node-projects/web-component-designer 0.0.190 → 0.0.191
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export async function copyTextToClipboard(text) {
|
|
2
2
|
copyToClipboard(['text/plain', text]);
|
|
3
3
|
}
|
|
4
|
+
//used, so you could copy internal if you have no clipboard access
|
|
5
|
+
let internalClipboard = null;
|
|
4
6
|
export async function copyToClipboard(items) {
|
|
5
7
|
if (navigator.clipboard) {
|
|
6
8
|
try {
|
|
@@ -12,10 +14,12 @@ export async function copyToClipboard(items) {
|
|
|
12
14
|
}
|
|
13
15
|
catch (err) {
|
|
14
16
|
await navigator.clipboard.writeText(items[0][1]);
|
|
17
|
+
internalClipboard = items[0][1];
|
|
15
18
|
}
|
|
16
19
|
console.info('Copy to clipboard successful');
|
|
17
20
|
}
|
|
18
21
|
else {
|
|
22
|
+
internalClipboard = items[0][1];
|
|
19
23
|
const textArea = document.createElement('textarea');
|
|
20
24
|
textArea.style.position = 'fixed';
|
|
21
25
|
textArea.style.top = '0';
|
|
@@ -69,6 +73,8 @@ export async function getTextFromClipboard() {
|
|
|
69
73
|
textArea.select();
|
|
70
74
|
document.execCommand('paste');
|
|
71
75
|
let value = textArea.value;
|
|
76
|
+
if (!value)
|
|
77
|
+
value = internalClipboard;
|
|
72
78
|
document.body.removeChild(textArea);
|
|
73
79
|
resolve(value);
|
|
74
80
|
});
|