scripting: expose file browser (from the file widget) as a scripting function

This commit is contained in:
jean-emmanuel 2023-02-02 10:37:04 +01:00
parent ce73b5d374
commit 0ea2c49860
3 changed files with 39 additions and 1 deletions

View file

@ -369,3 +369,15 @@ If the event that triggered the script's execution was not initiated by a user i
#### `getNavigator()`
Returns the instance of [Navigator](https://developer.mozilla.org/en-US/docs/Web/API/Navigator).
----
#### `browseFile(options, callback)`
Opens the file file browser and pass selected file to a callback function (does not create nor read files by itself).
- `options`: object with the following keys:
- `extension`: allowed extension (default: "*")
- `directory`: starting directory for browser (default: user's home)
- `allowDir`: allow choosing a directory instead of a file (default: false)
- `mode`: "save" or "open"