Copy markup in author mode

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
steve.cuzner
Posts: 69

Copy markup in author mode

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: 5749

Re: Copy markup in author mode

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-sample-operations

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

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 0 guests