@tamagui/react-native-web-lite
Version:
React Native for Web
32 lines (31 loc) • 1.07 kB
JavaScript
let clipboardAvailable;
class Clipboard {
static isAvailable() {
return clipboardAvailable === void 0 && (clipboardAvailable = typeof document.queryCommandSupported == "function" && document.queryCommandSupported("copy")), clipboardAvailable;
}
static getString() {
return Promise.resolve("");
}
static setString(text) {
let success = !1;
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 = !0;
} catch {
}
selection.removeAllRanges(), body.removeChild(node);
}
return success;
}
}
export {
Clipboard
};
//# sourceMappingURL=index.js.map