How to export Draw.io 'xml' data using javascript API for my Custom Web Application? (Retrieving XML Data from Canvas via Iframe) #4854
mesbahworld
started this conversation in
General
Replies: 1 comment
-
My understanding is that an iframe is completely independant of your web app. I my case, the server send back some element info to dynamicly highlight part of the diagram |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I am working on integrating the Draw.io editor into my custom web application, which is based on html css js. As a data modeler, I know little javascript. I have successfully embedded Draw.io in an iframe and can interact with it to some extent. However, I need help retrieving the designed ERD diagram's XML data from the canvas and passing it back to my application for further processing and generate SQL DDL script from ERD model. But I am unable to do that and here is my current situation:
Current Setup
Hosting Environment:
I have deployed the Draw.io editor on my own server using Tomcat, with NGINX as a proxy. The application is accessible via this URL:
https://app.flingex.com/draw/
Integration with Web App:
I have embedded the Draw.io editor in an iframe on one of my Web Application using the following code:
Objective:
I want to retrieve the clean XML data of the diagram designed in the Draw.io editor via the iframe using
postMessage
. The XML data will then be stored in the database for further manipulation and generate SQL DDL script from ERD model .What I've Tried
Sending
postMessage
to the IframeI used the following JavaScript to send a message to the iframe:
Listening for Messages in the Iframe
I opened the iframe directly in a new tab (
https://app.flingex.com/draw/
) and added this listener to debug:Results:
postMessage
seems to send successfully, but I don’t see any response or XML data being returned to my application.Expected Behavior
{ action: 'export', format: 'xml' }
to the iframe, I expect the iframe to respond with the exported XML data from the Draw.io canvas.Questions
postMessage
events for exporting XML data?Additional Information
embed=1
in the iframe URL, as I want to keep the design tools visible.https://app.flingex.com/draw/
works fine when accessed directly.What I Need
I’m looking for guidance on how to properly implement the following:
postMessage
or another method).Thank You!
I appreciate any help or suggestions to solve this issue. Let me know if you need more details or access to any specific code snippets.
**Tags **
draw.io
iframe
postmessage
javascript
html
Beta Was this translation helpful? Give feedback.
All reactions