@budibase/bbui 1.0.49-alpha.10 → 1.0.49-alpha.14

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/bbui",
3
3
  "description": "A UI solution used in the different Budibase projects.",
4
- "version": "1.0.49-alpha.10",
4
+ "version": "1.0.49-alpha.14",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -82,5 +82,5 @@
82
82
  "svelte-flatpickr": "^3.2.3",
83
83
  "svelte-portal": "^1.0.0"
84
84
  },
85
- "gitHead": "3da9cf22204edec14689341b5427e6b0af470a22"
85
+ "gitHead": "f625828b5881c0940cf373afb0e53b617c497a76"
86
86
  }
@@ -8,10 +8,35 @@
8
8
  copyToClipboard(value)
9
9
  }
10
10
 
11
- function copyToClipboard(value) {
12
- navigator.clipboard.writeText(value).then(() => {
13
- notifications.success("Copied")
11
+ const copyToClipboard = value => {
12
+ return new Promise(res => {
13
+ if (navigator.clipboard && window.isSecureContext) {
14
+ // Try using the clipboard API first
15
+ navigator.clipboard.writeText(value).then(res)
16
+ } else {
17
+ // Fall back to the textarea hack
18
+ let textArea = document.createElement("textarea")
19
+ textArea.value = value
20
+ textArea.style.position = "fixed"
21
+ textArea.style.left = "-9999px"
22
+ textArea.style.top = "-9999px"
23
+ document.body.appendChild(textArea)
24
+ textArea.focus()
25
+ textArea.select()
26
+ document.execCommand("copy")
27
+ textArea.remove()
28
+ res()
29
+ }
14
30
  })
31
+ .then(() => {
32
+ notifications.success("Copied to clipboard")
33
+ })
34
+ .catch(() => {
35
+ notifications.error(
36
+ "Failed to copy to clipboard. Check the dev console for the value."
37
+ )
38
+ console.warn("Failed to copy the value", value)
39
+ })
15
40
  }
16
41
  </script>
17
42