mikitex70 / redmine_drawio

Macro plugin to embed draw.io diagrams into Redmine wiki pages
MIT License
121 stars 51 forks source link

Can't edit macros after initial insert #135

Open vomus opened 6 months ago

vomus commented 6 months ago

Hi! I inserted a macro from visual_editor button, it it all right

{{drawio_attach(RnD_task_1.drawio,size=512,hilight=#0000ff)}}

and I can edit the diagram. However when redmine rendered my wiki page it showed the diagram of a rather small size. So I went to the editing and inserted size=512. After saving I get a macros error

drawio_attach ("\xD0" from ASCII-8BIT to UTF-8)

Is this a bug?

mikitex70 commented 6 months ago

I @vomus, I've done some testing and the problem seems to be due to a non-ASCII character in the attachment name. It will take me a while to figure out how I will fix it.

mikitex70 commented 6 months ago

Hi @vomus, I have pushed a fix in the develop branch. Git it a try.

vomus commented 6 months ago

Will do this evening

vomus commented 5 months ago

I have tested the dev branch, the bug disappeared! This is great. The one thing, however, I probably do not understand. I set the 'drawio' drawing type but changing a 'size' parameter in the macro does not make drawing any bigger or smaller . Should it do that or 'size' means something different?

When I choose a 'png' drawing type it works as expect it to. But where does it keep an original drawing for further editing?

mikitex70 commented 5 months ago

Hi @vomus, diagrams in the xml or drawio formats are rendered by the drawio viewer library, which ignores the size of the size of the container element. Instead, diagrams in the png or svg format are rendered by the browser, which uses this size to scale the image. I have added an initialzoom parameter (and relative input in dialogs) so you can set the initial zoom factor of the diagram (default is 100%), which can be changed by the user using the zoom in and zoom out buttons on the viewer toolbar (if enabled). Try to see if this solution meets your needs.

vomus commented 5 months ago

Yeah... It works... It would be cool by the way to be able to save zoom level that is chosen at zoom control on the toolbar.

And finally, export to svg/png when saving a page to pdf/html. Now if drawing are in drawio format they can not be exported into printable page...

mikitex70 commented 5 months ago

No, al this is not feasible: the diagram viewer is this, a viewer, and it is made by the Draw.io team. Maybe i can find a way to read the actual zoom level in the diagram, but I can't pass it to the edit page as a zoom default do be saved. The diagram viewer runs in page view, the editing is done in another page and this is how Redmine works.

The export in PNG/SVG has similar limitations: the viewer can only show diagrams, the export is done by the Draw.io editor. Maybe I can find an API on the Draw.io server to request the export ... but I'm not sure.

Printing the whole page with the diagram is also a problem: the diagram is rendered on the browser, the PDF is generated by the server, which cannot execute the viewer library (it is a client library, not a server library). If printing the diagram with the page is important there are two solutions:

vomus commented 5 months ago

I see. Thanks.