Skip to content

Add frontend feature : copy to clipboard button to the code snippets#728

Open
vimode wants to merge 1 commit intoalan-turing-institute:mainfrom
vimode:feat-copy-to-clipboard
Open

Add frontend feature : copy to clipboard button to the code snippets#728
vimode wants to merge 1 commit intoalan-turing-institute:mainfrom
vimode:feat-copy-to-clipboard

Conversation

@vimode
Copy link
Contributor

@vimode vimode commented Feb 17, 2026

Summary

Added the feature to click and copy code to clipboard on the frontend.
Before the code snippets look like
image

And with the new component to copytoclipboard it looks like
image

List of changes proposed in this PR (pull-request)

  • Added a new component that handles the logic to copy text to clipboard
  • Updated SingleView component to use the new CopyToClipboard component.

I tested them with a few model pages and everything renders and works as expected but if you find a model page that it does not work on properly, please let me know.

Thank you.

@vimode
Copy link
Contributor Author

vimode commented Feb 17, 2026

The Clipboard API's writeText() method is widely available so it should be compatible with all the latest browser versions.

https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText

@vimode
Copy link
Contributor Author

vimode commented Feb 18, 2026

I noticed the scivisionpy page also has code blocks but it uses markdown-to-jsx library.
I looked into the library and it allows overrides to add functionality to certain components rendered from the markdown.
If this PR seems fine I can work on trying to add the copy button to those code blocks too.

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

Successfully merging this pull request may close these issues.

1 participant

Comments