Skip to content

Latest commit

 

History

History
3213 lines (1274 loc) · 50.3 KB

DOCUMENTATION.md

File metadata and controls

3213 lines (1274 loc) · 50.3 KB

@aptoma/drpublish-plugin-api 3.12.5

js/PluginAPI.js

PluginAPI.getJWT(tag, callback)

Get the JWT as defined on DrPublish publication config. This token can be used to authenticate the request.

Returns
  • String
Parameters
Name Type Description
tag String The tag to create  
callback Function function(Boolean)  
Returns
  • Void

PluginAPI.openTagCreationDialog(tag, callback)

Creates a new tag

Parameters
Name Type Description
tag String The tag to create  
callback Function function(Boolean)  
Returns
  • Void

PluginAPI.reloadIframe()

Reloads the plugins's iframe

Returns
  • Void

PluginAPI.getPluginName()

Get the name of the loaded plugin

Returns
  • String The name of the plugin, or false if it couldn't be detected

PluginAPI.getAppName()

Get the name of the loaded plugin

Returns
  • String The name of the plugin, or false if it couldn't be detected

PluginAPI.setPluginName(name)

Set the name of the plugin

Parameters
Name Type Description
name String The name of the plugin  
Returns
  • Void

PluginAPI.setAppName(name)

Set the name of the plugin

Parameters
Name Type Description
name String The name of the plugin  
Returns
  • Void

PluginAPI.showInfoMsg(msg)

Show info-message to the user

Parameters
Name Type Description
msg String Message to be displayed  
Returns
  • Void

PluginAPI.showWarningMsg(msg)

Show warning-message to the user

Parameters
Name Type Description
msg String Message to be displayed  
Returns
  • Void

PluginAPI.showErrorMsg(msg)

Show error-message to the user

Parameters
Name Type Description
msg String Message to be displayed  
Returns
  • Void

PluginAPI.showLoader(msg)

Show the loader

Parameters
Name Type Description
msg String Message to display in progress loader  
Returns
  • Void

PluginAPI.hideLoader()

Hide the loader

Returns
  • Void

PluginAPI.__loadArticleRevision(id, callback) private method

Loads an old revision of an article

Parameters
Name Type Description
id Number The id of the revision to load  
callback Function The function to call when the new revision has been loaded  
Returns
  • Void

PluginAPI.createTag(tag, callback)

Creates a new tag

Parameters
Name Type Description
tag String JSON object with the tag to create, must contain tagTypeId and name properties  
callback Function function(Boolean)  
Returns
  • Void

PluginAPI.searchDrLib(data, callback)

Sends a query to DrLib

Parameters
Name Type Description
data Object Object with three properties; 'query' which is the query to send to DrLib, 'success' which is the callback to execute on success, and 'secure' a boolean to add the internal API key to the query and thus allow searching on unpublished article. This callback's parameter is an object which is the query result as an object. See the json output of DrLib to learn more about this object  
callback Function function(Boolean)  
Examples
PluginAPI.searchDrLib({
     query: 'articles.json?q=awesome',
     secure: true,
     success: function(data) {
         data.items.forEach(doStuffWithArticle);
     },
     error: function(data) {
         console.warn('something went wrong');
     }
})
Returns
  • Void

PluginAPI.generateArticleUrl(id, callback)

Generates an url to a published article

Parameters
Name Type Description
id String The id of the article to generate url for  
callback Function function(String), where the parameter is the generated url  
Returns
  • Void

PluginAPI.extendApi(group, name, action)

Extends the PluginAPI with custom functionality that other plugins can use

Parameters
Name Type Description
group String Group name for functionality to add  
name String Name of the specific function to add  
action Function function(Object) Function to call when the API is invoked, recieves one parameter as given in PluginAPI.callExtendedApi and return value is passed back to the caller  
Returns
  • Void

PluginAPI.callExtendedApi(group, name, data, callback)

Call the extended PluginAPI

Parameters
Name Type Description
group String Group name for functionality to call  
name String Name of the specific function to call  
data Object Data object to pass as parameter to the api call  
callback Function function(Object) Function to recieve the API response, parameter is the response from the API call  
Returns
  • Void

