It seems easy to write a macro to draw a diagram with external draw.io service

Why there is no such extension exist aleady :rofl:?

I just begin to read developer guides, but I think it will be easy to write a marco, which insert a iframe which contain draw.io page, and get back the diagram as text data and store it in page.

Do you guys have a different idea on this ?

I know there is already a diagram application, but that one seems pack draw.io as webjar, for me it’s a bit werid as draw.io can be used in embemd mode, don’t know why ? :innocent:

See https://extensions.xwiki.org/xwiki/bin/view/Extension/Diagram%20Application and https://store.xwiki.com/xwiki/bin/view/Extension/DiagramApplication

@vmassol sorry for late reply, thanks for your response.

can you help on my first try to implement a macro ?

{{velocity}}
#if($xcontext.action == 'edit')
  {{html}}
    <iframe src="http://172.31.25.15:8280/?embed=1&protocol=json" />
  {{/html}}
#else
  {{html}}
    <img src="data:image/png;base64," />
  {{/html}}
#end
{{/velocity}}

my first problem is when editing a page in WYSISWYG editor, the $xcontext.action is always equal to ‘view’, so I can’t embed a iframe to let user create diagram with external draw.io.

my second problem is I have no idea how to set content at client side using javascript, when the draw.io iframe finished I cant get back the diagram data as text, but how to update it back to server side as macro’s content ?

please help.