Oxygen Web Author 20.1 multiple custom Dialogs

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Oxygen Web Author 20.1 multiple custom Dialogs

Post by mu258770 »

Hi team,

We are working on making custom dialogs for Oxygen Web Author 20.1. We have followed the steps in the below link,

https://www.oxygenxml.com/maven/com/oxy ... ction.html


We are able to create the custom dialog and its functionality making use of the references. Also we are able to add an icon to the custom dialog.

Now we would like to add one more action to the toolbar just near the new item (the existing custom dialog is registered as "insert.link"). If we try to give a different name when registering the item, the new item is getting moved to the end in the tool bar.

We have two queries:

1) Is it possible to make use of the existing custom icon to make it work for the new functionality as well. Means, different action dialog should launch based on the context where the cursor is. So in practice, there should be only one new icon in the toolbar for two functionalities. If so, how?

2) If the above is not possible, is it possible to keep the new action just next to "insert.link" action we created? If so, how?

Regards,
Shabeer
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Oxygen Web Author 20.1 multiple custom Dialogs

Post by cristi_talau »

Hello,

1) Regarding an action whose behavior changes depending on the caret position. There are several approaches to implement this functionality:
  • In JavaScript you have API to get the current selection:

    Code: Select all

    var selection = editor.getSelectionManager().getSelection();

    to check whether it is empty or not [1]

    Code: Select all

    selection.isEmpty()
    and to get the node at caret

    Code: Select all

    selection.getNodeAtCaret()
    Depending on these checks, you can choose to invoke a different action at the end for example "InsertFragmentOperation" if the selection is empty or "SurroundWithFragmentOperation" if the selection is non-empty.
  • You can implement your own subclass of AuthorOperation which has a different behavior depending on where the caret is located. In this case you can use the server-side API to implement the required behavior.
2) Regarding the position of the new toolbar actions that you added, the code in the tutorial adds them at the end of the toolbar:

Code: Select all

ditaToolbar.children.push(...)
You can use the splice function to insert the new action at a position of your choice.

Best,
Cristian
[1] https://www.oxygenxml.com/maven/com/oxy ... ction.html
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Oxygen Web Author 20.1 multiple custom Dialogs

Post by mu258770 »

Hi,

Thank you for the response and it was useful!

Could you please let me know, if there is an easy way to add tooltip for the newly added item in toolbar.

Regards,
Shabeer
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Oxygen Web Author 20.1 multiple custom Dialogs

Post by cristi_talau »

Hello,

When you create your instance of AbstractAction you can override the getDescription() method to provide the text to be included on the tooltip. More details here [1].

Best,
Cristian

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