URL chooser for a custom action

NicoAMP
Posts: 45
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

URL chooser for a custom action

Post by NicoAMP » Tue Apr 07, 2020 5:51 pm

Hi,

I would like to add a custom action to add a mapref in a ditamap.

So I add this code, but I don't know how to invoke an "URL chooser" to get get link to .ditamap and use the result with ro.sync.ecss.extensions.commons.operations.IFragmentOperation (see "var url = ????").

Code: Select all

    MaprefAction = function(editor) {
      this.editor = editor;
    };
        
    MaprefAction.prototype.getDisplayName = function() {
      return 'Insert a mapref element';
    };
    
    // The actual action execution.
    MaprefAction.prototype.actionPerformed = function(callback) {
      var url = ????
      
      if (url) {
        this.editor.getActionsManager().invokeOperation(
          'ro.sync.ecss.extensions.commons.operations.IFragmentOperation', {
            fragment: '<' + 'mapref href="' + url + '"/>'
          }, callback);
      } else {
        callback && callback();
      }
    };
And just another thing, I put framework.js in a folder shared by 2 frameworks (one for dita topic and another for ditamap).
This file is recognized only by "dita topic" framework (I can see custom actions in toolbar) but not by "ditamap" framework. Do you know why ?

Thanks a lot for your help.

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

Re: URL chooser for a custom action

Post by cristi_talau » Tue Apr 07, 2020 6:17 pm

Hello,

First of all I noticed that IFragmentOperation is not the name of the builtin operation. I expect that it is a custom operation that you implemented yourself.

Regarding the URL chooser, the simplest way is to use an ${ask} variable with type relative_url [1]. In this case, you do not need any JS code. Just configure the action in the Document Type Configuration Dialog box in an Oxygen XML Editor application.

Alternatively, you can use workspace.getUrlChooser() from the JS code which returns a sync.api.UrlChooser [2]. I was surprised that it is not documented as API - it will be in the next version.

Best,
Cristian

[1] https://www.oxygenxml.com/doc/versions/ ... tml?hl=ask
[2] https://www.oxygenxml.com/maven/com/oxy ... ooser.html

NicoAMP
Posts: 45
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Re: URL chooser for a custom action

Post by NicoAMP » Wed Apr 08, 2020 10:22 am

Hi Cristian,

IFragmentOperation is a typo error, I use a classic InsertFragmentOperation.

I follow your advice using an action in Document Type Configuration Dialog box, with the following fragment:

Code: Select all

<mapref href="${ask('DITA Map', relative_url, '')}"/>
Thanks for your help.

Regards,
Nicolas

Post Reply