URL Chooser Does Not Shows a Prompt to the User That Asks for the URL
Problem
The UrlChooser feature in Web Author fails to display a prompt asking the user to input a URL.
Cause
Some editing tasks require the user to link several resources. For example, when
inserting an image, the user must provide the URL of that image. The same scenario applies
for links between XML document and DITA @conref
attributes.
Solution
You can improve the user experience by implementing a custom URL chooser that allows for choosing a resource in your CMS. This can be achieved by extending the sync.api.UrlChooser class. The following code snippet implements a dummy UrlChooser that shows a prompt to the user that asks for the URL:
var DummyUrlChooser = function() { sync.api.UrlChooser.call(this); }; DummyUrlChooser.prototype = Object.create(sync.api.UrlChooser.prototype); DummyUrlChooser.prototype.constructor = DummyUrlChooser; // Only support image choosing DummyUrlChooser.prototype.supports = function(type) { return type == sync.api.UrlChooser.Type.IMAGE; }; // DummyUrlChooser.prototype.chooseUrl = function(context, chosen) { if (context.getType() == sync.api.UrlChooser.Type.IMAGE) { var result = prompt(); chosen(result); } return null; };
Then, you can register it using the following API call:
workspace.setUrlChooser(new DummyUrlChooser());