UNPKG

tdesign-react

Version:
42 lines (36 loc) 1.25 kB
/** * tdesign v1.16.6 * (c) 2026 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _util_style = require('../_chunks/dep-2bbded38.js'); require('../_chunks/dep-202d6c73.js'); require('../_chunks/dep-615c149d.js'); require('../_chunks/dep-90a93885.js'); require('../_chunks/dep-a8d5081a.js'); require('../_chunks/dep-0173c82c.js'); function copyText(text) { var _document$execCommand, _document; if (!_util_style.canUseDocument) return; if ("clipboard" in navigator) { navigator.clipboard.writeText(text); return; } var textarea = document.createElement("textarea"); textarea.textContent = text; textarea.style.width = "0px"; textarea.style.height = "0px"; document.body.appendChild(textarea); var selection = document.getSelection(); var range = document.createRange(); range.selectNode(textarea); selection.removeAllRanges(); selection.addRange(range); (_document$execCommand = (_document = document).execCommand) === null || _document$execCommand === void 0 || _document$execCommand.call(_document, "copy"); selection.removeAllRanges(); document.body.removeChild(textarea); } exports["default"] = copyText; //# sourceMappingURL=copyText.js.map