PluginAPI.getCurrentUser(callback)

Gets logged in user

Parameters
Name Type Description
callback Function function(Object)  
Returns
  • Void

PluginAPI.getConfiguration(callback)

Get configuration information about the plugin

Parameters
Name Type Description
callback Function function(Object)  
Returns
  • Void

PluginAPI.getDrPublishConfiguration(callback)

Get DrPublish configuration

Parameters
Name Type Description
callback Function function(Object)  
Returns
  • Void

PluginAPI.setConfiguration(config, options, callback)

Set configuration information about the plugin

Parameters
Name Type Description
config Object The configuration object to save  
options Object Object, can have three keys. 'onlyPublication' (boolean) If true the configuration is set for the current publication only
'success' (function) Called if the configuration was saved successfully
'error' (function) Called if there was an error, recieves and error object as first parameter
 
callback Function function()  
Returns
  • Void

PluginAPI.emit(name, data)

Emits an event to DrPublish, and possibly other apps

Parameters
Name Type Description
name String Name of the event  
data String Data object to send with the event  
Returns
  • Void

PluginAPI.on(name, callback)

Listen for an event. If the callback returns false the event may cancel continued actions, e.g beforeSave can cancel article save. Look at documentation for Listeners to learn more.

Parameters
Name Type Description
name String Name of the event  
callback Function function(Object) Function to call when the event is triggered. Recieves one data object parameter of the form {source: , data: }  
Returns
  • Void

PluginAPI.increaseRequiredActionCounter(callback)

Increase the counter of actions required by the user, used to tell the user that the plugin requires input of some kind

Parameters
Name Type Description
callback Function function(Object) function to call once the counter has been increased, returns the new counter value  
Returns
  • Void

PluginAPI.decreaseRequiredActionCounter(callback)

Decrease the counter of actions required by the user, used to tell the user that the plugin requires input of some kind

Parameters
Name Type Description
callback Function function(Object) function to call once the counter has been decrease, returns current counter value  
Returns
  • Void

PluginAPI.clearRequiredActionCounter(callback)

Clear the counter of actions required by the user, used to tell the user that the plugin requires input of some kind

Parameters
Name Type Description
callback Function function(Object) function to call once the counter has been cleared  
Returns
  • Void

PluginAPI.setRequiredActionCounter(count, callback)

Set the counter of actions required by the user, used to tell the user that the plugin requires input of some kind

Parameters
Name Type Description
count Number The value to set the counter to  
callback Function function(Object) function to call once the counter has been cleared  
Returns
  • Void

PluginAPI.create() private method

Create a new instance of the Api class

Returns
  • Object

PluginAPI.createEmbeddedObject(typeId, callback)

Create an embedded object of the given type

Parameters
Name Type Description
typeId Number Type Id of the embedded object to create  
callback Function function(embeddedObjectId) called once the object has been created, first parameter is the new embedded object id  
Returns
  • Void

PluginAPI.getEmbeddedObjectTypes(callback)

Get information about the available embedded object types

Parameters
Name Type Description
callback Function function([Object]) recieves an array with objects describing the available embedded object types in the form of {typeId: 'embedded object type id', cssClass: 'css class used to style the objects'}  
Returns
  • Void

PluginAPI.giveFocus(pluginName, argument, start)

Gives focus to another plugin

Parameters
Name Type Description
pluginName String The name of the plugin to recieve focus  
argument Object Optional option argument to pass along to the plugin recieving focus  
start Boolean Flag to decide if the plugin should be started if it has not been loaded previously, default true  
Returns
  • Boolean

PluginAPI.hide()

Hide the plugin, so it is no longer visible on the list of open plugins

Returns
  • Boolean

PluginAPI.createModal(content, options)

Creates a jQuery UI modal in the main editor window, detached from the plugin itself. Modals are unique on a per-plugin basis, meaning that a plugin can only have a single modal at a time. Creating a new modal will overwrite the previous.

See the official documentation for a list of available options.

Note that you do not have direct access to the DOM of the modal. Use the provided helper methods to manipulate or read from the modal:

