URL chooser for a custom action
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
URL chooser for a custom action
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 = ????").
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.
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();
}
};
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.
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: URL chooser for a custom action
Post by cristi_talau »
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
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
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Re: URL chooser for a custom action
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:
Thanks for your help.
Regards,
Nicolas
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, '')}"/>
Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Re: URL chooser for a custom action
Hi Cristian,
Is it possible to get a relative URL using sync.api.UrlChooser?
Or resolve the url obtained against the current document path?
Thanks.
Regards,
Nicolas
Is it possible to get a relative URL using sync.api.UrlChooser?
Or resolve the url obtained against the current document path?
Thanks.
Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Site Admin
- Posts: 233
- Joined: Wed Aug 30, 2023 2:33 pm
Re: URL chooser for a custom action
Hello,
For your use case, you can use makeRelative(base, url) API [1]
[1] https://www.oxygenxml.com/maven/com/oxy ... ve__anchor
Best Regards,
Cosmin
For your use case, you can use makeRelative(base, url) API [1]
[1] https://www.oxygenxml.com/maven/com/oxy ... ve__anchor
Best Regards,
Cosmin
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Re: URL chooser for a custom action
Hello Cosmin,
I resoled the url using the current editing document and it works fine:
Thanks for your help.
Regards,
Nicolas
I resoled the url using the current editing document and it works fine:
Code: Select all
let currentUrl = workspace.currentEditor.getUrl();
let relativeUrl = workspace.makeRelative(currentUrl,url);
Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service