@claspo/common 7.5.6-cb1 → 7.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dom/copyToClipboard.js +1 -1
- package/package.json +1 -1
package/dom/copyToClipboard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function copyToClipboard(e){const
|
|
1
|
+
export default function copyToClipboard(e){var t;const o=String(e).trim().replace("<br>"," ");return(null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(o).catch(()=>copyWithExecCommand(o)):copyWithExecCommand(o)}function copyWithExecCommand(e){if("function"!=typeof document.execCommand)return Promise.reject();const t=document.createElement("textarea");try{t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t);const o=document.createRange();o.selectNodeContents(t);const n=document.getSelection();return n&&(n.removeAllRanges(),n.addRange(o)),t.setSelectionRange(0,e.length),document.execCommand("copy")?Promise.resolve():Promise.reject()}catch(e){return Promise.reject(e)}finally{t.remove()}}
|