docsify-copy-code icon indicating copy to clipboard operation
docsify-copy-code copied to clipboard

Enhanced CopyCode plugin

Open robinmattern opened this issue 1 year ago • 1 comments

I'm using your CopyCode plugin for Docsify. It works great. But I see some enhanced versions of it on GitHub and your cdnjs library webpage. The image below shows three versions of it.

  1. The one available here only has a Text copy button.
  2. The one on GitHub when I preview a markdown page has Copy icon as the button. It also displays a Play / Pause icon when it detects a .gif file
  3. The one on your cdnjs site that has a Copy URL icon, a "Copy Script Tag icon and a 1Copy SRI Hash icon.

Do you know where versions of these enhanced CopyCode plugin are. Or perhaps you could point me to some code that I might use to create such a plugin myself. One that works with any markdown add-in script would be great, as I suspect the GitHub site is using.

image

robinmattern avatar Feb 15 '24 17:02 robinmattern

Hi @robinmattern

I don't know off the top of my head which library Github is using for these enhanced copy-to-clipboard buttons. It is likely something they build in-house. If you want to create your own plugin, you could start by forking this repo and then changing it to your needs. The code is only a single JavaScript file with some CSS. It finds any <pre> tag with a [data-lang] attribute and adds the copy-to-clipboard button to it.

jperasmus avatar Feb 20 '24 18:02 jperasmus