hylid-bridge 4.0.28-alpha.1 → 4.0.28

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,4 +1,37 @@
1
- import { setClipboard as baseSetClipboard } from 'miniapp-web-jsapi/lib/web/jsapi/clipboard';
1
+ function _setClipboard(options) {
2
+ var _a, _b, _c, _d, _e, _f;
3
+ if (!options.text) {
4
+ (_a = options.fail) === null || _a === void 0 ? void 0 : _a.call(options);
5
+ (_b = options.complete) === null || _b === void 0 ? void 0 : _b.call(options, {
6
+ success: false
7
+ });
8
+ return;
9
+ }
10
+ var input = document.createElement('input');
11
+ input.style.position = 'fixed';
12
+ input.style.opacity = '0';
13
+ input.style.zIndex = '-1000';
14
+ document.body.appendChild(input);
15
+ input.setAttribute('readonly', 'readonly');
16
+ input.setAttribute('value', options.text);
17
+ input.setSelectionRange(0, options.text.length);
18
+ input.focus();
19
+ input.select();
20
+ if (document.execCommand('copy')) {
21
+ (_c = options.success) === null || _c === void 0 ? void 0 : _c.call(options, {
22
+ success: true
23
+ });
24
+ (_d = options.complete) === null || _d === void 0 ? void 0 : _d.call(options, {
25
+ success: true
26
+ });
27
+ } else {
28
+ (_e = options.fail) === null || _e === void 0 ? void 0 : _e.call(options);
29
+ (_f = options.complete) === null || _f === void 0 ? void 0 : _f.call(options, {
30
+ success: false
31
+ });
32
+ }
33
+ document.body.removeChild(input);
34
+ }
2
35
  export default function setClipboard(options) {
3
- return baseSetClipboard(options);
36
+ return _setClipboard(options);
4
37
  }