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:
parent
5fff1f2d3e
commit
0ee33fe341
@ -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 }),
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user