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.
This example shows how to use getMacroContent
.
1 2import { getMacroContent } from '@forge/confluence-bridge'; const macroContent = await getMacroContent(); // Use macroContent as desired
The getMacroContent
function returns an object with the following structure:
Name | Type | Description |
---|---|---|
data | string | A stringified macro ADF object. |
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"}]}' }
data
goes through JSON.parse1 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: