d2-playground icon indicating copy to clipboard operation
d2-playground copied to clipboard

Hope to add `/export/{format}` to render raw svg/png directly

Open morlay opened this issue 3 years ago • 4 comments

Like mermaid.live did

https://mermaid.live/view#pako:eNptkMtqAzEMRX9F0bYzP-BFSqGFppBVt7NRPDcZgx-Jx6aEkH-PxtMuCvHqWjpHIN3YphFseMalIlq8OzllCUMkfW_eWfTb7ctXmqKhT3ifaMkdTemHJIOuqb4-hVfMSlwQmiCZAn7Rpdcr2jdHB7vV7mjXjEartnmO7-gIeDplSNlwxwE5iBt1i9siDFwmBAxsNB5k1jTEu3JSS_q-Rsum5IqO63mU8rfx_-LH6ErKbI7iZy2ifffrqdrF7g9-RmWe

Hope to add /export/{format} to render raw svg/png

https://play.d2lang.com/export/{format}?script=qlDQtVOo5AIEAAD__w%3D%3D&layout=dagre&theme=8

In this way, we could be easy to back to edit mode, with the shared link.

https://play.d2lang.com?script=qlDQtVOo5AIEAAD__w%3D%3D&layout=dagre&theme=8

morlay avatar Jan 06 '23 10:01 morlay

@morlay Yup, D2 will soon have this. E.g. https://github.com/alixander/test-render/edit/main/README.md

alixander avatar Jan 06 '23 17:01 alixander

@alixander looks good. but now seems got 403 error when visit directly.

https://api.d2lang.com/render/svg?script=qlDQtVOo5AIEAAD__w==&layout=dagre&theme=101&sketch=1

morlay avatar Jan 09 '23 03:01 morlay

yes, it's whitelisted to only allow from playground and github right now. Do you have somewhere else specific you'd like to access the api from or are you just testing? @morlay

alixander avatar Jan 09 '23 18:01 alixander

@alixander

Now just testing, but hope it could be embed in other doc systems in future.

I found kroki already start to support d2 https://github.com/yuzutech/kroki/pull/1414 If d2-playground have github limited, I have to wait the next release of kroki.

morlay avatar Jan 10 '23 03:01 morlay