just-the-docs icon indicating copy to clipboard operation
just-the-docs copied to clipboard

Arbitrary click-to-copy links

Open rachaelsalisbury opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. I've just implemented the new copy code button on a private project documentation site and am loving the copy functionality. I wonder if it would be possible to extend the logic to copying other things to the clipboard? ie copying an email address to a clipboard, or even if someone didn't need to see the "code" copied. For example, my use case is sharing a Google App Scripts library ID—it's totally fine to have that ID in a code block with a copy code button, but no one really needs to see that ID before copying it.

Describe the solution you'd like I am not a coder at all, so apologies for any "language barriers" here. Instead of a link button that would be formatted like:

[Click to open google](https://www.google.com/){: .btn}

something as easily customizable where clicking copies a stable string/code. I know this code wouldn't actually work since it's link formatting, but something as easy as:

[Click to copy](text to copy to clipboard){: .btn}

rachaelsalisbury avatar Apr 14 '23 00:04 rachaelsalisbury

Hi @rachaelsalisbury,

Thank you for submitting an issue! Hm, this is certainly an interesting idea. From my perspective, the biggest difference would be the styling - I'd imagine that you'd want this to look more like an inline link, rather than the actual copy code button? With that in mind, I think we'd want to add a new CSS class that just makes a link "copyable", and allow users to combine it with other CSS classes to style the button itself. What do you think?

(happy to further explore this and push it upstream)

mattxwang avatar Apr 20 '23 05:04 mattxwang