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

Added a copy to clipboard button to <pre> blocks for easy clipboard interaction #88

Merged
merged 15 commits into from
Jan 3, 2023

Conversation

reactorcoremeltdown
Copy link
Contributor

Summary

I find it really convenient to copy text from <pre> blocks directly to clipboard with a single button.

image

Details

This pull request adds:

  • A vendor script that copies contents of <pre> blocks into clipboard using a button
  • A notyf.js toast pill library for some eye-candy

Checks

  • In case of new feature, add short overview in docs/<corresponding file>
  • Tested changes

@Linbreux
Copy link
Owner

Hi @reactorcoremeltdown
Really like this, was also thinking on implementing this! Also the popup looks clean :)
I don't know if the button style fits the wiki style

Maybe something like this would fit a bit better (with you nice toast of course) :
image
Feel free to suggest alternatives

@reactorcoremeltdown
Copy link
Contributor Author

Thanks a lot for reviewing and for suggestions!

Indeed, the button looks somewhat alien, so I'll give another try to https://clipboardjs.com/

BRB

@reactorcoremeltdown
Copy link
Contributor Author

BTW, I'll have to be careful about mobile layouts, display on hover does not work well sometimes.

@reactorcoremeltdown
Copy link
Contributor Author

image

So I think this looks much prettier.

What's changed:

  • Changed button title to emoji to make it smaller
  • Added a tooltip to the button
  • Placed the button in a top-right corner (requires CSS adjutments for both <pre> and <button> elements)
  • Enabled word-wrapping for <pre> tags

I hope that all makes sense! So far it looks and works good on both desktop and mobile layouts, but if you find anything that doesn't fit, please let me know!

@Linbreux Linbreux merged commit 885273b into Linbreux:main Jan 3, 2023
@Linbreux
Copy link
Owner

Linbreux commented Jan 5, 2023

Thanks for the contribution, it works great! I changed the icon to something a little more modern in 925be59.

@reactorcoremeltdown
Copy link
Contributor Author

Thanks for the contribution, it works great! I changed the icon to something a little more modern in 925be59.

Thank YOU for your patience, your support, and overall for such an amazing project!

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