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

Add copy to clipboard button in code snippets #2

Merged
merged 24 commits into from
Jun 4, 2023
Merged

Conversation

DavG25
Copy link
Owner

@DavG25 DavG25 commented Jun 3, 2023

Add customized version (that works with Gradio and this extension) of highlightjs-copy to show a button in each code snippet that copies code

Requested in #1

@Starlento
Copy link

Extension commit ID: 6be5366
webui commit ID: 19f78684e6d32d43cd5ce3ae82d6f2216421b9ae
environment: WSL2

I tested the function. Overall, this works well. Thank you very much for your update.
One trival problem is that if code snippet is only one line, the button seems too large.
image

@DavG25
Copy link
Owner Author

DavG25 commented Jun 3, 2023

One trival problem is that if code snippet is only one line, the button seems too large. image

Thanks for pointing that out, it should be fixed in efe8b91 by increasing the code block height if it's too narrow when the copy button is present, can you confirm it works for you?

@DavG25
Copy link
Owner Author

DavG25 commented Jun 3, 2023

I've modified the behavior as changing the code block height made it seem like there were multiple lines

In the latest commit (548c3f5) the copy button should always fit inside the code block and only modify the height in edge cases

@Starlento
Copy link

I've modified the behavior as changing the code block height made it seem like there were multiple lines

In the latest commit (548c3f5) the copy button should always fit inside the code block and only modify the height in edge cases

It is perfect now.

@DavG25 DavG25 merged commit 2bd7b84 into master Jun 4, 2023
@DavG25 DavG25 deleted the feature-copy-button branch June 5, 2023 14:21
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.

2 participants