jperasmus / docsify-copy-code

A docsify plugin that copies Markdown code block to your clipboard
MIT License
99 stars 71 forks source link

Enhanced CopyCode plugin #73

Open robinmattern opened 6 months ago

robinmattern commented 6 months ago

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 Tagicon 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

jperasmus commented 6 months ago

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.