It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How get embedded draw.io diagrams when accessing a page via Confluence REST API? Edited

A draw.io diagram on a page used to be an embedded, base64-encoded png in the body.export_view of a page, e.g:

GET https://confluence.company.com/rest/api/content/123456789?expand=metadata.labels,children.page,version,body.export_view

Old Response

{
"id": "123456789",
"type": "page",
"status": "current",
...
"body": {
"export_view": {
"value": "<img class=\"drawio-diagram-image\" src=\"data&colon;image/png;base64,c0debabe..."
}
}
}

 

But since a recent upgrade of the draw.io plugin (8.5.1 -> 9.2.6), I get a useless JS code block for every diagram on a page

New Response

{ 
"id": "123456789",
"type": "page",
"status": "current",
...
"body": {
"export_view": {
"value": "<span id=\"drawio-macro-content-cae9a5a5-bb84-4eba-83d2-b2f5798cf226\" style=\"position:relative;display:inline-block;max-width:100%;overflow:hidden;border:1px solid transparent;\"></span>\n\n<script type=\"text/javascript\">\n(function()\n{\n\t$ = AJS.$;\n\t\n\tvar graphContainer = document.getElementById('drawio-macro-content-cae9a5a5-bb84-4eba-83d2-b2f5798cf226');\n\tvar DrawioProperties = { contextPath : AJS.contextPath() };\n\t\n\tvar readerOpts = {};\n\t\t\treaderOpts.loadUrl = '' + '/rest/drawio/1.0/diagram/crud/..."
}
}
}

 

Is there any way to replace the JS code block with e.g. link to the rendered diagram?
(Maybe a configuration option for the plugin?)

Theoretically I could parse the JS script block and use the properties of readerOpts to construct the link to the rendered diagram that's available as attachment on the page anyway, but I really don't want to go down that rabbit hole.

1 answer

Are you sure it's a change to the plugin and not a Confluence update that caused the change?

Reasonably sure, yes. (I'm only a user of this particular confluence server, not an admin)

The change of the output format directly coincides with the plugin update.

I was able to dig up the previous version: 8.5.1

Any chance to get the old behaviour back?

We have implemented an admin setting which will act as a switch. Default will be 1 which will embed the diagram in the output.

It will be in the next release. 

that's great to hear!

Looking forward to the next version, so I can remove the JS script block parsing again...

Any ETA on the release?

Is this fix in 9.2.8?

It is. Search for 'emailpreview' in the docs here.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

32 views 2 4
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you