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

Copy code button #499

Merged
merged 6 commits into from
Sep 3, 2024
Merged

Conversation

mansoorbarri
Copy link
Contributor

fixes: Add a copy button to code snippet #494

files changed:

  • static/css/main.css
  • static/js/main.css

screenshot:

image
from: /post/2017-03-07-bigimg-sample/

@hydr0nium
Copy link
Contributor

@mansoorbarri
Pretty could idea but I would like to propose some changes if possible:

  • replace Copy text with something like nice icon. Maybe something like this: 💾 could be used or similar. Could also be done via an option what to display
  • Show the copy button only if the code box is hovered.

@henryiii
Copy link
Collaborator

When I've done this in the past, I also filtered the beginning stuff from console.

$ echo "hi"
hi

Should only copy echo "hi".

@mansoorbarri
Copy link
Contributor Author

@mansoorbarri Pretty could idea but I would like to propose some changes if possible:

  • replace Copy text with something like nice icon. Maybe something like this: 💾 could be used or similar. Could also be done via an option what to display
  • Show the copy button only if the code box is hovered.

updated as requested.

@hydr0nium
Copy link
Contributor

Everything looks good now but is it on purpose that it is below the code?

image

Because I would still put it IN the code block. If that is fixed I would say it should be merge into main.

@mansoorbarri
Copy link
Contributor Author

not expected behaviour, let me have a look at it. it should always show on the top right.

@mansoorbarri
Copy link
Contributor Author

please have a look now. I couldn't find the particular post in the example site so this is just a blind fix.

@hydr0nium
Copy link
Contributor

hydr0nium commented Sep 1, 2024

First of all sorry for the confusion. The picture was an example of my own website. I probably should have tested it with the exampleSite. It is fixed now but I think your code was good even before. I believe the culprit at work was browser caching 🎉 as it probably cached some CSS, JS, etc wrong. After doing a hard reload today it worked fine.

But I've noticed some more things:

  • When copying on the example site and then pasting it, the code that is pasted has some spaces in front of each line
  • When copying the example with the line numbers, the line numbers are copy also.

I am not sure how fixable these things are though

@mansoorbarri
Copy link
Contributor Author

can you let me know the blog you are copying from?

@hydr0nium
Copy link
Contributor

I copied it from the default examples sites of the beautiful hugo sites. this post

@mansoorbarri
Copy link
Contributor Author

fixed

@hydr0nium
Copy link
Contributor

Works like a charm now. In my opinion this can be added @henryiii

@henryiii henryiii merged commit fd74af4 into halogenica:master Sep 3, 2024
1 check passed
@henryiii
Copy link
Collaborator

henryiii commented Sep 3, 2024

Thanks both!

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.

3 participants