Right Click Actions

Post here questions and problems related to oXygen frameworks/document types.
nstensland
Posts: 21
Joined: Wed Jan 16, 2019 5:16 am

Right Click Actions

Post by nstensland » Wed Jan 16, 2019 5:26 am

Is it possible to register a command via JavaScript API into the right click menu? I was able to register it into the toolbar but cannot find a way to register into the right click menu. I understand that it is possible via framework, am wondering if it is possible via JavaScript API.

Thanks,
Nat

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

Re: Right Click Actions

Post by Radu » Wed Jan 16, 2019 8:56 am

Hi Nat,

Sure, from the Javascript code you can call any Java API you want.
In the sample project:

https://github.com/oxygenxml/wsaccess-j ... le-plugins

there are 3 plugin folders with names starting with contributePopupAction which may be interesting as examples for you.

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

nstensland
Posts: 21
Joined: Wed Jan 16, 2019 5:16 am

Re: Right Click Actions

Post by nstensland » Mon Feb 04, 2019 3:47 am

I meant javascript running in the client browser. We are using Oxygen Web Author. We are integration via a html Frame.

Is there a list of what the differences is between Oxygen stand alone and Web Author. It seems there are differences and some items which are not available in Web Author?

Can I add right click actions in javascript, in client browser via framework.js for example?

Thanks,
Nat

cristi_talau
Posts: 217
Joined: Thu Sep 04, 2014 4:22 pm

Re: Right Click Actions

Post by cristi_talau » Mon Feb 04, 2019 4:21 pm

Hello,

Web Author displays only the actions configured in the framework that are compatible with the web. For example, an action that displays a Java Swing dialog is not compatible.

If you implemented custom AuthorOperations, that you think are compatible with Web Author but still don't show up in the context menu, you should annotate them with @WebappCompatible [1].

If some of the builtin actions do not show up, it means that they are most likely not compatible with Web Author. If you consider one of the missing actions is important, please report this to us and we will prioritize making it compatible in a future version.

Regarding adding actions from JS code, you can follow the tutorial here [2]. Instead of actionsConfig.toolbars you should work with actionsConfig.contextualItems [3]. This way you can replace the incompatible action with a JS-based implementation.

Best,
Cristian

[1] https://www.oxygenxml.com/InstData/Edit ... tible.html
[2] https://www.oxygenxml.com/maven/com/oxy ... ction.html
[3] https://www.oxygenxml.com/maven/com/oxy ... Event.html

nstensland
Posts: 21
Joined: Wed Jan 16, 2019 5:16 am

Re: Right Click Actions

Post by nstensland » Fri Feb 08, 2019 5:31 pm

Thanks. Seems to work using contextualItems!

Quick follow up: sync.api.Workspace.EventType.EDITOR_LOADED, why does this get called 3 times when a page loads? First two times toolbar is null. Not sure from documentation what EDITOR_LOADED means exactly I guess.

Thanks again,
Nat

Gabriel Titerlea
Posts: 40
Joined: Thu Jun 09, 2016 2:01 pm

Re: Right Click Actions

Post by Gabriel Titerlea » Fri Feb 08, 2019 6:38 pm

why does this get called 3 times when a page loads
The EDITOR_LOADED event is called only once. Maybe you are referring to the ACTIONS_LOADED event.

Look at this code to better understand how the events are fired:

Code: Select all


goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
console.log('EDITOR_LOADED');
// This code will be called only once, after the editor is loaded.

var editor = e.editor;

goog.events.listen(editor, sync.api.Editor.EventTypes.ACTIONS_LOADED, function(e) {
console.log('ACTIONS_LOADED');
// This code will be called 3 times. Once for every toolbar that is loaded in the editor.

var actionsConfiguration = e.actionsConfiguration;

// This should have a value every time this function is called. Are you sure this is null?
var toolbars = actionsConfiguration.toolbars;

// These 2 objects are only present during the third call of this
// function if the active framework provides actions or contextualItems.
var actions = actionsConfiguration.actions;
var contextualItems = actionsConfiguration.contextualItems;

console.log('Toolbars: ', toolbars);
console.log('Actions: ', actions);
console.log('ContextualItems: ', contextualItems);
});
});

nstensland
Posts: 21
Joined: Wed Jan 16, 2019 5:16 am

Re: Right Click Actions

Post by nstensland » Sat Feb 09, 2019 12:41 am

Sorry yes, pasted the wrong thing. Action I meant. Thanks.

nstensland
Posts: 21
Joined: Wed Jan 16, 2019 5:16 am

Re: Right Click Actions

Post by nstensland » Sun Feb 10, 2019 1:15 am

Is there a way to override the copy,cut and paste commands using frameworks.js client side browser approach?

Thanks again!
Nat

cristi_talau
Posts: 217
Joined: Thu Sep 04, 2014 4:22 pm

Re: Right Click Actions

Post by cristi_talau » Mon Feb 11, 2019 5:20 pm

Hello,

To override an action from the context menu you have to register your action with the same ID in the ActionsManager.

However, implementing cut/copy/paste actions yourself in the browser is quite complicated due to security restrictions. If you give us more details about what you are trying to achieve, we may give you a better advice.

For example, in order to customize what happens when you paste from an external document (Word, HTML, etc) there is a stylesheet that you can modify [1].

Best,
Cristian

[1] https://www.oxygenxml.com/doc/versions/ ... mart-paste

nstensland
Posts: 21
Joined: Wed Jan 16, 2019 5:16 am

Re: Right Click Actions

Post by nstensland » Wed Feb 13, 2019 5:32 pm

This is an internal copy/paste. What is the 'action id' of cut, copy and paste built in commands in the contextual menu? Trying to replace it or remove without success.

cristi_talau
Posts: 217
Joined: Thu Sep 04, 2014 4:22 pm

Re: Right Click Actions

Post by cristi_talau » Wed Feb 13, 2019 6:32 pm

Hello,

To find the Id of an action you can follow the steps here [1].
The IDs of the Cut/Copy/Paste actions in the context menu are:

- Author/CutSpecial
- Author/CopySpecial
- Author/PasteSpecial

And the actions that are bound to shortcuts are

- Author/Cut
- Author/Copy
- Author/Paste

Best,
Cristian

[1] https://www.oxygenxml.com/maven/com/oxy ... ction.html

Post Reply