The "ClipboardFragmentProcessor" is called on the clipboard content, so indeed as you found out it's too late to do something about this after the object has been cloned and copied to the clipboard.Maybe if you add a listener before the "Copy" action is being executed you could try to adjust the offsets of the selection, something like:

and this works also for the text page but from what I tested only when the "Copy" action is invoked from the main menu.When the "Ctrl-C" shortcut is used you could try to intercept that by gaining access to the JTextArea using WSTextEditorPage.getTextComponent() and then looking in its input map, try to replace the mapping for "Ctrl-C" with your own action which wraps the current Copy action.When the "Copy" action is invoked from the contextual menu you could again use the API ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage.addPopUpMenuCustomizer(TextPopupMenuCustomizer) to wrap the current "Copy" action in your own.

About (2), in all editing pages including the Author visual editing mode you have the API ro.sync.exml.workspace.api.editor.page.WSTextBasedEditorPage.select(int, int).

Possibly we could try to add new API for this if we come to an agreement about how this API could look like (API to allow you to maybe set some custom properties in the clipboard along with the content) but I'm not sure in what Oxygen version we can do that. Oxygen 21 will be released in about a month and we are not adding new API to it.

But I still have issue with the contextual menu.The solution in your first post works fine for the "Copy" action of the main menu and the "Ctrl-C".But not for the contextual menu.I have tried the solution of a PopUpMenuCustomizer but in that specific case I can not add an ActionPerformedListener.This kind of listener is not available for JMenuItem element and I only can improve ActionListener.But it is launched after the action is performed.

Is it possible to change/modify the ClipboardFragmentInformation directly ?I know, it is possible to create an AuthorDocumentFragment from the document via the API authorPage.getAuthorAccess().getDocumentController().createDocumentFragment(startCaret, endCaret);Is it possible to use it to replace the fragment in the clipboard ?Or maybe update nodes in ClipboardFragmentInformation.getFragment().getContentNodes() ?

I have tried the solution of a PopUpMenuCustomizer but in that specific case I can not add an ActionPerformedListener.This kind of listener is not available for JMenuItem element and I only can improve ActionListener.But it is launched after the action is performed.

Once you get access to the "Copy" JMenuItem you are interested in, you can get its internal swing "AbstractAction", then you can create your own Swing action with the same name and icon which wraps the "AbstractAction" you found in the JMenuItem. In this way your action will be called first, you change the selection and invoke the original action.Or as an alternative this might also work (but you would need to test it):

but you would need to take care not to add the same listener twice to the same action because the popup menu customizer is called every time the end user right clicks.

Is it possible to change/modify the ClipboardFragmentInformation directly ?I know, it is possible to create an AuthorDocumentFragment from the document via the API authorPage.getAuthorAccess().getDocumentController().createDocumentFragment(startCaret, endCaret);Is it possible to use it to replace the fragment in the clipboard ?Or maybe update nodes in ClipboardFragmentInformation.getFragment().getContentNodes() ?

That's why I mentioned that we should maybe add new API. Somehow if we had this new API, when the "Copy" operation is invoked, Oxygen could call back to your code and tell you what fragments it will copy in the clipboard, allow you to modify the fragments and also maybe add some custom objects to the clipboard (maybe a set of properties). Then on the "Paste" somehow your code would be invoked again and you would receive those custom properties back, properties which might give you indications about how to change the document fragment. I'll add an issue on our side to look into this.

I have decided to add a PopupMenuListener on the pop-up menu.In the method popupMenuWillBecomeVisible, I check the selection and if it is a Text element which is selected, I change the selection by his parent element with

But It only corrects partially my problem.I have two behavior : - 1) If I select text in the node Text, it works fine - 2) If my TagsDisplayMode is Full_tags and I click on the Text tag directly, even if my code is executed, the copy event only take the Text node and not his parent like I have changed before.

- 2) If my TagsDisplayMode is Full_tags and I click on the Text tag directly, even if my code is executed, the copy event only take the Text node and not his parent like I have changed before.

I looked in our code and indeed in the case when a node is fully selected our code creates special contextual Copy and Cut actions which have references to the already selected node. So even if you change the selection, the action is done on the node which was selected when the popup is shown. I will probably add an issue on our side to change this.

A workaround is that in your wrapper "Copy" action that you add to the popup menu instead of delegating to the "Copy" action added by Oxygen to the popup you delegate to this action instead: