amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Support for copying to clipboard

Open koshka opened this issue 10 years ago • 29 comments

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

koshka avatar Sep 07 '16 23:09 koshka

This would be great, as long as we don't do the spammy text-selection hijacking.

jridgewell avatar Sep 08 '16 00:09 jridgewell

Would be a neat addition to amp-social-share.

@koshka Would you be interested in implementing this and contributing it to the project?

cramforce avatar Sep 08 '16 00:09 cramforce

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 avatar Jan 03 '17 05:01 torch2424

@torch2424: That'd be lovely.

jridgewell avatar Jan 03 '17 19:01 jridgewell

I wonder if requiring the show the URL is a little too opinionated. Awesome you are working on this @torch2424!!

cramforce avatar Jan 04 '17 22:01 cramforce

Just Finished this. Probably have a PR opened in today, or within the next week. Currently wrapping up the validator, and some Docs

torch2424 avatar Feb 19 '17 23:02 torch2424

It was concluded that due to lack of cross browser support, this is infeasible. Should not be a GFI candidate anymroe.

sohanirao avatar Feb 09 '18 19:02 sohanirao

<amp-story> supports this. Given that, is there any reason <amp-social-share> can't?

taymonbeal avatar Mar 29 '18 17:03 taymonbeal

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 .

cramforce avatar Mar 29 '18 17:03 cramforce

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.

samthor avatar Jul 25 '18 02:07 samthor

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) 😄

torch2424 avatar Oct 16 '18 21:10 torch2424

Here's the iframe solution: https://ampbyexample.com/advanced/copy_button/preview/

samthor avatar Oct 16 '18 22:10 samthor

@samthor Thank you for this! Great that we have a link in the issue in case someone else comes across this 👍

torch2424 avatar Oct 16 '18 22:10 torch2424

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>

sebastianbenz avatar Oct 26 '18 18:10 sebastianbenz

Hey @torch2424 are there any updates on this? It'd be really fantastic to have this available for amp.dev.

sebastianbenz avatar Jan 11 '19 10:01 sebastianbenz

@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 👍

torch2424 avatar Jan 11 '19 19:01 torch2424

cc @nainar - can you investigate prioritization?

rudygalfi avatar Jan 11 '19 21:01 rudygalfi

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 ! 😄

torch2424 avatar Jan 11 '19 22:01 torch2424

@aghassemi You marked this "soon" about 6 months ago. Is there any plans to work on it ? Thank you !

catherinehoule avatar Feb 28 '20 14:02 catherinehoule

Hi @catherinehoule, would the solution outlined on https://ampbyexample.com/advanced/copy_button/preview/ work for you and unblock you?

aghassemi avatar Feb 28 '20 14:02 aghassemi