website icon indicating copy to clipboard operation
website copied to clipboard

add copy to clipboard functionality

Open danditomaso opened this issue 2 years ago • 5 comments
trafficstars

This adds the copy to clipboard feature that is available on many documentation websites. It sits inline with the text, so there wont be any cases where it will overlap existing content.

Clicking the copy button takes the contents inside the code block and copies it to your clipboard, you receive a tooltip when clicking it that disappears after a second. I'm open to tweaking the timing on the tooltip if it feels slow.

danditomaso avatar Aug 11 '23 20:08 danditomaso

Hmm, this had some side-effects on /docs/install. For example, the Debian section's commands have a lot more padding now.

Before:

image

After:

image

Also I'm only seeing the copy button on some of the blocks on this page. I'm not sure why though, they aren't significantly different other than missing the button :thinking: Probably just a selector bug.

francislavoie avatar Aug 11 '23 20:08 francislavoie

Hmm, this had some side-effects on /docs/install. For example, the Debian section's commands have a lot more padding now.

Before:

image

After:

image

Also I'm only seeing the copy button on some of the blocks on this page. I'm not sure why though, they aren't significantly different other than missing the button 🤔 Probably just a selector bug.

@francislavoie I'm seeing the same thing, I've added some changes to fix that in other locations. I think a better fix for this is for any case where there is a code element along with more than one span, is to add an inner div, keep the cmd's within that inner element along with some padding. Then absolutely position the copy button outside of that code block, which will ensure it wont overlap any text. I wont have a chance to update this PR with thos fixes until late afternoon today if that is alright?

danditomaso avatar Aug 14 '23 14:08 danditomaso

No rush at all 👍 take your time

francislavoie avatar Aug 14 '23 14:08 francislavoie

Yeah, thanks for working on that! No problem, we're not in a hurry :)

mholt avatar Aug 14 '23 15:08 mholt

Is this ready to merge? If not, feel free whenever it's ready :)

mholt avatar Sep 07 '23 21:09 mholt