-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Copy without onClick Event #218
Comments
I would love to have this too but due to security restrictions imposed by browser vendors, user interaction is required in order copy/cut to work. A simulated click event using JavaScript does not work as this would enable clipboard poisoning. You might want to check https://www.npmjs.com/package/react-clipboard.js or https://www.npmjs.com/package/react-clip. Feel free to send a PR if you come up with something ;) |
Thanks for the explanation. I had a feeling it was something like that. Can we make a note of this somewhere in the documentation? |
We already have this on the wiki (https://github.com/zenorocha/clipboard.js/wiki/Known-Limitations), but as soon as we redesign the site we can include it over there. |
Hey guys, I added a proposal for this feature. Can you check #518? Thanks! |
Thank you for this issue. @mlucool |
I would like to suggest the API allow for a programatic copy without a click event. The use case here is better integration with a framework like React where I want to use react's onClick bindings.
Optimally it would work as:
After playing with the code, it seems that this could be accomplished by a singleton Clipboard in the copy function that tracks nothing.
I gave this a quick attempt via adding the following, but the
succeeded = document.execCommand(this.action)
inclipboard-action.js
returns false (does not throw). I am not sure why this would be the case when the normal clipboard via click works on the same page.Tested via:
Please let me know if you think this is a good idea and any suggestions on how to make it work. I can make the PR.
The text was updated successfully, but these errors were encountered: