mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
1.9 KiB
2 lines
1.9 KiB
2 years ago
|
import{t as p}from"./toggle-selection-93f4ad84.js";var v=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},y=p,f={"text/plain":"Text","text/html":"Url",default:"Text"},m="Copy to clipboard: #{key}, Enter";function g(o){var a=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return o.replace(/#{\s*key\s*}/g,a)}function b(o,a){var r,i,d,n,l,e,c=!1;a||(a={}),r=a.debug||!1;try{d=y(),n=document.createRange(),l=document.getSelection(),e=document.createElement("span"),e.textContent=o,e.ariaHidden="true",e.style.all="unset",e.style.position="fixed",e.style.top=0,e.style.clip="rect(0, 0, 0, 0)",e.style.whiteSpace="pre",e.style.webkitUserSelect="text",e.style.MozUserSelect="text",e.style.msUserSelect="text",e.style.userSelect="text",e.addEventListener("copy",function(t){if(t.stopPropagation(),a.format)if(t.preventDefault(),typeof t.clipboardData>"u"){r&&console.warn("unable to use e.clipboardData"),r&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var s=f[a.format]||f.default;window.clipboardData.setData(s,o)}else t.clipboardData.clearData(),t.clipboardData.setData(a.format,o);a.onCopy&&(t.preventDefault(),a.onCopy(t.clipboardData))}),document.body.appendChild(e),n.selectNodeContents(e),l.addRange(n);var u=document.execCommand("copy");if(!u)throw new Error("copy command was unsuccessful");c=!0}catch(t){r&&console.error("unable to copy using execCommand: ",t),r&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(a.format||"text",o),a.onCopy&&a.onCopy(window.clipboardData),c=!0}catch(s){r&&console.error("unable to copy using clipboardData: ",s),r&&console.error("falling back to prompt"),i=g("message"in a?a.message:m),window.prompt(i,o)}}finally{l&&(typeof l.removeRange=="function"?l.removeRange(n):l.removeAllRanges()),e&&document.body.removeChild(e),d()}return c}var D=b;export{D as a,v as c};
|