UNPKG

@aplus-frontend/ui

Version:

2 lines (1 loc) 642 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t,e){const o=e?.format;if(typeof t!="string")return!1;try{if(o==="text/html"){const r=new ClipboardItem({[o]:new Blob([t],{type:o}),"text/plain":new Blob([t],{type:"text/plain"})});navigator.clipboard.write([r])}else navigator.clipboard.writeText(t);return!0}catch{return a(t)}}function a(t){try{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();const o=document.execCommand("copy");return document.body.removeChild(e),o}catch{return!1}}exports.copy=n;