![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
highlightjs-copy
Advanced tools
A simple, accessible highlightjs plugin to add a copy button to your codeblocks.
A simple, accessible highlightjs plugin to add a copy button to your codeblocks.
<script src="https://unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.js"></script>
<link
rel="stylesheet"
href="https://unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.css"
/>
npm install highlightjs-copy
hljs.addPlugin(new CopyButtonPlugin());
hljs.addPlugin(
new CopyButtonPlugin({
callback: (text, el) => console.log("Copied to clipboard", text),
})
);
hljs.addPlugin(
new CopyButtonPlugin({
hook: (text, el) => text + "\nCopied from my cool website.",
})
);
<!-- Code block example -->
<pre>
<code class="language-bash" data-replace="{{YOUR_API_KEY}}" data-replaceWith="grtf32a35bbc...">
gretel configure --key {{YOUR_API_KEY}}
</code>
</pre>
<script>
hljs.addPlugin(
new CopyButtonPlugin({
hook: (text, el) => {
let { replace, replacewith } = el.dataset;
if (replace && replacewith) {
return text.replace(replace, replacewith);
}
return text;
},
callback: (text, el) => {
/* logs `gretel configure --key grtf32a35bbc...` */
console.log(text);
},
})
);
hljs.highlightAll();
</script>
CSS selector | Details |
---|---|
.hljs-copy-wrapper | Applied to the parent <pre> element that wraps the .hljs code. |
.hljs-copy-button | The copy button itself. The variable --hljs-theme-background is automatically applied to the parent element. This allows the button to inherit the code block's background color. |
[data-copied='true'] | This data attribute is applied to the copy button and is set to true for two seconds when the copy action is performed. |
.hljs-copy-alert | A visually hidden status element that announces the copy confirmation to screen readers. |
FAQs
A simple, accessible highlightjs plugin to add a copy button to your codeblocks.
The npm package highlightjs-copy receives a total of 0 weekly downloads. As such, highlightjs-copy popularity was classified as not popular.
We found that highlightjs-copy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.