Copy markup in author mode

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
steve.cuzner
Posts: 72
Joined: Thu Mar 26, 2015 4:57 pm

Copy markup in author mode

Post by steve.cuzner » Mon Oct 03, 2016 10:39 pm

If I select a tag, e.g., <foo>text</foo>, and copy using ctrl+c or the menu items, then paste to another application, all that is pasted is "text" Is there setting or a special copy mode that includes markup into the paste buffer?

Radu
Posts: 7314
Joined: Fri Jul 09, 2004 5:18 pm

Re: Copy markup in author mode

Post by Radu » Tue Oct 04, 2016 8:39 am

Hi Steve,

Indeed the copy operation in the Author visual editing mode sets in the clipboard only the text content, with line breaks separating paragraphs.
We have an issue registered to add a special copy operation and I will add your feedback on it.
So right now you can either copy the content in the Text editing mode or maybe create a custom Author action.
For example the Javascript code to copy the XML content of the selection in the Author using a JSOperation should look something like:

Code: Select all

    if(authorAccess.getEditorAccess().hasSelection()){
frag = authorAccess.getDocumentController().createDocumentFragment(authorAccess.getEditorAccess().getSelectionStart(), authorAccess.getEditorAccess().getSelectionEnd() - 1);
xmlContent = authorAccess.getDocumentController().serializeFragmentToXML(frag);
Packages.java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new Packages.java.awt.datatransfer.StringSelection(xmlContent), null);
}
Based on discussions with users who use JSOperations I created a GitHub repository which contains sample operations for doing various things, I updated the repository to contain also a sample for copy XML to clipboard:

https://github.com/oxygenxml/javascript ... operations

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Radu
Posts: 7314
Joined: Fri Jul 09, 2004 5:18 pm

Re: Copy markup in author mode

Post by Radu » Fri Nov 20, 2020 1:37 pm

Hi,

We released Oxygen 23 which added in the main menu "Document->Edit" a "Copy as XML" action.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply