Set Initial URL For Choose File Filter Button from DITA Context Dialog
Are you missing a feature? Request its implementation here.
-
- Posts: 130
- Joined: Thu Aug 30, 2018 10:06 pm
Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by dreifsnider »
Hi,
My team would like to start using the DITAVAL/filter options added to Web Author in version 26.1.
However, our DITAVALs are not stored in the same repository as our topics and ditamaps and many of our users are not even aware of where our DITAVAL files are stored.
Therefore, we would like to be able to set the initial URL for the Choose file dialog that displays when clicking on the folder icon so that users won't even need to navigate to a different repository and folder.
Is this possible to do?
Thanks!
Daniel
My team would like to start using the DITAVAL/filter options added to Web Author in version 26.1.
However, our DITAVALs are not stored in the same repository as our topics and ditamaps and many of our users are not even aware of where our DITAVAL files are stored.
Therefore, we would like to be able to set the initial URL for the Choose file dialog that displays when clicking on the
Code: Select all
button.dita-map-view__file-picker-button.filter-button
Is this possible to do?
Thanks!
Daniel
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Hello,
When a ditaval is already set, the file chooser will be opened in that location. A ditaval can be specified using the dita.val.url parameter in the URL of the editor (or by setting it as a loading option. We also have a sample plugin available for setting a loading option: https://github.com/oxygenxml/web-author ... ons-setter .
So, a possibility would be to set an initial ditaval, or to indicate a fake one in the folder you want the file chooser to be opened in the filters repository.
I hope this solution is suitable for your use case.
Please let us know if you need more information.
Best Regards,
Mihaela
When a ditaval is already set, the file chooser will be opened in that location. A ditaval can be specified using the dita.val.url parameter in the URL of the editor (or by setting it as a loading option. We also have a sample plugin available for setting a loading option: https://github.com/oxygenxml/web-author ... ons-setter .
So, a possibility would be to set an initial ditaval, or to indicate a fake one in the folder you want the file chooser to be opened in the filters repository.
I hope this solution is suitable for your use case.
Please let us know if you need more information.
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 130
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by dreifsnider »
Hi Mihaela,
Thank you for this suggestion of using the loading options! We're already using the loading option sample plugin so thankfully we can just update that to also load a ditaval.
Does the GitHub folder path need to be URL encoded in the loading options plugin, or will Web Author automatically convert the path to be URL encoded?
Thanks!
Daniel
Thank you for this suggestion of using the loading options! We're already using the loading option sample plugin so thankfully we can just update that to also load a ditaval.
Does the GitHub folder path need to be URL encoded in the loading options plugin, or will Web Author automatically convert the path to be URL encoded?
Thanks!
Daniel
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Hello,
The URL does not need to be encoded when using loading option to set the filter.
Best,
Cosmin
The URL does not need to be encoded when using loading option to set the filter.
Best,
Cosmin
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
-
- Posts: 130
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by dreifsnider »
Hi Cosmin,
Thanks for the reply and for that information!
I don't see a loading option specifically for the dita.val.url or anything else related to loading a ditaval. I'm looking at this documentation: https://www.oxygenxml.com/maven/com/oxy ... ingOptions
Do I need to instead update the url as part of the loading options? Something like:
Or is there a simpler way to load the ditaval into the DITA Context?
Thanks!
Daniel
Thanks for the reply and for that information!
I don't see a loading option specifically for the dita.val.url or anything else related to loading a ditaval. I'm looking at this documentation: https://www.oxygenxml.com/maven/com/oxy ... ingOptions
Do I need to instead update the url as part of the loading options? Something like:
Code: Select all
goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function(e) {
if (!e.options.url.includes('.ditaval')) {
e.options.url.concat('&dita.val.url=gitgh%3A%2F%2Fhttps%253A%252F%252Fgithub.com%252Fdreifsnider%252Foxy-frameworks%2Fmain%2Fweb-author%2Fditavals%2Fdefault.ditaval&show.excluded.content=true');
}
});
}
Thanks!
Daniel
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Hello,
URL parameters can also be used in loading options. Here [1] you can find an example of customizing the Editor using loading options.
[1] https://www.oxygenxml.com/maven/com/oxy ... tions.html
Best,
Cosmin
URL parameters can also be used in loading options. Here [1] you can find an example of customizing the Editor using loading options.
[1] https://www.oxygenxml.com/maven/com/oxy ... tions.html
Best,
Cosmin
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
-
- Posts: 130
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by dreifsnider »
Hi,
Since we're using the Impose Ditamap sample plugin to automatically impose a DITAMAP, I realized that I had to update this plugin to impose a DITAVAL as well.
Unfortunately, imposing a DITAVAL does not make the Filter Choose file dialog open in the correct location.
I believe this is because the DITAVAL is being loaded from a different repository than where the DITA file is located. Our repositories have the following structure:
When the Filter Choose file button is clicked, we're presented with the message "You cannot go above the root of the file repository", and the dialog still shows the repository that the topic and ditamap are loaded from (product-one-content) instead of the repository that the ditaval is loaded from (dita-frameworks):
Is there any other way we can control where the Filter Choose file dialog initially opens?
For what it's worth, if we manually navigate to and select a DITAVAL file using the the Filter Choose file dialog, it does remember the folder when subsequently opened. It's just when a DITAVAL is initially loaded the dialog does not seem to be aware of where the DITAVAL is located.
Thanks,
Daniel
Since we're using the Impose Ditamap sample plugin to automatically impose a DITAMAP, I realized that I had to update this plugin to impose a DITAVAL as well.
Unfortunately, imposing a DITAVAL does not make the Filter Choose file dialog open in the correct location.
I believe this is because the DITAVAL is being loaded from a different repository than where the DITA file is located. Our repositories have the following structure:
Code: Select all
product-one-content <- unique repository
en
_toc.ditamap
topicA.dita
ja
_toc.ditamap
topicA.dita
Code: Select all
product-two-content <- unique repository
en
_toc.ditamap
topicA.dita
ja
_toc.ditamap
topicA.dita
Code: Select all
dita-frameworks <- unique repository
css
dita-ot
ditavals
default.ditaval
productA.ditaval
productB.ditaval
- image.png (11.78 KiB) Viewed 943 times
- image.png (24.93 KiB) Viewed 943 times
- image.png (36.37 KiB) Viewed 943 times
For what it's worth, if we manually navigate to and select a DITAVAL file using the the Filter Choose file dialog, it does remember the folder when subsequently opened. It's just when a DITAVAL is initially loaded the dialog does not seem to be aware of where the DITAVAL is located.
Thanks,
Daniel
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Hello,
You are right, it seems that URL parameter doesn't handle the case you mentioned (with the ditavals being in a different repository than the ditamap).
As a workaround, you can use the DITA Projects [1] option. There is such a sample in the Web Author kit from which you can draw inspiration (oxygen-xml-web-author\tomcat\work\Catalina\localhost\oxygen-xml-web-author\samples\dita\mobile-phone). You can easily switch profiling conditions using a convenient drop-down control instead of having to browse for DITAVAL files.
[1] https://www.oxygenxml.com/doc/versions/ ... jects.html
Best,
Cosmin
You are right, it seems that URL parameter doesn't handle the case you mentioned (with the ditavals being in a different repository than the ditamap).
As a workaround, you can use the DITA Projects [1] option. There is such a sample in the Web Author kit from which you can draw inspiration (oxygen-xml-web-author\tomcat\work\Catalina\localhost\oxygen-xml-web-author\samples\dita\mobile-phone). You can easily switch profiling conditions using a convenient drop-down control instead of having to browse for DITAVAL files.
[1] https://www.oxygenxml.com/doc/versions/ ... jects.html
Best,
Cosmin
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
-
- Posts: 130
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by dreifsnider »
Hi Cosmin,
Thank you for your reply and suggestion of using the DITA Projects functionality to predefine the profiling conditions. As you mention, this is a much better user experience as users can simply select a predefined profile condition without having to navigate to and select a DITAVAL file.
I will investigate building a DITA project file and loading it into our custom Web Author frameworks.
Thanks again!
Daniel
Thank you for your reply and suggestion of using the DITA Projects functionality to predefine the profiling conditions. As you mention, this is a much better user experience as users can simply select a predefined profile condition without having to navigate to and select a DITAVAL file.
I will investigate building a DITA project file and loading it into our custom Web Author frameworks.
Thanks again!
Daniel
-
- Posts: 509
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by cristi_talau »
Hello,
We analyzed more the warning that you get when you specify the DITAVAL url. It is a limitation that we plan to address in an upcoming release.
The DITA Project approach provides a better UX, but comes with its own challenges:
This code uses window.prompt, but you can replace it with your own dialog.
Best,
Cristian
We analyzed more the warning that you get when you specify the DITAVAL url. It is a limitation that we plan to address in an upcoming release.
The DITA Project approach provides a better UX, but comes with its own challenges:
- If you put the DITA Project file in the product repository, it will have to reference a file outside that repository and that might not work. One workaround is to use Git submodules to "mount" the frameworks repo inside the product repo.
- If you put the DITA Project in the frameworks repo, you will need to add information about various products in the frameworks repo.
Code: Select all
let chooser = workspace.getUrlChooser();
chooser._defaultChooseUrl = chooser.chooseUrl;
chooser.chooseUrl = (context, chosen, purpose) => {
if (context.getInitialUrl() && context.getInitialUrl().endsWith('.ditaval')) {
let ditaval = window.prompt('Choose dita val');
chosen(ditaval);
} else {
chooser._defaultChooseUrl(context, chosen, purpose);
}
}
Best,
Cristian
-
- Posts: 130
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by dreifsnider »
Hi Cristian,
I explored the possibility of using a DITA-OT project, but unfortunately and as you alluded to, this isn't feasible for us as we have over 200 ditamaps that would need to be accounted for each with their own context. Plus the maintenance involved in keeping this up-to-date is extremely high.
Thank you for these details and for providing this alternative solution of implementing our own custom UrlChoser dialog! I'm afraid that we most likely won't be able to implement this though because of the work involved in creating our own UI and dialog. Plus, we'd like to make the Web Author UI as seamless as possible to avoid confusing our users.
Would it be possible to use the setInitialUrl method specifically for the choose filter button? We want to avoid affecting any of the other UrlChooser functionality, for example, inserting images or xrefs.
I'm wondering if this would let us use the existing UrlChooser dialog UI and set the URL to the correct repository location in which the DITAVALs are stored?
If this would be possible, could you provide an example of how we could use the setInitialUrl() method for the choose filter button?
Thanks!
Daniel
I explored the possibility of using a DITA-OT project, but unfortunately and as you alluded to, this isn't feasible for us as we have over 200 ditamaps that would need to be accounted for each with their own context. Plus the maintenance involved in keeping this up-to-date is extremely high.
Thank you for these details and for providing this alternative solution of implementing our own custom UrlChoser dialog! I'm afraid that we most likely won't be able to implement this though because of the work involved in creating our own UI and dialog. Plus, we'd like to make the Web Author UI as seamless as possible to avoid confusing our users.
Would it be possible to use the setInitialUrl method specifically for the choose filter button? We want to avoid affecting any of the other UrlChooser functionality, for example, inserting images or xrefs.
I'm wondering if this would let us use the existing UrlChooser dialog UI and set the URL to the correct repository location in which the DITAVALs are stored?
If this would be possible, could you provide an example of how we could use the setInitialUrl() method for the choose filter button?
Thanks!
Daniel
-
- Posts: 130
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by dreifsnider »
Hi Cristian,
I created a new plugin to test your code, but I'm getting the following error: "Cannot read properties of null (reading 'chooseUrl')" on the following line:
For what it's worth, here's the plugin.js I'm using:
I also tried to use the setInitialUrl method to set the context, as follows but this doesn't seem to work either:
Thank you for any help you can provide!
Daniel
I created a new plugin to test your code, but I'm getting the following error: "Cannot read properties of null (reading 'chooseUrl')" on the following line:
Code: Select all
chooser._defaultChooseUrl = chooser.chooseUrl;
Code: Select all
(function () {
workspace.listen(sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function({editor}) {
let chooser = workspace.getUrlChooser();
chooser._defaultChooseUrl = chooser.chooseUrl;
chooser.chooseUrl = (context, chosen, purpose) => {
if (context.getInitialUrl() && context.getInitialUrl().endsWith('.ditaval')) {
let ditaval = window.prompt('Choose dita val');
chosen(ditaval);
} else {
chooser._defaultChooseUrl(context, chosen, purpose);
}
}
});
})();
Code: Select all
(function () {
workspace.listen(sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function({editor}) {
let ditaValDir = 'oxy-url-to-ditaval-directory'
let chooser = workspace.getUrlChooser();
chooser._defaultChooseUrl = chooser.chooseUrl;
chooser.chooseUrl = (context, chosen, purpose) => {
if (context.getInitialUrl() && context.getInitialUrl().endsWith('.ditaval')) {
context.setInitialUrl(ditaValDir);
} else {
chooser._defaultChooseUrl(context, chosen, purpose);
}
}
});
})();
Daniel
-
- Posts: 509
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Set Initial URL For Choose File Filter Button from DITA Context Dialog
Post by cristi_talau »
Hello,
Can you try to execute this code EDITOR_LOADED instead of BEFORE_EDITOR_LOADED?
Best,
Cristian
Can you try to execute this code EDITOR_LOADED instead of BEFORE_EDITOR_LOADED?
Best,
Cristian
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