Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File System Access API #101

Open
amytimed opened this issue Jun 19, 2024 · 1 comment
Open

File System Access API #101

amytimed opened this issue Jun 19, 2024 · 1 comment

Comments

@amytimed
Copy link

With the web's File System Access API, developers can open files and save changes to them without creating a new file.

Here's how it works:

let [fileHandle] = await window.showOpenFilePicker();

// Get file content
const file = await fileHandle.getFile();
const contents = await file.text();

const newContents = "...";

// Save changes to the file
const writable = await fileHandle.createWritable();
await writable.write(newContents);
await writable.close();

// Changes have been saved to the file the user opened!

Proposed Behavior

What I think would be great for BeepBox is for users to be able to open and edit files, then CTRL+S to write changes to the file they opened. BeepBox would keep track of if a certain file is opened, and would create a save dialog if the user does not have a .json file open.

CTRL+Shift+S could be used a Save As keyboard shortcut which would open a dialog to save in a new file instead of an existing one.

This would create a distinction between Open, Import, Save and Export:

  • Open would make BeepBox use the File System Access API, and show a file picker, then store a file handle, and save changes to that file on CTRL+S
  • Import would work exactly as before, but could potentially use a CTRL+I instead
  • Export would work exactly as before, but could potentially use a CTRL+E instead
  • Save would use the stored File System Access API file handle to save changes to the same file the user opened

What problem does this solve?

When I'm using BeepBox, I have to export to multiple formats each time I update my tracks (.json and .wav) in order to both keep the source file of the track, and also the actual audio file. With this solution, I could instead just CTRL+S each time I make a change, and export to audio when I need.

This would also make BeepBox behave more like most software, which typically have Save and Export as distinct features.

@Mid-The-Modder
Copy link

That would be lovely ngl

I have problems thinking in my head how the saving would exactly detect which .json file the original song came from unless given some extra special properties, but saving changes to a selected file would be very convenient so you don't gotta fill your downloads with 20 .jsons of the same song :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants