Page 1 of 1
Insert copy button to copy code inside a code block
Posted: Fri Feb 07, 2025 6:08 pm
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
Re: Insert copy button to copy code inside a code block
Posted: Mon Feb 10, 2025 8:42 am
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
Re: Insert copy button to copy code inside a code block
Posted: Mon Feb 10, 2025 11:50 am
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
Re: Insert copy button to copy code inside a code block
Posted: Mon Feb 10, 2025 1:13 pm
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