• About the Connect JavaScript API
  • Confluence
  • Context
  • Cookie
  • Custom content
  • Dialog
  • Events
  • Flag
  • History
  • Host
  • Iframe
  • Inline dialog
  • Navigator
  • Request
  • Scroll position
  • User

Confluence

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

Methods

saveMacro (macroParameters, macroBody)

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

Parameters

NameTypeDescription
macroParametersObject

data to be saved with the macro.

macroBodyString

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

Example

1
2
3
AP.confluence.saveMacro({foo: 'bar'});

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

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

1
AP.confluence.closeMacroEditor();

getMacroData (callback)

Get the data saved in the saveMacro method.

Parameters

NameTypeDescription
callbackfunction

callback to be passed the macro data.

Example

1
2
3
AP.confluence.getMacroData(function(data){
  alert(data);
});

getMacroBody (callback)

Get the body saved in the saveMacro method.

Parameters

NameTypeDescription
callbackfunction

callback to be passed the macro data.

Example

1
2
3
AP.confluence.getMacroBody(function(body){
  alert(body);
});

onMacroPropertyPanelEvent (eventBindings)

Provide handlers for property panel control events

Event name components:

  • control-key: "key" property provided for the custom control declared in the JSON descriptor
  • event-type: type of user interaction, as described below
  • macro-key: "key" property provided for the macro declared in the JSON descriptor

Event types:

  • click: the property panel control was clicked by the user

Parameters

NameTypeDescription
eventBindingsObject

An object which specifies property panel events as keys and handler functions as values. The handler does not take any arguments.

Example

1
2
3
4
5
6
AP.confluence.onMacroPropertyPanelEvent({
  "{event-type}.{control-key}.{macro-key}.macro.property-panel": function() {
    // handle button click
    AP.confluence.closePropertyPanel();
  }
});

closeMacroPropertyPanel ()

Closes the macro property panel, if it is open.

Example

1
AP.confluence.closeMacroPropertyPanel();

getContentProperty (key, callback)

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

Parameters

NameTypeDescription
keyString

the key of the property to retrieve

callbackfunction

callback to be passed the content property

Example

1
2
3
AP.confluence.getContentProperty('propertyKey', function(property) {
  alert(property);
});

setContentProperty (contentProperty, callback)

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

Parameters

NameTypeDescription
contentPropertyconfluence~ContentProperty

the content property to create or update

callbackfunction

callback to be passed the result

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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

NameTypeDescription
keyString

the key of the property to retrieve

callbackfunction

callback to be passed the content property

Example

1
2
3
AP.confluence.syncPropertyFromServer('propertyKey', function(property) {
  alert(property);
});

  • System status
  • Privacy
  • Developer Terms
  • Trademark
  • Cookie Preferences
  • © 2019 Atlassian