fuc-new/doc/node_modules/@vuepress/plugin-copy-code/lib/client/useCopyCode-D3STBXy7.js
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

3 lines
2.9 KiB
JavaScript

import{useLocale as L,Message as A}from"@vuepress/helper/client";import{useMediaQuery as C,watchImmediate as M,useClipboard as N,useEventListener as g}from"@vueuse/core";import{computed as _,nextTick as k}from"vue";import{onContentUpdated as z}from"vuepress/client";import"@vuepress/helper/message.css";import"./styles/copy-code.css";import"./styles/vars.css";const I='<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#06a35a"><path d="M822.812 824.618c-83.076 81.992-188.546 124.614-316.05 127.865-122.085-3.251-223.943-45.873-305.935-127.865S76.213 640.406 72.962 518.682c3.251-127.503 45.873-232.973 127.865-316.05 81.992-83.075 184.211-126.058 305.936-129.309 127.503 3.251 232.973 46.234 316.049 129.31 83.076 83.076 126.059 188.546 129.31 316.05-2.89 121.723-46.234 223.943-129.31 305.935zM432.717 684.111c3.973 3.974 8.307 5.78 13.364 6.14 5.057.362 9.753-1.444 13.365-5.417l292.57-287.515c3.974-3.973 5.78-8.307 5.78-13.364s-1.806-9.753-5.78-13.365l1.807 1.806c-3.973-3.973-8.669-5.779-14.087-6.14-5.418-.361-10.475 1.445-14.809 5.418L460.529 592.006c-3.973 3.25-8.669 4.695-14.448 4.695-5.78 0-10.836-1.445-15.531-3.973l-94.273-72.962c-4.335-3.251-9.392-4.335-14.448-3.973s-9.392 3.25-12.642 7.585l-2.89 3.973c-3.25 4.334-4.334 9.391-3.973 14.81.722 5.417 2.528 10.113 5.779 14.086L432.717 684.11z"/></svg>',R=/language-(shellscript|shell|bash|sh|zsh)/,T=({selector:h,ignoreSelector:i,inlineSelector:u,duration:n=2e3,locales:v,showInMobile:b,transform:p})=>{if(__VUEPRESS_SSR__)return;const f=C("(max-width: 419px)"),s=_(()=>!f.value||b),a=L(v),y=o=>{if(o.hasAttribute("copy-code"))return;const e=document.createElement("button");e.type="button",e.classList.add("vp-copy-code-button"),e.setAttribute("aria-label",a.value.copy),e.setAttribute("data-copied",a.value.copied),o.parentElement?.insertBefore(e,o),o.setAttribute("copy-code","")},d=()=>{document.body.classList.toggle("no-copy-code",!s.value),s.value&&document.querySelectorAll(h).forEach(y)};M(s,()=>k(d),{flush:"post"}),z(o=>{o!=="beforeUnmount"&&d()});const{copy:m}=N({legacy:!0}),l=new WeakMap;let w=null;const S=async(o,e,t)=>{const c=e.cloneNode(!0);i&&c.querySelectorAll(i).forEach(x=>{x.remove()}),p&&p(c);let r=c.textContent||"";if(R.test(o.className)&&(r=r.replace(/^ *(\$|>) /gm,"")),await m(r),n<=0)return;t.classList.add("copied"),clearTimeout(l.get(t));const E=setTimeout(()=>{t.classList.remove("copied"),t.blur(),l.delete(t)},n);l.set(t,E)};g("click",o=>{const e=o.target;if(s.value&&e.matches('div[class*="language-"] > button.vp-copy-code-button')){const t=e.parentElement,c=e.nextElementSibling;if(!t||!c)return;S(t,c,e)}},{passive:!0}),u&&g("dblclick",o=>{const e=o.target;if(s.value&&e.matches(u)){const t=window.getSelection();t&&(e.contains(t.anchorNode)||e.contains(t.focusNode))&&t.removeAllRanges(),m(e.textContent||""),(w??=new A).pop(`${I}<span>${a.value.copied} </span>`,n)}},{passive:!0})};export{T as u};
//# sourceMappingURL=useCopyCode-D3STBXy7.js.map