mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Implement the Web Share Target API (#3230)
* Use the web share target API * Make requested changes * Remove line * Add application/json back * Add application/vnd.excalidraw+json * Add 'POST' check back * Make requested changes * Update src/appState.ts Co-authored-by: Thomas Steiner <tomac@google.com> * Update test * Override initializeScene * Use Excalidraw MIME type * Minor fixes * More MIME type tweaks * More permissive file open * Be overpermissive in file open Co-authored-by: Thomas Steiner <tomac@google.com> Co-authored-by: tomayac <steiner.thomas@gmail.com>
This commit is contained in:
parent
f1daff2437
commit
b9e70ec666
6 changed files with 11846 additions and 11397 deletions
|
@ -47,3 +47,20 @@ workbox.routing.registerRoute(
|
|||
plugins: [new workbox.expiration.Plugin({ maxEntries: 10 })],
|
||||
}),
|
||||
);
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
if (
|
||||
event.request.method === "POST" &&
|
||||
event.request.url.endsWith("/web-share-target")
|
||||
) {
|
||||
return event.respondWith(
|
||||
(async () => {
|
||||
const formData = await event.request.formData();
|
||||
const file = formData.get("file");
|
||||
const webShareTargetCache = await caches.open("web-share-target");
|
||||
await webShareTargetCache.put("shared-file", new Response(file));
|
||||
return Response.redirect("/?web-share-target", 303);
|
||||
})(),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue