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.2KB

  1. !function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var c=window.ClipboardJS||void 0;c||"function"!=typeof require||(c=require("clipboard"));var u=[];if(!c){var t=document.createElement("script"),o=document.querySelector("head");t.onload=function(){if(c=window.ClipboardJS)for(;u.length;)u.pop()()},t.src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js",o.appendChild(t)}Prism.plugins.toolbar.registerButton("copy-to-clipboard",function(t){var o=t.element,e=function(t){var o={copy:"Copy","copy-error":"Press Ctrl+C to copy","copy-success":"Copied!","copy-timeout":5e3};for(var e in o){for(var n="data-prismjs-"+e,r=t;r&&!r.hasAttribute(n);)r=r.parentElement;r&&(o[e]=r.getAttribute(n))}return o}(o),n=document.createElement("button");return n.textContent=e.copy,n.setAttribute("type","button"),c?r():u.push(r),n;function r(){var t=new c(n,{text:function(){return o.textContent}});t.on("success",function(){n.textContent=e["copy-success"],i()}),t.on("error",function(){n.textContent=e["copy-error"],i()})}function i(){setTimeout(function(){n.textContent=e.copy},e["copy-timeout"])}})}else console.warn("Copy to Clipboard plugin loaded before Toolbar plugin.")}();