From 0ee33fe341c011a5ae073863d1ca85ea4cabb637 Mon Sep 17 00:00:00 2001 From: Lipis Date: Sat, 29 Feb 2020 18:42:26 +0100 Subject: [PATCH] Change the extension to .excalidraw (#858) * Change the extension to .excalidra * Support opening as well * support .excalidraw extension on canvas DranAndDrop Co-authored-by: Faustino Kialungila --- src/index.tsx | 5 ++++- src/scene/data.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index bb267644..2b0337be 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2191,7 +2191,10 @@ export class App extends React.Component { onPointerLeave={this.removePointer} onDrop={event => { const file = event.dataTransfer.files[0]; - if (file?.type === "application/json") { + if ( + file?.type === "application/json" || + file?.name.endsWith(".excalidraw") + ) { loadFromBlob(file) .then(({ elements, appState }) => this.syncActionResult({ elements, appState }), diff --git a/src/scene/data.ts b/src/scene/data.ts index 1381304d..7405996d 100644 --- a/src/scene/data.ts +++ b/src/scene/data.ts @@ -83,7 +83,7 @@ export async function saveAsJSON( ) { const serialized = serializeAsJSON(elements, appState); - const name = `${appState.name}.json`; + const name = `${appState.name}.excalidraw`; await fileSave( new Blob([serialized], { type: "application/json" }), { @@ -96,7 +96,7 @@ export async function saveAsJSON( export async function loadFromJSON() { const blob = await fileOpen({ description: "Excalidraw files", - extensions: ["json"], + extensions: ["json", "excalidraw"], mimeTypes: ["application/json"], }); return loadFromBlob(blob);