The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

How to more easily copy & paste from e.g. a {code} block?

Simon Hardy-Francis
August 23, 2011

Let's say I have a {code}echo my line of code{code} block. If the reader wants to copy and paste the 'mycode' text from the wiki page then they must do it with the mouse etc. Very fiddly if doing often. Is there a way to provide some sort of icon which when pressed simply copies the contents of the code block into the copy and paste buffer? Or maybe there is a non-{code} block alternative?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Thomas Wendel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 31, 2011

Hi Simon,

As far as I know, double-clicking into the code block will at least select all the code.

Copy/Paste functionality is always a bit tricky to implement into web applications, although possible. Most browsers prohibit the copy/paste functionality as it is a security vulnerability if a web page can read a visitors clipboard. Therefore in Firefox, the user has to tweak the about:config to let JavaScript read and write the local clipboard. Other methods use Java applets to interact with the local clipboard, which is also not nice. So I think this is the reason, why such a click-to-copy button has not been implemented into the {code}-macro yet.

So double-clicking might be your best option so far.

Cheers,

Thomas

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 31, 2011

Most sites including bitbucket use Flash for copypaste which seems to work perfectly fine.

Thomas Wendel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 31, 2011

Copy/paste with Flash may work perfectly fine, true. But it is still a security risk and it uses, well...., Flash. ;-)

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 31, 2011

Anyway I just mentioned Flash for completeness as you had talked about java applets and javascript...

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 31, 2011

I'm not really a Flash fan but looking on most web sites it's the de facto standard for clipboard manipulation... I have the flash blocker plugin but I don't mind enabling flash for those sites where I want to copy from the code blocks.

TAGS
AUG Leaders

Atlassian Community Events