Load drawio with files of different formats #12
-
Hi there, Is there a way to load DrawIoEmbed with different file types, not just XML? I want to load PNG, Visio files, etc., when the component is mounted. Currently, I can only load XML files by using the xml prop. If I spin up DrawIoEmbed, I can drop these files into the editor, and it works nicely, so there might be a way to do this programmatically. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
Hi Angus, According to the draw.io docs it should be possible, I just have to find some time to check whether it's easily implemented within this plugin. I'll get back to you later! |
Beta Was this translation helpful? Give feedback.
-
I just added an example of how to load a .png file, and transform it to the correct format: In case of .vsdx files, I don't know how draw.io handles them. There's not much to find online on how to parse those files. In the end, it should be an xml/base64 format one way or the other. I can't seem to parse that file type correctly, so unfortunately I'm not able to help with that. |
Beta Was this translation helpful? Give feedback.
-
Hey @marcveens, thanks for your response. So is that just loading in a base64 string in the XML? Whenever I try to do this I don't see anything appear in the editor, or I get an error e.g. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Is there a way to access the underlying |
Beta Was this translation helpful? Give feedback.
I just added an example of how to load a .png file, and transform it to the correct format:
https://github.com/marcveens/react-drawio/blob/f154102ec850d1ad1ea7a07479ebf7a483fcda7f/stories/DiagramsEmbed.stories.tsx#L53C1-L66C3
In case of .vsdx files, I don't know how draw.io handles them. There's not much to find online on how to parse those files. In the end, it should be an xml/base64 format one way or the other. I can't seem to parse that file type correctly, so unfortunately I'm not able to help with that.