espruino / EspruinoWebIDE

The Espruino Web IDE - A Chrome Web App for programming Espruino
Apache License 2.0
367 stars 158 forks source link

Use File System Access API if supported #254

Closed sauerman closed 3 years ago

gfwilliams commented 3 years ago

Thanks! Sorry for the delay looking at this. I was on holiday.

Ideally I'd have liked to keep the IDE working the same for 'normal' users (eg, no extra clicks needed), and I'm trying to avoid async and destructuring in the codebase at the moment. However I took your code as a base and re-wrote the IDE side of things in 3970caa2b938db985dda2280635536f43087c44b

It should now be live at https://espruino.github.io/EspruinoWebIDE if you want to give it a try.

Basically, you open a file (which is as normal), then click the down-arrow to choose what happens. If you choose the 'upload' option then every time the file changes, the editor contents will be reloaded and the file sent to the device - which should be great for integration with VSCode/etc.

Thanks!

gniezen commented 3 years ago

If I understand correctly, this only handles the "Open file" side of things, but not the "Save file" part? I would imagine the File System Access API would be ideal to also save the file that's currently open?

Looking at https://github.com/espruino/EspruinoWebIDE/commit/3970caa2b938db985dda2280635536f43087c44b#diff-51d9f89cc909b0b11ec0534e24afded705617d1488ed4c49882aa8fab5352c16R215-R222 I should be seeing a "Save file.." dialog, but I'm not sure how to get this working?

gfwilliams commented 3 years ago

I'm not sure how to get this working?

You just click the 'save' button?

But yes, right now it puts up a dialog each time you press the save button. Ideally it'd remember the file and just write to it again. What stopped me was figuring out how to do that nicely via the UI. I'm thinking maybe a drop-down under 'save' like we have for open and upload...

So first time (unless you opened a file before, you get the dialog). Otherwise you only get the dialog if you use the drop-down and 'Save As'.

gniezen commented 3 years ago

right now it puts up a dialog each time you press the save button.

Hmm, that's not what happened for me. It just saved a new copy to my Downloads folder.

I'm thinking maybe a drop-down under 'save' like we have for open and upload...

Yes, I think that could work!

gfwilliams commented 3 years ago

Sorry - closing this again. I thought it was an issue rather than PR :)

It just saved a new copy to my Downloads folder.

Argh, that's not good. What OS/browser are you on?

drmercer commented 1 year ago

It just saved a new copy to my Downloads folder.

Argh, that's not good. What OS/browser are you on?

This also happens to me, using Edge on Linux.