Parameters
Name Type Description
content String An HTML string  
options Object A standard jQuery UI options object.  
Examples
PluginAPI.createModal('<h1>This is a modal</h1>', {
  buttons: {
    Ok: function () {
      alert('Ok!');
    }
  }
});

PluginAPI.updateModal('<h1>This is the same modal</h1>');

PluginAPI.createModal('<h1>This is a brand new modal</h1>', {
  buttons: {
    cancel: function() {
      PluginAPI.closeModal(true);
    }
  }
});
Returns
  • Boolean

PluginAPI.updateModal(content)

Updates the HTML content of a live modal. Has no effect if the modal does not exist.

Parameters
Name Type Description
content String An HTML string  
Returns
  • Boolean

PluginAPI.closeModal(destroy)

Closes and optionally deletes the modal. Has no effect if the modal does not exists.

Parameters
Name Type Description
destroy Boolean Whether or not to delete the modal  
Returns
  • Boolean

PluginAPI.getModalInputs(callback)

Returns the values of all input or select elements within a modal.

The values are keyed by one of the following properties in order of priority: element ID, element name or input type + index.

Parameters
Name Type Description
callback Function  
Examples
Given a modal with the following HTML content:

 <form>
     <input type="number">
     <input name="name" type="text">
     <select id="languages">
         <option selected>en</option>
         <option>no</option>
     </select>
 </form>

 getModalInputs would return:

 {
     "number-0": {VALUE}
     "name": {VALUE},
     "languages": "en"
 }
Returns
  • Void

js/AH5Communicator.js

module.exports(PluginAPI)

Parameters
Name Type Description
PluginAPI Api  
Returns
  • AH5Communicator

selectedPluginElement()

Returns
  • Void

pluginElementSelected(elementData)

Parameters
Name Type Description
elementData selectedPluginElementData  
Returns
  • Void

AH5Communicator.getActiveEditor(callback)

Get name of current active editor

Parameters
Name Type Description
callback function function(String)  
Returns
  • Void

AH5Communicator.registerMenuAction(action, callback)

Registers/Modifies a context menu items for a plugin element The object send should have the following structure

Parameters
Name Type Description
action Object The action object  
callback function function()  
Examples
PluginAPI.Editor.registerMenuAction({
	  label: 'label in the menu',
	  icon: '[Optional] url to possible icon image',
	  trigger: '[Optional] css selector, only show menu element when this matches the element',
	  callback: function(id, clickedElementId) {
		  // callback function
		  // first parameter is id of the plugin element
		  // second paramter is id of closest element to the trigger element that has an id
		  //	  in code: $(event.triggerElement).closest('[id]').attr('id');
	  }
})
Returns
  • Void

AH5Communicator.registerHoverAction(action, callback)

Adds a mouseover action to plugin elements

Parameters
Name Type Description
action function to perform  
callback function function(String)  
Returns
  • Void

AH5Communicator.getSelectedPluginElement(callback)

Gets the selected plugin element from the editor

Parameters
Name Type Description
callback function function(String)  
Returns
  • Void

AH5Communicator.directionalCastle(elementId, direction, callback)

Swap positions between the provided element and the adjacent one in the specified direction PluginAPI.Editor.directionalCastle({ elementId: 'the provided element id', direction: 'forward/backward' })

Parameters
Name Type Description
elementId String DOM element id  
direction String Direction  
callback function  
Returns
  • Void

AH5Communicator.registerMenuActionGroup(group, callback)

Registers/Modifies a group of items to in the context menu The object send should have the following structure

Parameters
Name Type Description
group Object The action object  
callback function function()  
Examples
PluginAPI.Editor.registerMenuActionGroup({
	  label: 'label for the group in the menu',
	  icon: '[Optional] url to possible icon image',
	  actions: [
		  {
			  label: 'label for the action #1',
			  callback: function(id, clickedElementId) {
				  // same as for registerMenuAction
			  }
		  },
		  {
			  label: 'label for the action #2',
			  callback: function(id, clickedElementId) {
				  // same as for registerMenuAction
			  }
		  }
	  ]
})
Returns
  • Void

AH5Communicator.getEditorType(callback)

Retrieves the type of editor that currently has focus

Parameters
Name Type Description
callback function function(String)  
Returns
  • Void

AH5Communicator.replaceElementById(id, element, callback)

Replace an element in the article

Parameters
Name Type Description
id String Id of the element  
element String The new element  
callback function function(Boolean), called after replacement is done  
Returns
  • Void

AH5Communicator.replacePluginElementById(id, element, callback)

Replace a plugin element in the article

Parameters
Name Type Description
id String Id of the element  
element String The new element  
callback function function(Boolean), called after replacement is done  
Returns
  • Void

AH5Communicator.setElementContentById(id, content, callback)

Set the content of an element in the article

Parameters
Name Type Description
id String Id of the element  
content String The new content  
callback function function(Boolean), called when done  
Returns
  • Void

AH5Communicator.deleteElementById(id, callback)

Delete an element in the article

Parameters
Name Type Description
id String Id of the element  
callback function function(Boolean), called after deletion is done  
Returns
  • Void

AH5Communicator.getHTMLById(id, callback)

Get HTML code of an element

Parameters
Name Type Description
id String The element id  
callback function function(String), html content of the element  
Returns
  • Void

AH5Communicator.getHTMLBySelector(selector, callback)

Get HTML code of all elements that match the selector

Parameters
Name Type Description
selector String The CSS selector  
callback function function([String]), html content of matching elements  
Returns
  • Void

AH5Communicator.getCategories(callback)

Get all categories

Parameters
Name Type Description
callback Function function([Object Category]), list of Category objects with id, name and pid  
Returns
  • Void

AH5Communicator.getParentCategories(category, callback)

Returns all the parent categories of the given category

Parameters
Name Type Description
category Object The category to find parents of  
callback Function function([Object Category]), array of parent Category objects  
Returns
  • Void

AH5Communicator.getParentIds(id, selector, callback)

Returns all the parent elements that match the selector

Parameters
Name Type Description
id String Id of element to find parents of  
selector String Selector to filter parent elements with  
callback Function function([String]), array of ids  
Returns
  • Void

AH5Communicator.getTagTypes(callback)

Retrieve information about all tagtypes

Parameters
Name Type Description
callback Function function([Object Tagtype]), array of tagtypes with id, name and config object  
Returns
  • Void

AH5Communicator.getTagType(id, callback)

Get information about the given tagtype

Parameters
Name Type Description
id String The element id  
callback Function function(Object Tagtype), tagtype object with id, name and config object  
Returns
  • Void

AH5Communicator.clear(callback)

Clears the editor contents

Parameters
Name Type Description
callback Function function(Boolean)  
Returns
  • Void

AH5Communicator.insertString(string, callback)

Insert a string into the editor

Parameters
Name Type Description
string String The string that should be inserted  
callback Function function(String), id of the newly inserted element if it has one  
Returns
  • Void

AH5Communicator.insertElement(element, options[, callback])

Insert an element into the editor

Note that the HTML of the element is what will be transferred, and nothing else! The element will be given the class dp-plugin-element, and given a unique ID (if none is present)

Parameters
Name Type Description
element Element The element that should be inserted  
options Object Function (can be omitted) Options object, supports option 'select' - set to true to automatically select the inserted element  
callback Function function(String), id of the newly inserted element Optional
Returns
  • Void

AH5Communicator.removeClasses(id, classes, callback)

Remove classes from the element an element in the article

Parameters
Name Type Description
id String Id of the element  
classes Array Array of class names  
callback function function(Boolean)  
Returns
  • Void

AH5Communicator.addClasses(id, classes, callback)

Add new classes to an element

Parameters
Name Type Description
id String Id of the element  
classes Array Array of class names  
callback function function(Boolean)  
Returns
  • Void

AH5Communicator.markAsActive(id, callback)

Mark an element as currently selected (green border with default styling)

Parameters
Name Type Description
id String Id of the element  
callback function function(Boolean)  
Returns
  • Void

AH5Communicator.setAttributeById(id, attribute, value, callback)

Sets the attribute of the element with the given ID to value

Parameters
Name Type Description
id String The ID of the element to set the attribute on  
attribute String The attribute to set  
value String What to set the attribute to  
callback Function function(Boolean)  
Returns
  • Void

AH5Communicator.setStyleById(id, attribute, value, callback)

Sets a style of the element with the given ID to value

Parameters
Name Type Description
id String The ID of the element to set the attribute on  
attribute String The style attribute to set  
value String What to set the attribute to  
callback Function function(Boolean)  
Returns
  • Void

AH5Communicator.initMenu(menus, callback)

Initialize pre registered menus

Available options are: simplePluginMenu, editContext, deleteButton, floatButtons

Parameters
Name Type Description
menus Array Array of menu names  
callback Function function(Boolean)  
Returns
  • Void

AH5Communicator.openPluginElementEditor(id)

Opens the plugin editor for a given element.

Parameters
Name Type Description
id String Plugin element ID  
Returns
  • Void

AH5Communicator.getTotalWordCount(callback)

Returns the total number of words in the currently open article.

Parameters
Name Type Description
callback Function Receives the total word count as its single parameter  
Returns
  • Void

AH5Communicator.getTotalCharCount(callback)

Returns the total number of characters in the currently open article.

Parameters
Name Type Description
callback Function Receives the total character count as its single parameter  
Returns
  • Void

AH5Communicator.updateAssetOption(dpArticleId, key, value, callback)

Update one data option of the referenced embedded asset

Parameters
Name Type Description
dpArticleId Number DrPublish's embedded asset id  
key String Name of the property  
value String Value of the property  
callback Function Receives the total character count as its single parameter  
Returns
  • Void

AH5Communicator.updateAssetData(data, callback)

Update all asset data of the referenced embedded asset

Parameters
Name Type Description
data Object Updated data  
callback Function Receives the total character count as its single parameter  
Examples
 var data = {
  internalId: assetDpArticleId,
  assetElementId: activeAssetId,
  assetType: 'picture',
  assetSource: PluginAPI.getPluginName(),
  resourceUri: fullsizeUrl,
  previewUri: fullsizeUrl,
  renditions: {
      highRes: {uri: fullsizeUrl},
      thumbnail: {uri: thumbnailUrl}
  },
  options: {}
}
PluginAPI.Editor.updateAssetData(data);
Returns
  • Void

AH5Communicator.getAssetData(dpArticleId, callback)

Get all data option of the referenced embedded asset

Parameters
Name Type Description
dpArticleId Number DrPublish's embedded asset id  
callback Function Receives the total character count as its single parameter  
Returns
  • Void

AH5Communicator.insertNestedAsset(parentElementId, markup, data, callback)

Insert an embedded asset inside of an existing one

Parameters
Name Type Description
parentElementId Number DOM element id of the receiving asset  
markup String HTML to inject  
data Object Asset data  
callback Function Receives the total character count as its single parameter  
Examples
var title = response.data.title ? response.data.title : '';
var caption = response.data.description ? response.data.description : '';
var credit = response.data.byline ? response.data.byline : '';
var source = response.data.source ? response.data.source : '';
var markup = '<div class="dp-article-image-container"><img src="' + fullsizeUrl + '" /></div>';
markup += '<div class="dp-article-image-headline" data-dp-editable-type="textfield" data-dp-editable-name="headline">' + title + '</div>';
markup += '<div class="dp-article-image-caption" data-dp-editable-type="html" data-dp-editable-name="caption">' + caption + '</div>';
markup += '<div class="dp-article-image-credit" data-dp-editable-type="textfield" data-dp-editable-name="credit">' + credit + '</div>';
 markup += '<div class="dp-article-image-source" data-dp-editable-type="textfield" data-dp-editable-name="source">' + source + '</div>';
var options = response.data.options ? response.data.options : {};
var callback = function () {
  // do something here
 };
var rends = renditions || {};
rends.highRes = {uri: fullsizeUrl};
rends.preview = {uri: fullsizeUrl};
var drpdata = {
              embeddedTypeId: 5,
              isMultiple: true,
              assetType: 'picture',
              externalId: id,
              assetClass: 'dp-picture',
              assetSource: 'images',
              resourceUri: fullsizeUrl,
              previewUri: fullsizeUrl,
              renditions: rends,
              options: options
          };
