Page 1 of 1

Right Click Actions

Posted: Wed Jan 16, 2019 5:26 am
by nstensland
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

Re: Right Click Actions

Posted: Wed Jan 16, 2019 8:56 am
by Radu
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

Re: Right Click Actions

Posted: Mon Feb 04, 2019 3:47 am
by nstensland
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

Re: Right Click Actions

Posted: Mon Feb 04, 2019 4:21 pm
by cristi_talau
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

Re: Right Click Actions

Posted: Fri Feb 08, 2019 5:31 pm
by nstensland
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

Re: Right Click Actions

Posted: Fri Feb 08, 2019 6:38 pm
by Gabriel Titerlea
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);
});
});

Re: Right Click Actions

Posted: Sat Feb 09, 2019 12:41 am
by nstensland
Sorry yes, pasted the wrong thing. Action I meant. Thanks.

Re: Right Click Actions

Posted: Sun Feb 10, 2019 1:15 am
by nstensland
Is there a way to override the copy,cut and paste commands using frameworks.js client side browser approach?

Thanks again!
Nat

Re: Right Click Actions

Posted: Mon Feb 11, 2019 5:20 pm
by cristi_talau
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

Re: Right Click Actions

Posted: Wed Feb 13, 2019 5:32 pm
by nstensland
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.

Re: Right Click Actions

Posted: Wed Feb 13, 2019 6:32 pm
by cristi_talau
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