@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.
@@ -1 +1 @@
1
- export default function copyToClipboard(e){const t=String(e).trim().replace(/<br\s*\/?>/gi," "),o=navigator.clipboard;return(null==o?void 0:o.writeText)?hasOpaqueOrigin()?copyWithExecCommand(t).catch(()=>o.writeText(t)):o.writeText(t).catch(()=>copyWithExecCommand(t)):copyWithExecCommand(t)}function hasOpaqueOrigin(){var e;return"null"===(null!==(e=window.origin)&&void 0!==e?e:window.location.origin)}function copyWithExecCommand(e){if("function"!=typeof document.execCommand)return Promise.reject(new Error("copyToClipboard: document.execCommand is not available"));const t=document.getSelection();if(!t)return Promise.reject(new Error("copyToClipboard: the document has no selection"));const o=getRanges(t),n=createSelectableNode(e);try{document.body.appendChild(n);const o=document.createRange();return o.selectNodeContents(n),t.removeAllRanges(),t.addRange(o),String(t)!==e?Promise.reject(new Error("copyToClipboard: the text could not be selected")):document.execCommand("copy")?Promise.resolve():Promise.reject(new Error("copyToClipboard: the copy command failed"))}catch(e){return Promise.reject(e)}finally{n.remove(),t.removeAllRanges(),o.forEach(e=>t.addRange(e))}}function createSelectableNode(e){const t=document.createElement("span");return t.textContent=e,t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",t.style.whiteSpace="pre",t.style.textTransform="none",t.style.setProperty("user-select","text"),t.style.setProperty("-webkit-user-select","text"),t}function getRanges(e){const t=[];for(let o=0;o<e.rangeCount;o+=1)t.push(e.getRangeAt(o));return t}
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()}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claspo/common",
3
- "version": "7.5.6-cb1",
3
+ "version": "7.5.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {