GalleryEditor API allows the user to perform different operations on the currently opened document. They are available within the Context Object, when the user is editing a Gallery.
|
GalleryEditor API are to be considered as a feature in progress. Changes and additions may be made without warning. |
|
In the source code, we will refer to the Context Object as a generic "ctx" object. |
activeDocument
The activeDocument is the entry point of the GalleryEditor API. It contains a set of different methods to analyze the currently opened document.
Methods of the activeDocument object
getXmlContent
Returns the complete XML content of the document.
It can be called as
ctx.activeDocument.getXmlContent(options);
Method |
|
Parameter
* Optional
If options is not specied or if it’s an empty object the xml of the entire document will be returned. |
Returns |
|
Example
// Obtains the XML of the document.
var xml = ctx.activeDocument.getXmlContent();
// For example, we can parse the XML with jQuery and use it somehow.
var parsedXML = $.parseXML( xml );
// ...
getObjectsData
Returns an array containing the list of the data of each object present in the active document.
It can be called as
ctx.activeDocument.getObjectsData();
Method |
|
Parameter |
None |
Returns |
|
|
The objects contained in the array are intended as "read only" objects. Any change made on them will not be reflected in the active document. |
Example
// Obtains the current selection.
var objectsData = ctx.activeDocument.getObjectsData();
// objectsData is now an array of objects.
Here below an extract of the data contained in each returned object:
{
"id": "199$1.0.624088073",
"type": "Image",
"name": "Official_portrait_of_Barack_Obama-U47037702204ISU-266x200@Globe-Web.jpg",
"description": "",
"owner": "user",
"creator": "user",
"created": 1457105152,
"last_modifier": "user",
"size": 125008,
"system_attributes": {
"workfolder": "",
"template": "",
"templateName": "",
"summary": "",
"wordCount": "",
"sugCategory": "",
"channel": "",
"title": "...",
"storyType": "",
"productInfo": {
"name": "",
"issueDate": ""
},
"imageInfo": {
"width": 266,
"height": 200,
"ptWidth": 63.84000015258789,
"ptHeight": 48,
"colorType": "RGB",
"processTypes": ["resample"]
},
"priority": ""
},
"system_attributes_xml": "<props><process><type>resample</type></process><title>...</title><summary/><imageInfo>\n<width>266</width>\n<height>200</height>\n<ptWidth>63.84</ptWidth>\n<ptHeight>48.0</ptHeight>\n<xDim>22.52</xDim>\n<yDim>16.93</yDim>\n<dim>2.252cm x 1.693cm</dim>\n<xres>300.0</xres>\n<yres>300.0</yres>\n<colorType>RGB</colorType>\n<fileType>PNG</fileType>\n</imageInfo></props>",
"usage_ticket": "<?xml version='1.0' encoding='UTF-8'?><tl></tl>"
}
isCroppedImage
Return a boolean value to check if the image is hard cropped.
It can be called as
ctx.activeDocument.isCroppedImage(loid);
Method |
|
Parameter |
|
Returns |
|
// Obtain the cropped information.
var isCropped = ctx.activeDocument.isCroppedImage(loid);
//check the isCropped variable
saveDocument
Execute the save of the current document.
It can be called as
ctx.activeDocument.saveDocument();
Method |
|
Parameter |
Optional {Function} callback - A function invoked if the the document is successfully saved |
|
If the document is not dirty, the save is not executed, but the callback, if defined, is always invoked. |