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>
This commit is contained in:
Lipis 2020-02-29 18:42:26 +01:00 committed by GitHub
parent 5fff1f2d3e
commit 0ee33fe341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -2191,7 +2191,10 @@ export class App extends React.Component<any, AppState> {
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 }),

View File

@ -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);