add support for file system access api when available

This commit is contained in:
Stewart Allen 2022-10-19 23:30:17 -04:00
commit f74175564e

View file

@ -532,6 +532,17 @@ gapp.register("kiri.main", [], (root, exports) => {
}
function loadFile() {
// use modern Filesystem api when available
if (window.showOpenFilePicker) {
window.showOpenFilePicker().then(files => {
return Promise.all(files.map(fh => fh.getFile()))
}).then(files => {
if (files.length) {
api.platform.load_files(files);
}
}).catch(e => { /* ignore cancel */ });
return;
}
const button = $('load-file');
button.onchange = function(event) {
console.log(event);