katoikia-app/web-ui/web-react/node_modules/prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js

1 line
973 B
JavaScript

!function(){if("undefined"!=typeof self&&self.Prism&&self.document){if(!Prism.plugins.toolbar)return console.warn("Copy to Clipboard plugin loaded before Toolbar plugin."),void 0;var o=window.Clipboard||void 0;o&&/(native code)/.test(o.toString())&&(o=void 0),o||"function"!=typeof require||(o=require("clipboard"));var t=[];if(!o){var e=document.createElement("script"),n=document.querySelector("head");e.onload=function(){if(o=window.Clipboard)for(;t.length;)t.pop()()},e.src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js",n.appendChild(e)}Prism.plugins.toolbar.registerButton("copy-to-clipboard",function(e){function n(){var t=new o(i,{text:function(){return e.code}});t.on("success",function(){i.textContent="Copied!",r()}),t.on("error",function(){i.textContent="Press Ctrl+C to copy",r()})}function r(){setTimeout(function(){i.textContent="Copy"},5e3)}var i=document.createElement("a");return i.textContent="Copy",o?n():t.push(n),i})}}();