azure-devops-ui
Version:
React components for building web UI in Azure DevOps
1 lines • 838 B
JavaScript
import*as React from"react";import*as ReactDOM from"react-dom";function copyToClipboard(e,t){var o;e instanceof HTMLElement?copy(e,t):((o=document.createElement("div")).classList.add("visually-hidden"),o.setAttribute("aria-hidden","true"),o.setAttribute("role","presentation"),o.setAttribute("style","{color: inherit; background-color: inherit;}"),document.body.appendChild(o),e=React.createElement("div",{ref:function(e){e&&(copy(e,t),window.setTimeout(function(){ReactDOM.unmountComponentAtNode(o),document.body.removeChild(o)},0))},style:{whiteSpace:"pre",color:"inherit",backgroundColor:"inherit"}},e),ReactDOM.render(e,o))}function copy(e,t){var o=document.createRange(),n=window.getSelection();n.removeAllRanges(),o.selectNodeContents(e),n.addRange(o),document.execCommand("copy"),n.removeAllRanges(),t&&t()}export{copyToClipboard};