arronhunt / highlightjs-copy

πŸ“‹β‡οΈ A simple, accessible highlightjs plugin to add a copy button to your code blocks.

Home Page:https://highlightjs-copy.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This library does not work

hacktronics opened this issue Β· comments

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

import CopyButtonPlugin from "highlightjs-copy";
hljs.addPlugin( new CopyButtonPlugin());

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 #13 as it should fix your issue.

commented

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()).

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.

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.

commented

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? 😁

v1.0.4 was just published, please let me know if this resolves the issues πŸ™

commented

last version still shows 1.0.3 (2 years ago)

"highlightjs-copy": "^1.0.3",

@arronhunt still 1.0.3 on npm

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

1.0.4 is now published. Please πŸ‘ if this resolves the problem and I can close this issue :)

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