UI Kit components
Jira UI Kit components
UI Kit hooks
Forge bridge APIs
Jira bridge APIs
Confluence bridge APIs
Upgrade UI Kit versions
Previous versions

getMacroContent

getMacroContent is an asynchronous function that allows your macro to retrieve the current, up-to-date ADF of the macro as seen in the editor. It returns a JSON-stringified data object containing the ADF of the macro. This function works only in edit modes (e.g. a Live Doc or edit mode of a Page). You can get this info from the isEditing property in the extension context.

Example

This example shows how to use getMacroContent.

1
2
import { getMacroContent } from '@forge/confluence-bridge';

const macroContent = await getMacroContent(); // Use macroContent as desired

Response Type

The getMacroContent function returns an object with the following structure:

NameTypeDescription
datastringA stringified macro ADF object.

Example Response

1
2
{
    data: '{"type":"bodiedExtension","attrs":{"extensionKey":"cool-bodied-macro","extensionType":"com.atlassian.ecosystem","layout":"default","localId":"0","parameters":{"localId":"0","extensionId":"ari:cloud:ecosystem::extension/cool-bodied-macro","extensionTitle":"Cool bodied macro","forgeEnvironment":"DEVELOPMENT","render":"native"}},"content":[{"content":[{"text":"hello","type":"text"}],"type":"paragraph"}]}'
}

Example response after data goes through JSON.parse

1
2
{
    "type": "bodiedExtension",
    "attrs": {
        "extensionKey": "cool-bodied-macro",
        "extensionType": "com.atlassian.ecosystem",
        "layout": "default",
        "localId": "0",
        "parameters": {
            "localId": "0",
            "extensionId": "ari:cloud:ecosystem::extension/cool-bodied-macro",
            "extensionTitle": "Cool bodied macro",
            "forgeEnvironment": "DEVELOPMENT",
            "render": "native"
        }
    },
    "content": [
        {
            "content": [
                {
                    "text": "hello",
                    "type": "text"
                }
            ],
            "type": "paragraph"
        }
    ]
}

Rate this page: