You can declare custom content in Confluence. This content behaves like built-in Confluence content types, such as page, blog post, or comment.
Custom content can be:
You can also find a step by step tutorial series covering all the aspects of custom content here: Custom Content with Confluence Connect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
{
"modules": {
"customContent": [
{
"uiSupport": {
"contentViewComponent": {
"addonKey": "addon-key",
"moduleKey": "dialog-module-key"
},
"icons": {
"item": {
"width": 16,
"height": 16,
"url": "/item.png"
}
}
},
"apiSupport": {
"bodyType": "storage",
"supportedContainerTypes": [
"space",
"page"
],
"supportedChildTypes": [
"attachment",
"comment"
],
"supportedSpacePermissions": [],
"preventDuplicateTitle": false,
"indexing": {
"enabled": true
}
},
"name": {
"value": "My Content Type Name"
},
"key": "my-custom-content"
}
]
}
}
The above snippet defines your custom content: my-custom-content
.
You can create a new piece of content with this type by posting the following JSON to the Confluence /rest/api/content
endpoint.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{
"type":"ac:my-addon-key:my-custom-content",
"title":"My content title",
"space":{
"key":"ds"
},
"body":{
"storage":{
"value":"This is my content body",
"representation":"storage"
}
}
}
The content type key for custom content is defined in 3 parts:
ac
my-addon-key
my-custom-content
Content type key ac:my-addon-key:my-custom-content
should be used for
creating custom content that's defined in a Connect add-on with the key of my-addon-key
and module key of my-custom-content
apiSupport
Type | |
Required | Yes |
Description | This property allows you to specify the container types your custom content can appear in, and its supported child content types. It also allows you to enable indexing of your custom content. This property allows you to specify the container types your custom content can appear in, and its supported child content types. It also allows you to enable indexing of your custom content. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
In the above example, you'll see we specify content type keys in the Built-in content types exampleThe following snippet shows the content type we're defining can:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Custom content exampleThe following snippet shows the content type we're defining can:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Raw body type custom content exampleYou can define custom content to support a content body with a type ofraw .This is useful when you want to store, for example, stringified JSON to the content. 1 2 3 4 5 6 7 8 9 10 11 12 13
Content with a raw body looks like this: 1 2 3 4 5 6 7 8 9 10 11 12 13
|
supportedContainerTypes |
| ||||||||
bodyType |
| ||||||||
indexing |
| ||||||||
preventDuplicateTitle |
| ||||||||
supportedChildTypes |
| ||||||||
supportedSpacePermissions |
|
key
Type | |
Max length | 100 |
Required | Yes |
Pattern | ^[a-zA-Z0-9-]+$ |
Description | A key to identify this module. This key must be unique relative to the add on, with the exception of Confluence macros: Their keys need to be globally unique. Keys must only contain alphanumeric characters and dashes. The key is used to generate the url to your add-on's module. The url is generated as a combination of your add-on key and module key. For example, an add-on which looks like: { "key": "my-addon", "modules": { "configurePage": { "key": "configure-me", } } }
Will have a configuration page module with a URL of |
name
Type | |
Required | Yes |
Description | A human readable name. Represents a string that can be resolved via a localization properties file. You can use the same Example1 2 3 4
|
value |
| ||||||||
i18n |
|
uiSupport
Type | |
Required | Yes |
Description | Declares information for rendering the custom content in the UI. Declares information related for rendering the custom content in the UI. 1 2 3 4 5 6 7
View component exampleSuppose we already defined a general page module like following:1 2 3 4 5 6 7 8
And also the general page is used as a view component in ui support section. 1 2 3 4 5 6
When a user clicks the title of the corresponding custom content in the search result.
{ac.customData} in the example above, it will be substituted with the value
of the ac.customData parameter that will be taken from the Confluence's current URL. Add-on developers can specify any number of custom parameters, provided that they
have names that follow this convention: ac.parameter_name .
If more than one custom parameter with the same name is defined in Confluence's current URL, only the first value will be used.
For additional information on custom parameters see Context Parameters.
Context ParametersView components support Confluence context parameters. When rendering the view component the context variables will be passed to the URL that is defined in the corresponding view component module.You can retrieve the content or space information with these parameters via Confluence REST API and render it according to your needs. Please consult Context Parameters for what parameters are currently supported. |
contentViewComponent |
| ||||||||||||||||
icons |
| ||||||||||||||||
breadcrumbs |
| ||||||||||||||||
editComponent |
| ||||||||||||||||
editComponentCancelButtonLabel |
| ||||||||||||||||
editComponentSubmitButtonLabel |
| ||||||||||||||||
editComponentTitlePlaceholder |
| ||||||||||||||||
listViewComponent |
|
description
Type | |
Description | The description of the custom content Represents a string that can be resolved via a localization properties file. You can use the same Example1 2 3 4
|
value |
| ||||||||
i18n |
|
Rate this page: