Insert copy button to copy code inside a code block

Post here questions and problems related to editing and publishing DITA content.
walker87
Posts: 2
Joined: Fri Feb 07, 2025 5:53 pm

Insert copy button to copy code inside a code block

Post by walker87 »

While in Author or Editor mode, is there a method of copying code from a code block in a webhelp page to the operating system's clipboard?
This page has a perfect example of what I want to do:
https://www.oxygenxml.com/doc/versions/ ... -html.html
I want to be able to include this button in my HTML output:
image.png
The idea is to make for a better user experience when the user is viewing code samples in the Online Help.
Any help would be much appreciated.
Thanks
You do not have the required permissions to view the files attached to this post.
Radu
Posts: 9472
Joined: Fri Jul 09, 2004 5:18 pm

Re: Insert copy button to copy code inside a code block

Post by Radu »

Hi,

Thanks for the feature request!
Right now we do not have a special copy action for code blocks when working in the Text/Author visual editing modes.
I added an internal issue based on your request, pasting the issue ID below for future reference:
EXM-55272 Copy action for code blocks
If we get to fix this issue in a future version I will update this forum thread.

As a possible workaround at least for the Author visual editing mode, I would triple click inside the codeblock to select it completely and then cut or copy it. Triple click works also in the Text mode, it will also copy the <codeblock> tags though if you plan to paste afterwards in a Notepad or some other external application.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
walker87
Posts: 2
Joined: Fri Feb 07, 2025 5:53 pm

Re: Insert copy button to copy code inside a code block

Post by walker87 »

Hi Radu,

Thanks for getting back to me and thanks very much for raising the feature request.

Another question. How did you include this copy button in your HTML output? This is what I want to achieve.
image.png
Thanks
You do not have the required permissions to view the files attached to this post.
Radu
Posts: 9472
Joined: Fri Jul 09, 2004 5:18 pm

Re: Insert copy button to copy code inside a code block

Post by Radu »

Hi,
The WebHelp publising is part of our commercial offering, its code is not open source. You can probably search online for similar ways to add copy buttons via Javascript.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply