Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Prism Plugin Copy to Clipboard Button #454

Open
wyattowalsh opened this issue Mar 5, 2023 · 1 comment
Open

Support for Prism Plugin Copy to Clipboard Button #454

wyattowalsh opened this issue Mar 5, 2023 · 1 comment

Comments

@wyattowalsh
Copy link

Hi there 👋

For my Next.js app that uses MDX, I am utilizing this plugin for code blocks (w/ syntax highlighting) support within my MDX.

I would love to have the Prism extension Copy to Clipboard Button supported so that my code blocks could have a copy button.

Is this possible? I'm happy to help contribute the necessary code if someone could help point me in the right direction 🫡

Thanks and best wishes

@gary-archer
Copy link

gary-archer commented Apr 7, 2024

In case it helps anyone, I also ran into this and there is a pretty good solution in this online link. In your layout file you use code like this and then add some code to update <pre><code> elements:

const rootRef = useRef<HTMLDivElement>(null);
useEffect(() => {
    addCopyToClipboardButtons(rootRef);
}

You can see my PostView for an example, and adapt it further if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants