Documentation

Confluence

A Confluence specific JavaScript module which provides functions to interact with the macro editor.

Methods

closeMacroEditor()

Closes the macro editor, if it is open.

This call does not save any modified parameters to the macro, and saveMacro should be called first if necessary.

Example
AP.confluence.closeMacroEditor();

getContentProperty(key, callback)

Provides the Content Property with the given key, on the current Content, to the callback.

Parameters:
Name Type Description
key String

the key of the property to retrieve

callback function

callback to be passed the content property

Example
AP.confluence.getContentProperty('propertyKey', function(property) {
  alert(property);
});

getMacroBody(callback)

Get the body saved in the saveMacro method.

Parameters:
Name Type Description
callback function

callback to be passed the macro data.

Example
AP.confluence.getMacroBody(function(body){
  alert(body);
});

getMacroData(callback)

Get the data saved in the saveMacro method.

Parameters:
Name Type Description
callback function

callback to be passed the macro data.

Example
AP.confluence.getMacroData(function(data){
  alert(data);
});

saveMacro(macroParameters, macroBody)

Save a macro with data that can be accessed when viewing the confluence page.

Parameters:
Name Type Description
macroParameters Object

data to be saved with the macro.

macroBody String

the macro body to be saved with the macro. If omitted, the existing body will remain untouched.

Example
AP.confluence.saveMacro({foo: 'bar'});

AP.confluence.saveMacro({foo: 'bar'}, "a new macro body");

setContentProperty(contentProperty, callback)

Sets the provided Content Property against the current Content, sending the result to the callback.

Parameters:
Name Type Description
contentProperty confluence~ContentProperty

the content property to create or update

callback function

callback to be passed the result

Example
AP.confluence.setContentProperty({
  key: 'propertyKey',
  value: 'propertyValue',
  version: {
    number: 2
  }
}, function(result) {
   alert(result.property); // the updated property, if successful
   alert(result.error);    // if unsuccessful, the reason for the failure
});

syncPropertyFromServer(key, callback)

Raise contentProperty.update event for the Content Property with the given key on the current Content. It also provide content property to the callback like getContentProperty does.

Parameters:
Name Type Description
key String

the key of the property to retrieve

callback function

callback to be passed the content property

Example
AP.confluence.syncPropertyFromServer('propertyKey', function(property) {
  alert(property);
});