arronhunt / highlightjs-copy

📋❇️ A simple, accessible highlightjs plugin to add a copy button to your code blocks.
https://highlightjs-copy.netlify.app
The Unlicense
96 stars 23 forks source link

This library does not work #14

Closed hacktronics closed 9 months ago

hacktronics commented 1 year ago

Uncaught TypeError: highlightjs_copyWEBPACK_IMPORTED_MODULE3default(...) is not a function followed:

import CopyButtonPlugin from "highlightjs-copy";
hljs.addPlugin( new CopyButtonPlugin());
packet-sent commented 1 year ago

I had a similar issue with vite, the error seems to be caused by CopyButtonPlugin not being exported in the current npm package. You can look at https://github.com/arronhunt/highlightjs-copy/pull/13 as it should fix your issue.

yehiaabdelm commented 1 year ago

In the index.js of the package add module.exports = CopyButtonPlugin to the end of the file. Then run npx patch-package highlightjs-copy in your terminal. Then in your js file import CopyButtonPlugin from 'highlightjs-copy' and run hljs.addPlugin(new CopyButtonPlugin()).

mrsimonemms commented 1 year ago

The version in npm is 1.0.3, the latest version in GitHub is 1.0.4. It just needs to be published by the author.

hacktronics commented 1 year ago

I am no longer tracking this issue, so you can close the same if required. I created my own simple copy plugin, as was running out of time.

yehiaabdelm commented 1 year ago

I am no longer tracking this issue, so you can close the same if required. I created my own simple copy plugin, as was running out of time.

Can you share your code? 😁

arronhunt commented 1 year ago

v1.0.4 was just published, please let me know if this resolves the issues 🙏

Madd0g commented 1 year ago

last version still shows 1.0.3 (2 years ago)

mrsimonemms commented 1 year ago

Confirmed as 1.0.3

dobeerman commented 1 year ago
"highlightjs-copy": "^1.0.3",
unkn-wn commented 1 year ago

@arronhunt still 1.0.3 on npm

msjoshlopez commented 1 year ago

I still cant get this to work. The latest on npm is still 1.0.3

arronhunt commented 1 year ago

1.0.4 is now published. Please 👍 if this resolves the problem and I can close this issue :)

arronhunt commented 9 months ago

@hacktronics I'm closing this issue since we are now a few versions ahead. Please reopen if you have further problems!