With Méthode Swing it’s possible to add manipulation to a custom url.
Registration of a custom manipulation
To register a custom manipulation, use the following namespace
eidosmedia.webclient.extensions.manageCustomUrl
and its function
register( options )
Method |
|
Parameter |
Required Supported functions:
|
Returns |
|
The following is a very simple registration for a custom manipulation.
(function(){
eidosmedia.webclient.extensions.manageCustomUrl.register({'handleUrl': function( data, ctx, callback ) {
/**
* Save the current url
*/
var uri = data.uri;
/**
* Save the handle drop flag
*/
var handleDrop = false;
try {
/**
* The area object it's useful to verify if the call come form the editor of the story
*/
var area = ctx.area;
if (area.getType() == 'editor' && area.getName() == 'story') {
/**
* In our example we decide to handle only the url of eidosmedia site
* Change the if statement according to your needs
*/
if (uri == 'https://www.eidosmedia.com/') {
var contentTitle = 'Eidosmedia link site';
handleDrop = true;
/**
* Prepare the xml to insert in the current active document context
*/
var xml = '<a href="' + uri + '">' + contentTitle + '</a>';
ctx.activeDocument.insertXml(xml);
}
}
/**
* notify a callback, if specified, only if the drop has not been handled so Swing can manage
* the url in the standard way
*/
if (!handleDrop && callback) {
callback(data);
}
} catch (ex) {
console.log("manageCustomUrl-handleUrl custom manipulation exception caught", ex);
/**
* notify a callback, if specified, only if the drop has not been handled so Swing can manage
* the url in the standard way
*/
if (!handleDrop && callback) {
callback(data);
}
}
}, 'getPreviewInfo': function( data, ctx ) {
/**
* Save the current url
*/
var uri = data.uri;
var currentXml = data.xml;
var previewInfo;
try {
/**
* The area object it's useful to verify if the call come form the editor of the story
*/
var area = ctx.area;
if (area.getType() == 'editor' && area.getName() == 'story') {
/**
* In our example we decide to handle only the url of eidosmedia site
* Change the if statement according to your needs
*/
if (uri == 'https://www.eidosmedia.com/') {
var path = ''; // path of an image in the eomdb;
var customIcon = 'fa fa-exclamation-circle'; // the custom icon to use
previewInfo = {'path': path, 'icon': customIcon}
}
}
} catch (ex) {
console.log("manageCustomUrl-getPreviewInfo custom manipulation exception caught", ex);
}
return previewInfo;
}});
})();
Wrap all the custom manipulation with a try…catch block to allow Swing to handle the url if something goes wrong. |