add support for file system access api when available
This commit is contained in:
parent
414ac87814
commit
f74175564e
1 changed files with 11 additions and 0 deletions
|
|
@ -532,6 +532,17 @@ gapp.register("kiri.main", [], (root, exports) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFile() {
|
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');
|
const button = $('load-file');
|
||||||
button.onchange = function(event) {
|
button.onchange = function(event) {
|
||||||
console.log(event);
|
console.log(event);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue