Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Markus Perndorfer January 8, 2020

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

1 accepted

0 votes
Answer accepted
David Benson _draw_io_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 8, 2020

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

Markus Perndorfer January 8, 2020

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

Markus Perndorfer January 14, 2020

Any chance to get the old behaviour back?

Boris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2020

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. 

Markus Perndorfer January 30, 2020

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?

Markus Perndorfer February 24, 2020

Is this fix in 9.2.8?

Boris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2020

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

ee November 16, 2021

it's version 9.1.

after setting emailpreview=1, the export_view is still js code.

how to rollback to base64 encode images.image.png

David Benson _draw_io_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2021

9.1 is too old, you need to update to get the change.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events