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

it is a good plugin but I wonder why I have to bind to a specific DOM rather than provide API only for freely use #446

Closed
codeh2o opened this issue Jul 12, 2017 · 5 comments

Comments

@codeh2o
Copy link

codeh2o commented Jul 12, 2017

Minimal example

Fork this JSFiddle and reproduce your issue.

Expected behaviour

I thought that by going to the page '...' and pressing the button '...' then '...' would happen.

Actual behaviour

Instead of '...', what I saw was that '...' happened instead.

Browsers affected

I tested on all major browsers and only IE 11 does not work.

@cesarpachon
Copy link

Agree on this. I am working on HTML5 games that only have a root canvas element. I need to fire the clipboard behaviour from a custom callback (that, following the framework chain, by sure will start eventually at some canvas.onClick handler). it would be great if I can fire clipboard.copy(mytext) directly.

@gengshenghong
Copy link

Agree with @cesarpachon Hope it will be possible to use clipboard.copy freely!!! It is sometimes difficult to create a button (DOM) bind to the clipboard directly....

@djmattyg007
Copy link

This was asked previously and the request was denied: #329

@darylteo
Copy link

darylteo commented Oct 10, 2017

This library is great for handling the cross browser concerns when it comes to copying. However there are modern situations where a blanket DOM selector isn't necessary.

  • If you're using a component based front end (i.e. angular, react etc.), you'll be instantiating new Clipboard() for every component each time to attach a dom click event to a button.
  • the component framework you're using will have established patterns for handling user interactions in built. There is no need to throw in another DOM level event listener.
  • even when using a global selector, relying on the presence of a global level event delegator would violate encapsulation of components.

Anyway, just my opinion. We're just ended up writing a function that simply spawns a new ClipboardAction with dummy options after a click event, which is still within the bounds of the execCommand security restrictions.

@zenorocha
Copy link
Owner

That's a very important argument @darylteo, thanks for sharing. I created an issue for us to track this new functionality #518.

Let me know what you guys think about it.

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

6 participants