Add file handling (#1736)
* Add file handling https://github.com/WICG/file-handling/blob/master/explainer.md#example * Only trigger on `.excalidraw` for now
This commit is contained in:
parent
998f0ae458
commit
6b87278a0f
@ -17,5 +17,13 @@
|
|||||||
"start_url": ".",
|
"start_url": ".",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"theme_color": "#000000",
|
"theme_color": "#000000",
|
||||||
"background_color": "#ffffff"
|
"background_color": "#ffffff",
|
||||||
|
"file_handlers": [
|
||||||
|
{
|
||||||
|
"action": "/",
|
||||||
|
"accept": {
|
||||||
|
"application/vnd.excalidraw+json": [".excalidraw"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,7 @@ export const actionClearCanvas = register({
|
|||||||
showAriaLabel={useIsMobile()}
|
showAriaLabel={useIsMobile()}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (window.confirm(t("alerts.clearReset"))) {
|
if (window.confirm(t("alerts.clearReset"))) {
|
||||||
// TODO: Defined globally, since file handles aren't yet serializable.
|
// TODO: Make this part of `AppState`.
|
||||||
// Once `FileSystemFileHandle` can be serialized, make this
|
|
||||||
// part of `AppState`.
|
|
||||||
(window as any).handle = null;
|
(window as any).handle = null;
|
||||||
updateData(null);
|
updateData(null);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import App from "./components/App";
|
|||||||
import { register as registerServiceWorker } from "./serviceWorker";
|
import { register as registerServiceWorker } from "./serviceWorker";
|
||||||
|
|
||||||
import "./css/styles.scss";
|
import "./css/styles.scss";
|
||||||
|
import { loadFromBlob } from "./data";
|
||||||
|
|
||||||
// On Apple mobile devices add the proprietary app icon and splashscreen markup.
|
// On Apple mobile devices add the proprietary app icon and splashscreen markup.
|
||||||
// No one should have to do this manually, and eventually this annoyance will
|
// No one should have to do this manually, and eventually this annoyance will
|
||||||
@ -88,3 +89,16 @@ registerServiceWorker({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ("launchQueue" in window && "LaunchParams" in window) {
|
||||||
|
(window as any).launchQueue.setConsumer(
|
||||||
|
async (launchParams: { files: any[] }) => {
|
||||||
|
if (!launchParams.files.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const fileHandle = launchParams.files[0];
|
||||||
|
const blob = await fileHandle.getFile();
|
||||||
|
loadFromBlob(blob);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user