Skip to content

Export site file as JSON on wasm#427

Open
xiyuoh wants to merge 5 commits intomainfrom
xiyu/export_json
Open

Export site file as JSON on wasm#427
xiyuoh wants to merge 5 commits intomainfrom
xiyu/export_json

Conversation

@xiyuoh
Copy link
Copy Markdown
Member

@xiyuoh xiyuoh commented Apr 10, 2026

This PR targets #423 and provides a way for users to export their site JSON on web via copy/paste. The objective is to allow users to store changes they made on the web editor.

Currently we do not support saving to file on wasm due to limitations in accessing the file system, so as a workaround this PR generates the site file to JSON string and allows the user to copy it. There could be better alternatives out there and I'm open to suggestions!

One thing to note - write_text() is currently only enabled for secure context (e.g. https://, localhost), more details here.

CC @JohnTGZ

To test

Follow instructions on the main README to run the editor on web. Under File in the top menu bar, you'll see an Export JSON button. Upon clicking on it a dialog will appear with the JSON string and button to copy all to clipboard.

image

xiyuoh added 2 commits April 10, 2026 04:21
Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
@xiyuoh xiyuoh requested a review from mxgrey April 10, 2026 04:36
@mxgrey mxgrey added this to PMC Board Apr 10, 2026
@github-project-automation github-project-automation Bot moved this to Inbox in PMC Board Apr 10, 2026
@luca-della-vedova
Copy link
Copy Markdown
Member

I'm guessing there is no way to do a "Download" instead?

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
@xiyuoh
Copy link
Copy Markdown
Member Author

xiyuoh commented Apr 13, 2026

@luca-della-vedova Added in 708d35c

@JohnTGZ
Copy link
Copy Markdown
Contributor

JohnTGZ commented Apr 14, 2026

Hi XY, this feature is great! Not directly related to this PR, but now you can update the following line in the root README.md to highlight this new alternative feature:

TODO: The web assembly version is highly experimental, currently it lacks important features like saving/loading of map files.

@mxgrey mxgrey moved this from Inbox to In Review in PMC Board Apr 21, 2026
@mxgrey
Copy link
Copy Markdown
Collaborator

mxgrey commented May 4, 2026

@JohnTGZ @xiyuoh

Any opinions on whether the Download file button should also be included in the File menu when compiled to WASM? Is there a particular reason to have users click through two steps (Export Json -> Download file) instead of one?

@xiyuoh
Copy link
Copy Markdown
Member Author

xiyuoh commented May 5, 2026

@mxgrey I was thinking of both download and copy/paste features to be accessible within the Export JSON widget and let the users decide how they'd like to retrieve their site JSON. For example it's faster for me to copy the JSON over downloading a new file in my workflow, but others might prefer the download approach. I believe crossflow's diagram editor works the same. No strong opinions though, I'd be happy to move the Download option to the File menu directly.

@JohnTGZ
Copy link
Copy Markdown
Contributor

JohnTGZ commented May 5, 2026

@mxgrey I was thinking of both download and copy/paste features to be accessible within the Export JSON widget and let the users decide how they'd like to retrieve their site JSON. For example it's faster for me to copy the JSON over downloading a new file in my workflow, but others might prefer the download approach. I believe crossflow's diagram editor works the same. No strong opinions though, I'd be happy to move the Download option to the File menu directly.

I don't have a strong opinion either. But I think offering the ability to copy text could be convenient during development.

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
@xiyuoh
Copy link
Copy Markdown
Member Author

xiyuoh commented May 5, 2026

Added Download File to the main dropdown in 25d2f8d

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

4 participants