From facd5fe4c73786c4c183e126e5c91709e867df20 Mon Sep 17 00:00:00 2001 From: Judicael <46365844+judicaelandria@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:32:19 +0300 Subject: [PATCH] feat: save project as (support for firefox and safari) --- packages/tldraw/src/state/data/filesystem.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/tldraw/src/state/data/filesystem.ts b/packages/tldraw/src/state/data/filesystem.ts index e36c14eee..1a14e83b4 100644 --- a/packages/tldraw/src/state/data/filesystem.ts +++ b/packages/tldraw/src/state/data/filesystem.ts @@ -1,4 +1,4 @@ -import { fileOpen, fileSave } from 'browser-fs-access' +import { fileOpen, fileSave, supported } from 'browser-fs-access' import type { FileSystemHandle } from 'browser-fs-access' import { get as getFromIdb, set as setToIdb } from 'idb-keyval' import { IMAGE_EXTENSIONS, VIDEO_EXTENSIONS } from '~constants' @@ -48,12 +48,15 @@ export async function saveToFileSystem( const hasPermissions = await checkPermissions(fileHandle) if (!hasPermissions) return null } - + let filename = '' + if (!supported) { + filename = prompt('Enter the desired file name!') ?? `${file.name}` + } // Save to file system const newFileHandle = await fileSave( blob, { - fileName: `${file.name}.tldr`, + fileName: `${filename}.tldr`, description: 'Tldraw File', extensions: [`.tldr`], },