UNPKG

@tamagui/react-native-web-lite

Version:
40 lines (39 loc) 1.14 kB
let clipboardAvailable; class Clipboard { static isAvailable() { if (clipboardAvailable === void 0) { clipboardAvailable = typeof document.queryCommandSupported === "function" && document.queryCommandSupported("copy"); } return clipboardAvailable; } static getString() { return Promise.resolve(""); } static setString(text) { let success = false; const body = document.body; if (body) { const 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); const selection = window.getSelection(); selection.removeAllRanges(); const range = document.createRange(); range.selectNodeContents(node); selection.addRange(range); try { document.execCommand("copy"); success = true; } catch (e) {} selection.removeAllRanges(); body.removeChild(node); } return success; } } export { Clipboard }; //# sourceMappingURL=index.mjs.map