Skip to content
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

Changing clipboard text from a callback #231

Closed
prionkor opened this issue Apr 25, 2016 · 8 comments
Closed

Changing clipboard text from a callback #231

prionkor opened this issue Apr 25, 2016 · 8 comments

Comments

@prionkor
Copy link

prionkor commented Apr 25, 2016

Example

There is a copy button on a table cell, when clicked some contents from <td> elements (child of a particular <tr> element) will be copied to clipboard (not all of them).

Is it possible? I have looked into documentation and didn't find anything related. I didn't see any types of custom event listener for this plugin. Perhaps I missed something?

@jamesryanbell
Copy link

I'm in this exact situation too! Does anyone know if this is possible?

Thanks,
James

@zenorocha
Copy link
Owner

Please share a JSFiddle so we can debug this.

@prionkor
Copy link
Author

Hello,

Please find the js fiddle link below. The main goal is to able to catch and modify the content just before plugin sends it to clipboard. This is a very simplistic example.

https://jsfiddle.net/sisir/0a2w6av3/2/

On my app I am trying to copy on a dblclick event. But I guess that is for another question.

@carlosjdelgado
Copy link

Maybe could be good to have the ability to concatenate in the clipboard the content of all targets matching certain class.
testing the fiddle i see that actually this is not possible.

https://jsfiddle.net/kganafuj/1/

@prionkor
Copy link
Author

prionkor commented Apr 29, 2016

Another idea that can be considered is a copy method that takes string and sends to clipboard. This will have a vast implementation use cases.

var clipboard = new Clipboard(); // no element passed
clipboard.copy('my text');

This will help implementing the plugin with keyboard shortcut library like Mousetrap

@prionkor
Copy link
Author

prionkor commented Apr 29, 2016

@carlosjdelgado Setting multiple target may be confusing to the plugin because it will not know which element it should be copy from. Considering if there are multiple element available using same class.

@zenorocha
Copy link
Owner

There are a number of errors on these JSFiddles.

  1. You're loading the GitHub raw path, which doesn't include the proper MIME type and therefore cannot be executed.
  2. You haven't read the documentation or checked the demo folder properly. It explains exactly how to use the imperative API.

Here's the end result @prionkor is looking for https://jsfiddle.net/zenorocha/d48hxmzy

@zenorocha
Copy link
Owner

Hey guys, I added a proposal for this feature. Can you check #518?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants