sacode387 / FlowRun

Runnable flowcharts for the web
https://flowrun.io/
Apache License 2.0
46 stars 9 forks source link

How to import exported programs? #2

Closed maubuz closed 1 year ago

maubuz commented 2 years ago

I can export the current diagram to the system's clipboard using both the "Copy Source" and "Copy DOT". However, how can I import the previously exported program?

Looking at the demo file index.html, it looks like the diagram DOT could be "inserted" into the <div class="flowrun-instance> and then rendered in the browser (graphviz's magic?). However, I get the impression this would have to happen in the back-end before the page is served.

If there isn't currently a way to import diagrams, what is recommend as the best approach to doing this? Once again, thank you for sharing this project.

sake92 commented 2 years ago

You have multiple options (not Graphviz' but Flowrun's "magic" 😛 ):


I probably could've implemented an "Import" button..
But at flowrun.io it's easier to just Fork/Copy an existing program from other people...

maubuz commented 2 years ago

Thank you for the answer. I was able to use the 3rd option suggested. It seems like that would be the path to an eventual import button.

While doing so, I noticed that the json object generated by the "Copy Source" button contain strings that the function loadEditor can't parse. For example, here is a json segment: "value":"\"Hello World\"", when called, loadEditor returns Uncaught SyntaxError: JSON.parse: expected ',' or '}' after property value in object. Once I changed the json strings to "value":"\\"Hello World\\"" (extra forward slash, like in your hello-word tutorial) then it loaded perfectly.

Maybe loadEditor was never intended to work with the json provided by "Copy Source", but I figure I would let you know since it's almost there 😉

The use case for an "Import" button would be:

I'm happy to discuss it further. During the semester it's hard but I would love to eventually take some time to learn Scala and contribute to the project. Lot's of potential. The Discord link you sent me seems to not send me anywhere.

sake92 commented 2 years ago

@maujac yeah, I had that issue too, never looked deep into it haha..

Your suggestions are something I thought about too.
That functionality would be really useful for teachers.
Shouldn't be too hard to implement it, hopefully just a few lines. 😃

Here is a correct invite, maybe that one expired, IDK: https://discord.gg/3fJA6DfHbA
Sure thing, we can chat there and figure it out. 😉

sake92 commented 1 year ago

@maujac I have implemented a download/load functionality.
Let me know if you spot any issues! :)