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

Copy link and copy source buttons in snippet details #9

Open
tpetricek opened this issue Jun 29, 2015 · 8 comments
Open

Copy link and copy source buttons in snippet details #9

tpetricek opened this issue Jun 29, 2015 · 8 comments

Comments

@tpetricek
Copy link
Member

... are not implemented! They should copy the thing into clipboard (if we can do that without ugly hacks - if no, we should remove the buttons)

@abjrcode
Copy link
Contributor

abjrcode commented Jul 3, 2015

I have been looking around for a way to do this smoothly but it seems there is no "clean" way to do it.

Google Chrome has removed all APIs that grant access the clipboard and there is no standard API for the others browsers too.

There are two hacks that people are using to work around this.

  • You can either pop up a dialog containing the required text already selected and ask the user to print Ctrl-C or any other shortcut of course.
  • The other work around is injecting a flash script which grants you access to the clipboard. This is the popular solution because it stands out of the users way and it is used by GitHub itself when you copy a repository's URL with the copy button. They are using a famous third party library for this called ZeroClipboard.

Let me know what you think Tomas.

@tpetricek
Copy link
Member Author

Yeah, the current version of www.fssnip.net uses the Flash trick, but I don't think that's a very good solution. I quite like the idea of just doing a pop up dialog (perhaps some nice Bootstrap way) with a textbox where people can copy it, so I'd go for that option!

@abjrcode
Copy link
Contributor

abjrcode commented Jul 3, 2015

Okay. I am on it.

@abjrcode
Copy link
Contributor

abjrcode commented Jul 6, 2015

I am almost done but I honestly don't like the way things came up at last.
Anyway I will create a pull request soon and you could see for your self.

@tpetricek
Copy link
Member Author

This works in Chrome, but it seems to be broken in IE (on my machine at least).

Also, I'm not particularly keen on the blueish label in the dialog, so if we can make that white, that would be nicer (I think!)

@tpetricek
Copy link
Member Author

I couldn't figure out how to make this work in IE, so I added exception handler...

@abjrcode
Copy link
Contributor

Oh sorry I totally forgot about this in the mid of all the work I have, but yes I remember that accessing the clipboard in a uniform way across browsers is really hard. I miss F# and I hope to be able to participate again although I can't see it happening soon. Good luck

@kunjee17
Copy link
Contributor

@tpetricek have a look at clipboard.js whenever you have time. It is having decent browser support.

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

No branches or pull requests

3 participants