UNPKG

@tamagui/react-native-web-lite

Version:
53 lines (51 loc) 2.14 kB
function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor; } var clipboardAvailable, Clipboard = /* @__PURE__ */function () { "use strict"; function Clipboard2() { _class_call_check(this, Clipboard2); } return _create_class(Clipboard2, null, [{ key: "isAvailable", value: function () { return clipboardAvailable === void 0 && (clipboardAvailable = typeof document.queryCommandSupported == "function" && document.queryCommandSupported("copy")), clipboardAvailable; } }, { key: "getString", value: function () { return Promise.resolve(""); } }, { key: "setString", value: function (text) { var success = !1, body = document.body; if (body) { var node = document.createElement("span"); node.textContent = text, node.style.opacity = "0", node.style.position = "absolute", node.style.whiteSpace = "pre-wrap", node.style.userSelect = "auto", body.appendChild(node); var selection = window.getSelection(); selection.removeAllRanges(); var range = document.createRange(); range.selectNodeContents(node), selection.addRange(range); try { document.execCommand("copy"), success = !0; } catch {} selection.removeAllRanges(), body.removeChild(node); } return success; } }]), Clipboard2; }(); export { Clipboard as default }; //# sourceMappingURL=index.native.js.map