skanaar / nomnoml

The sassy UML diagram renderer
https://www.nomnoml.com
MIT License
2.66k stars 208 forks source link

[enhancement] Add nomnoml source code into image metadata #115

Closed stolksdorf closed 4 years ago

stolksdorf commented 4 years ago

Keeping rendered nomnoml diagrams and their source "linked" is a tricky problem, eg. I make a png diagram for a slideshow at work, if I don't save the source for that diagram somewhere, it will be lost.

It would be great that when you render either a SVG or a PNG, nomnol would embed the source code into the image file to be read and edited later.

For SVGs this is pretty easy, there's a metadata tag that can just store whatever you want. so thats perfect.

For PNGs it's a bit weirder. There is a text chunk but it seems less straight forward to use, and I'm not sure on it's max allowable size. You could of course embed the source data into the least significant color bits, but that seems like overkill.

It would also be great if the web editor could accept these images via drag and drop and populates the editor with the embedded source code.

I was inspired by Pico8 game cartridges.

Thoughts?

skanaar commented 4 years ago

Including the source in the SVG sounds like a good idea. Would you have time to make a pull request with such a change?

I am not immediately convinced that it is a good idea to embed data in the PNG files. Perhaps that could be a 3rd party service to handle stuff like that :)

stolksdorf commented 4 years ago

I started experimenting with this, couple things:

Do you have a preference/aversion to either of those ideas?

skanaar commented 4 years ago

Sound nice.

The file manager menu should have a button for “Open file” where you can select a .nomnoml or .svg file. Would be great to accept drag-dropping local files onto the browser window as well.

stolksdorf commented 4 years ago

Implemented in #117

skanaar commented 4 years ago

I have done some cleanup, and the feature turned out to be really nice! Will test it a bit and they deploy it.

skanaar commented 4 years ago

Deployed 🎉