I2I: Create an Bento component for copy to clipboard functionality
See original GitHub issueSummary
This I2I proposes the copy to clipboard
button. This button will allow users to copy any (specified in button attribute) content present in the document/page to the clipboard.
Design Document
We would like to introduce a new component amp-copy
which will copy specified content into the clipboard.
Attributes:
sourceId
- In this attribute, we can specify from where the content should get copied. This can be theid
of anyHTML
tag (e.gdiv
,p
,pre
,code
etc.) from where we want to fetch the content. We can also provide theid
of anyinput
tag here.text
- Any text passed to this attribute will get copied to theclipboard
. Preference will be given to thesourceId
attribute. IfsourceId
is not specified, we will look for thetext
attribute.
Examples of both the attributes:
- Copy content from the
div
tag
<div id="myDiv1">
<p> hello world </p>
</div>
<amp-copy width="100" height="20" source-id="myDiv1">
Copy Content
</amp-copy>
- Copy content from the
text
tag
<amp-copy width="100" height="20" text="copy this line">
Copy Content
</amp-copy>
This component doesn’t expose a postMessage interface.
Motivation
Currently, there’s no direct way to add the copy to clipboard
button on pages. We need a simple way to add such buttons on pages that will allow a wide range of users/publishers to allow their audience/users to copy content which just a single click.
Alternative Solutions
There’s a way to add the copy button
button on AMP pages. This solution involves adding an iframe
to the page. Using iframe
for copy seems to be overkill.
Launch Tracker
No response
Notifications
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Cut, Copy and Paste in JavaScript with the Clipboard API
Copying and pasting text will be a useful option in most applications. The API is refreshingly simple: // copy text TO the clipboard...
Read more >Untitled
Q796 vst, Jual kawat bendrat jakarta, Functional rear air brake spoiler, ... Salame nel budello gentile, Create td element javascript, I am so...
Read more >winamp5666_full_en-us_redux.exe - Hybrid Analysis
Spyware/Leak: Contains ability to open the clipboard. Contains ability to retrieve keyboard strokes; Fingerprint: Reads the active computer ...
Read more >jTo - ALBA.Net
Six ways to die 2015, Bucegi pate concurs, Matematikashi, Processos da area de vendas, Modern sliding doors melbourne, Plastic tadpatri making machine, ...
Read more >frequent-classes - CodaLab Worksheets
... collapsed 8693 cta 8638 level 8545 required 8541 copy 8514 vertical 8452 ... updated 3373 component 3368 shop 3364 player 3361 preview...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for the detailed reply. This approach makes more sense. Let me give it a try. Let me check the feasibility of this approach and I will get back to you.
Can you tell me more about the CSS classes? Could we for instance also expose events to cover this interaction? Since
toggleClass
is an action, I can imagine an API like this:You could also have a button that copies the
textContent
from something else:Note that the
copySuccess
event would (in this example, at least) fire on the target element forcopyToClipboard
. Maybe it would make more sense on the element that calls it, not sure.