var  insertNested = function () {
  PluginAPI.Editor.insertNestedAsset(
      selectedSlideshowAsset.id,
      markup,
      drpdata
};
PluginAPI.Editor.getSelectedPluginElement(insertNested);
Returns
  • Void

AH5Communicator.insertEmbeddedAsset(markup, data, callback)

Insert an embedded asset

Parameters
Name Type Description
markup String HTML to inject  
data Object Asset data  
callback Function Receives the total character count as its single parameter  
Examples
var title = response.data.title ? response.data.title : '';
var caption = response.data.description ? response.data.description : '';
var credit = response.data.byline ? response.data.byline : '';
var source = response.data.source ? response.data.source : '';
var markup = '<div class="dp-article-image-container"><img src="' + fullsizeUrl + '" /></div>';
markup += '<div class="dp-article-image-headline" data-dp-editable-type="textfield" data-dp-editable-name="headline">' + title + '</div>';
markup += '<div class="dp-article-image-caption" data-dp-editable-type="html" data-dp-editable-name="caption">' + caption + '</div>';
markup += '<div class="dp-article-image-credit" data-dp-editable-type="textfield" data-dp-editable-name="credit">' + credit + '</div>';
 markup += '<div class="dp-article-image-source" data-dp-editable-type="textfield" data-dp-editable-name="source">' + source + '</div>';
var options = response.data.options ? response.data.options : {};
var callback = function () {
  // do something here
 };
var rends = renditions || {};
rends.highRes = {uri: fullsizeUrl};
rends.preview = {uri: fullsizeUrl};
var drpdata = {
              embeddedTypeId: 5,
              isMultiple: true,
              assetType: 'picture',
              externalId: id,
              assetClass: 'dp-picture',
              assetSource: 'images',
              resourceUri: fullsizeUrl,
              previewUri: fullsizeUrl,
              renditions: rends,
              options: options
          };
PluginAPI.Editor.insertEmbeddedAsset(markup, drpdata, callback);
Returns
  • Void

js/ArticleCommunicator.js

ArticleCommunicator()

This class is used for communicating with the article, typically setting and getting values of metadata or in the article content itself.

Returns
  • Void

ArticleCommunicator.focusPlugin(callback)

Give focus to yourself

Parameters
Name Type Description
callback Function function(Boolean), called as the plugin gets focus  
Returns
  • Void

ArticleCommunicator.focusApp()

Give focus to yourself

Returns
  • Void

ArticleCommunicator.startPlugin(name, options, callback)

Start the given plugin

Parameters
Name Type Description
name String Name of the plugin as defined on publication settings  
options Object Options for initializing the plugin  
callback Function function(Boolean), called after plugin is started  
Returns
  • Void

ArticleCommunicator.startApp()

Returns
  • Void

ArticleCommunicator.stopPlugin(name)

Stop the given plugin

Parameters
Name Type Description
name String Name of the plugin, as defined on publication config  
Returns
  • Void

ArticleCommunicator.stopApp()

Returns
  • Void

ArticleCommunicator.getId(callback)

Get the id of the article currently edited

Parameters
Name Type Description
callback Function function(Int), id of the current article  
Returns
  • Void

ArticleCommunicator.getPackageId(callback)

Get the guid of the article package currently edited

Parameters
Name Type Description
callback Function function(Int), id of the current article  
Returns
  • Void

ArticleCommunicator.getPackageGuid(callback)

Get the guid of the article package currently edited

Parameters
Name Type Description
callback Function function(Int), id of the current article  
Returns
  • Void

ArticleCommunicator.clearMetaInfo(callback)

Clear the meta information summary

Parameters
Name Type Description
callback Function function(Boolean), called when meta data has been cleared  
Returns
  • Void

ArticleCommunicator.getTags(callback)

Get tags used in the article

Parameters
Name Type Description
callback Function function([Object Tag]), array with tags connected to an article  
Returns
  • Void

ArticleCommunicator.getCustomMeta(name, callback)

Retrieve custom meta value for the article

Parameters
Name Type Description
name String Name of the custom meta value  
callback Function function(Object), the parameter is an object containing the given custom meta value  
Returns
  • Void

ArticleCommunicator.setCustomMeta(name, value, callback)

Set custom meta value for the article

Parameters
Name Type Description
name String Name of the meta value  
value Object Value to set  
callback Function function()  
Returns
  • Void

ArticleCommunicator.setMetaChanged(callback)

Marks article model as having meta data changes

Parameters
Name Type Description
callback Function function()  
Returns
  • Void

ArticleCommunicator.setTags(tags, save, callback)

Set tags for the article

Parameters
Name Type Description
tags Array List of tags that should be set  
save Boolean Set to true to force save once the tags are updated  
callback Function function(Boolean), called when tags have been set  
Returns
  • Void

ArticleCommunicator.addTags(tags, errorFunction, callback)

Add tag for the article

Parameters
Name Type Description
tags Array Tags to be added  
errorFunction Function called if error  
callback Function function(Boolean), called when tag has been set  
Returns
  • Void

ArticleCommunicator.addTag(tag, errorFunction, callback)

Add tag for the article

Parameters
Name Type Description
tag String Tag to be added  
errorFunction Function called if error  
callback Function function(Boolean), called when tag has been set  
Returns
  • Void

ArticleCommunicator.addTags(tags, errorFunction, callback)

Add tags for the article

Parameters
Name Type Description
tags String Tags to be added  
errorFunction Function called if error  
callback Function function(Boolean), called when tag has been set  
Returns
  • Void

ArticleCommunicator.removeTag(tag, callback)

Remove tag from article

Parameters
Name Type Description
tag String Tag to remove  
callback Function function(Boolean), called when tag has been removed  
Returns
  • Void

ArticleCommunicator.getSelectedCategories(callback)

Get the selected categories

Parameters
Name Type Description
callback Function function([String]), array with category ids  
Returns
  • Void

ArticleCommunicator.saveCategories(callback)

Save the currently selected categories

Parameters
Name Type Description
callback Function function(Boolean), called when categories has been saved  
Returns
  • Void

ArticleCommunicator.setCategories(categories, callback)

Set selected categories

Parameters
Name Type Description
categories Array List of category IDs that should be set  
callback Function function(Boolean), called when categories have been set  
Returns
  • Void

ArticleCommunicator.addCategories(categories, callback)

Add the given categories to the list of categories

Parameters
Name Type Description
categories Array List of category IDs to add  
callback Function function(Boolean), called when the categories have been set  
Returns
  • Void

ArticleCommunicator.removeCategories(categories, callback)

Remove the given categories from the list of categories

Parameters
Name Type Description
categories Array List of category IDs to remove  
callback Function function(Boolean), called when the categories have been removed  
Returns
  • Void

ArticleCommunicator.setMainCategory(category, callback)

Set the main category of the current article

Parameters
Name Type Description
category Number The ID of the category to set as the main category  
callback Function function(Boolean), called when the main category has been set  
Returns
  • Void

ArticleCommunicator.getSource(callback)

Get the source set for the article

Parameters
Name Type Description
callback Function function(String), name of the source  
Returns
  • Void

ArticleCommunicator.setSource(value, callback)

Set the source for the article

Parameters
Name Type Description
value String The new value to be set as source  
callback Function function(Boolean), called when the source has been set  
Returns
  • Void

ArticleCommunicator.getStatus(callback)

Get the status for the article

Parameters
Name Type Description
callback Function function(String), current status  
Returns
  • Void

ArticleCommunicator.setStatus(status, callback)

Set the status for the article

Parameters
Name Type Description
status String The new status to be set (draft, waiting, published)  
callback Function function(Boolean), called when the source has been set  
Returns
  • Void

ArticleCommunicator.getPublishedDatetime(callback)

Get the published-date

Parameters
Name Type Description
callback Function function(String), current published datetime  
Returns
  • Void

ArticleCommunicator.setPublishedDatetime(published, callback)

Set the published-date

Parameters
Name Type Description
published String Date to be set (YYYY-MM-DD HH:MM:SS)  
callback Function function(Boolean), called when done  
Returns
  • Void

ArticleCommunicator.getAuthors(callback)

Get the authors set in the article

Parameters
Name Type Description
callback Function function([String]), currently set authors  
Returns
  • Void

ArticleCommunicator.setAuthors(authors, callback)

Set authors for the article

Parameters
Name Type Description
authors Array List of authors that should be set  
callback Function function(Boolean), called when it has been set  
Returns
  • Void

ArticleCommunicator.addAuthors(authors, callback)

Add the given authors to the list of authors

Parameters
Name Type Description
authors Array List of authors to add  
callback Function function(Boolean), called when it has been set  
Returns
  • Void

ArticleCommunicator.removeAuthors(authors, callback)

Remove the given authors from the list of authors

Parameters
Name Type Description
authors Array List of authors to remove  
callback Function function([String]), author list as it is after the authors has been removed  
Returns
  • Void

ArticleCommunicator.setKeywords(keywords, callback)

Set the keyword-list on the article

Parameters
Name Type Description
keywords Array List of keywords to add  
callback Function Function to call when keywords have been set  
Returns
  • Void

ArticleCommunicator.getKeywords(callback)

Get the current set of keywords on the article

Parameters
Name Type Description
callback Function Function to call with the result  
Returns
  • Void

ArticleCommunicator.getCurrentContent(callback)

Gets the current article content

Parameters
Name Type Description
callback Function function(Object Content)  
Returns
  • Void

ArticleCommunicator.setCurrentContent(content, callback)

Updates current article content

Parameters
Name Type Description
content String The new content for the article  
callback Function function(Boolean), called when it has been set  
Returns
  • Void

ArticleCommunicator.getArticletypeId(callback)

Get the article type of the current article

Parameters
Name Type Description
callback Function function(Int)  
Returns
  • Void

ArticleCommunicator.setArticletypeId(articletypeId, callback)

Set the article type of the current article

Parameters
Name Type Description
articletypeId Number The new article type of the article  
callback Function function(Boolean), called when it has been set  
Returns
  • Void

ArticleCommunicator.maximizePluginWindow(title, onClose)

Maximize the plugin view

Parameters
Name Type Description
title String Title to give the maximized view  
onClose function Function to call when the window is closed/minimized  
Returns
  • Void

ArticleCommunicator.maximizeAppWindow()

Returns
  • Void

ArticleCommunicator.restorePluginWindow(callback)

Restore the plugin pane to the default size

Parameters
Name Type Description
callback function Callback to call after everything is done  
Returns
  • Void

ArticleCommunicator.restoreAppWindow()

Restore the plugin pane to the default size

Returns
  • Void

ArticleCommunicator.getByline(callback)

Get the current byline

Parameters
Name Type Description
callback function function(String), xml string with the current byline  
Returns
  • Void

ArticleCommunicator.setByline(byline, save, callback)

Set the byline

Parameters
Name Type Description
byline String XML version of byline to use  
save Boolean If true, force save after updating byline information  
callback Function function(Boolean), called when it has been set  
Returns
  • Void

ArticleCommunicator.setGeolocations(geolocations, callback)

Set geolocation

Parameters
Name Type Description
geolocations Object The location to set  
callback Function function(Boolean), called when it has been set  
Returns
  • Void

ArticleCommunicator.getGeolocations(callback)

Get geolocation

Parameters
Name Type Description
callback Function function(Object), retrieves the currently set geo location  
Returns
  • Void

ArticleCommunicator.getProperties(callback)

Fetches a list of all properties available to an article.

Parameters
Name Type Description
callback Function Callback called with an array of property objects.  
Returns
  • Void

ArticleCommunicator.setProperties(properties, callback)

Updates and saves one or more property values. The input is a simple object with property names and their new value. The supplied callback is called with an updated list of properties.

Parameters
Name Type Description
properties Object An object of property names and corresponding values.  
callback Function Callback called with an updated list of properties.  
Examples
PluginAPI.Article.setProperties({
    fooProperty: "bar",
    barProperty: "foo"
}, function(properties) {
    // Returns a complete and updated list of properties.
})
Returns
  • Void

ArticleCommunicator.setProperty(name, value, callback)

Updates and saves a single property.

Parameters
Name Type Description
name String The property to update.  
value Object The updated value.  
callback Function Callback called with an updated list of properties.  
Returns
  • Void

Documentation generated with doxdox.