marcveens / react-drawio

React component for integrating the Diagrams (draw.io) embed iframe
MIT License
43 stars 8 forks source link

Ability to supply a baseUrl #4

Closed sabinayakc closed 6 months ago

sabinayakc commented 8 months ago

Hey thanks for the repo first of all.

I was needing a react iframe like component and stumbled upon your repo.

However, I use a self hosted instance of draw.io and so was wanting to provide my own url.

This PR should allow that.

Let me know.

Thanks again.

sabinayakc commented 8 months ago

Need to handle this one as well. Maybe you might have a better idea?

https://github.com/marcveens/react-drawio/blob/5d3c1e81ca60dad1e851721ab041359b4c7129a1/src/utils/handleEvent.ts#L8

marcveens commented 6 months ago

Hi @sabinayakc,

Thanks for your PR and sorry for not responding sooner. Good addition!

In regards to your question, since you already have the baseUrl available in the DrawIoEmbedcomponent, you can also pass it to handleEvent on line 38 as an extra argument. Then the line you provided can become something like if (!event.origin.includes('embed.diagrams.net') && !event.origin.includes(baseUrl)) {.

sabinayakc commented 6 months ago

Done!

marcveens commented 6 months ago

Awesome, looks good, thanks for your contribution!