UNPKG

tdesign-react

Version:
42 lines (36 loc) 1.25 kB
/** * tdesign v1.16.2 * (c) 2025 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _util_style = require('../_chunks/dep-e0735b5f.js'); require('../_chunks/dep-b304bc94.js'); require('../_chunks/dep-4ce0670e.js'); require('../_chunks/dep-b325182b.js'); require('../_chunks/dep-bdafd287.js'); require('../_chunks/dep-3448f35f.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