Browse Source

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 <Faustino.kialungila@gmail.com>
Lipis 5 years ago
parent
commit
0ee33fe341
2 changed files with 6 additions and 3 deletions
  1. 4 1
      src/index.tsx
  2. 2 2
      src/scene/data.ts

+ 4 - 1
src/index.tsx

@@ -2191,7 +2191,10 @@ export class App extends React.Component<any, AppState> {
             onPointerLeave={this.removePointer}
             onPointerLeave={this.removePointer}
             onDrop={event => {
             onDrop={event => {
               const file = event.dataTransfer.files[0];
               const file = event.dataTransfer.files[0];
-              if (file?.type === "application/json") {
+              if (
+                file?.type === "application/json" ||
+                file?.name.endsWith(".excalidraw")
+              ) {
                 loadFromBlob(file)
                 loadFromBlob(file)
                   .then(({ elements, appState }) =>
                   .then(({ elements, appState }) =>
                     this.syncActionResult({ elements, appState }),
                     this.syncActionResult({ elements, appState }),

+ 2 - 2
src/scene/data.ts

@@ -83,7 +83,7 @@ export async function saveAsJSON(
 ) {
 ) {
   const serialized = serializeAsJSON(elements, appState);
   const serialized = serializeAsJSON(elements, appState);
 
 
-  const name = `${appState.name}.json`;
+  const name = `${appState.name}.excalidraw`;
   await fileSave(
   await fileSave(
     new Blob([serialized], { type: "application/json" }),
     new Blob([serialized], { type: "application/json" }),
     {
     {
@@ -96,7 +96,7 @@ export async function saveAsJSON(
 export async function loadFromJSON() {
 export async function loadFromJSON() {
   const blob = await fileOpen({
   const blob = await fileOpen({
     description: "Excalidraw files",
     description: "Excalidraw files",
-    extensions: ["json"],
+    extensions: ["json", "excalidraw"],
     mimeTypes: ["application/json"],
     mimeTypes: ["application/json"],
   });
   });
   return loadFromBlob(blob);
   return loadFromBlob(blob);