Support for copying to clipboard
Description
Our pages allow users to copy the share URL, (in addition to basic social sharing). To allow our pages to support AMP, we need to be able to copy content to clipboard without JS.
Current feature is provided by a 3rd party tool clipboardjs. We cannot find equivalent functionality.
Example
https://gfycat.com/BareSecondaryFlamingo Click on the embed </> button below the video Click on the copy to clipboard icon
This would be great, as long as we don't do the spammy text-selection hijacking.
Would be a neat addition to amp-social-share.
@koshka Would you be interested in implementing this and contributing it to the project?
Hello! As per the Contributing Guidelines I'd like to show an "intent to implement", a Pull request for this issue.
I plan on using something like: https://www.sitepoint.com/javascript-copy-to-clipboard/ , and clipboard.js for any other reference :smile:
I agree with @jridgewell, and try to make the component specifically display the text that will be copied.
@torch2424: That'd be lovely.
I wonder if requiring the show the URL is a little too opinionated. Awesome you are working on this @torch2424!!
Just Finished this. Probably have a PR opened in today, or within the next week. Currently wrapping up the validator, and some Docs
It was concluded that due to lack of cross browser support, this is infeasible. Should not be a GFI candidate anymroe.
<amp-story> supports this. Given that, is there any reason <amp-social-share> can't?
We should definitely support copy to clipboard.
On Thu, Mar 29, 2018 at 10:01 AM, Taymon A. Beal [email protected] wrote:
supports this. Given that, is there any reason can't? — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ampproject/amphtml/issues/4853#issuecomment-377302861, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFeTz-gjsvL4eH1__wmbfjwNR20IoS4ks5tjRNigaJpZM4J3dmW .
As a drive-by comment: we implement this with an amp-iframe that just loads a tiny page containing a copy button with regular JS. We have a placeholder button in the top-level page, which is almost immediately replaced with the iframe.
Just wanted to bump this a little bit, totally forgot, but @sebastianbenz and I discussed how this would be really helpful for AMP By Example, and the upcoming amp.dev at the contributor summit. Would be cool if we could get something going on this, especially since a lot of issues I had with my original PR, are now fixed in later versions of mobile safari (i think) 😄
Here's the iframe solution: https://ampbyexample.com/advanced/copy_button/preview/
@samthor Thank you for this! Great that we have a link in the issue in case someone else comes across this 👍
For amp.dev it'd be great to have the ability to copy code snippets from the documentation samples. For this case It'd be great to have a simple copy action which specifies a node and recursively concatenates all child text nodes to a single string which is then added to the clipboard:
<button on="tap:mySnippet.copyToClipboard">
<pre id="mySnippet">
Code ...
</pre>
Hey @torch2424 are there any updates on this? It'd be really fantastic to have this available for amp.dev.
@sebastianbenz My apologies! Wasn't sure if the iframe solution would suffice or not. I will pass this around the team in mountain view, and see if we can get some traction on this 👍
cc @nainar - can you investigate prioritization?
I'll let @nainar investigate/prioritize this. Feel free to reach out to me on this topic, I actually made an extension for this about a year and a half ago, so before we start implementation perhaps we can possibly re-use some of that code (probably not though).
Thanks for catching this @rudygalfi ! 😄
@aghassemi You marked this "soon" about 6 months ago. Is there any plans to work on it ? Thank you !
Hi @catherinehoule, would the solution outlined on https://ampbyexample.com/advanced/copy_button/preview/ work for you and unblock you?