Open YavarR opened 1 year ago
I had the same problem with this. I ended up adding the file to my repo and changing the first line to:
module.exports = class CopyButtonPlugin {
Then I included it with:
const CopyButtonPlugin = require('./vendor/highlightjs-copy.js')
To initialize, I wrapped the code in a timeout because I found that it wouldn't work in Chrome otherwise:
setTimeout(() => { hljs.addPlugin(new CopyButtonPlugin()) hljs.highlightAll() }, 100)
I was having a similar issue, and I created a PR to export a default, https://github.com/arronhunt/highlightjs-copy/pull/21.
The previous change restricts the export to NodeJS environment, which did not work in my case.
Hi Arron I installed highlightjs-copy, But I can’t import it after npm install. Could you pleas help me. I already instals highlight.js and it works perfectly.
That is for highlight.js:
import hljs from 'highlight.js/lib/core'; import 'highlight.js/styles/base16/railscasts.css'; import javascript from 'highlight.js/lib/languages/javascript'