Closed ggrossetie closed 2 years ago
So, you mean implement a node app instead of the desktop tool? Do you want https://github.com/jgraph/draw-image-export2 ?
I was under the impression that jgraph/draw-image-export2
was the "legacy" implementation? The description says: "The 2018 server-side PNG/PDF export implementation using Node, Puppeteer and Chrome headless".
Also jgraph/draw-image-export2
relies on an external service (draw.io server), so it's not really a standalone application:
await page.goto((process.env.DRAWIO_SERVER_URL || 'https://viewer.diagrams.net') + '/export3.html', {waitUntil: 'networkidle0'});
No, that's the current server-side generation, it's just we switched to that new architecture in 2018.
It doesn't rely on anything external, that is the external server. export3.html just happens to be served externally, it could just as well be bundled on that node sever.
No, that's the current server-side generation, it's just we switched to that new architecture in 2018.
ππ»
It doesn't rely on anything external, that is the external server. export3.html just happens to be served externally, it could just as well be bundled on that node sever.
So the static resources are available here https://github.com/jgraph/drawio/tree/dev/src/main/webapp right? Should I worry about breaking changes? Should I use a specific version? latest?
In theory, I only need to serve the following files:
export3.html
js/export-init.js
mxgraph/css/common.css
export-fonts.css
js/app.min.js
js/export.js
math
(for MathJax)Is that correct? I will give it a try and report back, thanks for your guidance ππ»
Yes, that look like the right list (you'll soon find out if one is missing :) ).
Is your feature request related to a problem? Please describe.
The diagrams.net (Electron-based) CLI is very useful but I would like to read a diagram from stdin and write the output to stdout to avoid file manipulations.
It would be particularly useful when executing the CLI from a program. For instance, let's say that I want to write a small HTTP service on top of the CLI. I will receive the input diagram as a request body and I want to write the result in the response. In this case, I don't want to:
It would be more efficient to execute the command with the input file as stdin and to read the result from stdout. No file manipulation.
Describe the solution you'd like
When exporting a single input file to a single output file, we could allow diagrams.net CLI to read it from stdin and output the result to stdout. By convention, command-line interfaces usually use
-
(dash character), for instance:The above command will read the diagram from stdin. It's also common to output to stdout (by default) when the input is read from stdin. In other words, the above command will output to stdout by default, but the following command will output to
output.svg
:Similarly, if we want to explicitly output to stdout then we can use the value
-
:Please note that the value of the parameter
output
is-
.Describe alternatives you've considered
I guess writing my own CLI inspired by
electron.js
but that would be a maintenance burden.For reference, I did try to create a simple CLI based on Puppeteer (instead of Electron) but I had to make some changes to export.js in order to be able to call the right functions from Puppeteer (most notably
render
andget-svg-data
callback).If this is something that you would like to support (i.e., providing both an Electron-based CLI and a Puppeteer-based CLI) then I would gladly help. I know that diagrams.net is closed to contributions but let me know if I can be of any help.
Additional context
I'm working on https://kroki.io and I would like to provide an API to convert diagrams.net XML files to PNG, JPEG or SVG images (and potentially PDF and VSDX). As far as I understand, diagrams.net is using the browser (client-side JavaScript) to convert diagrams to images. So, I'm looking for a self-contained and lightweight solution to provide this service server-side.