Set Trailing Cmma to (#525)
This commit is contained in:
@ -27,19 +27,19 @@ interface DataState {
|
||||
|
||||
export function serializeAsJSON(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState?: AppState
|
||||
appState?: AppState,
|
||||
): string {
|
||||
return JSON.stringify({
|
||||
version: 1,
|
||||
source: window.location.origin,
|
||||
elements: elements.map(({ shape, ...el }) => el),
|
||||
appState: appState || getDefaultAppState()
|
||||
appState: appState || getDefaultAppState(),
|
||||
});
|
||||
}
|
||||
|
||||
export async function saveAsJSON(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState
|
||||
appState: AppState,
|
||||
) {
|
||||
const serialized = serializeAsJSON(elements, appState);
|
||||
|
||||
@ -48,9 +48,9 @@ export async function saveAsJSON(
|
||||
new Blob([serialized], { type: "application/json" }),
|
||||
{
|
||||
fileName: name,
|
||||
description: "Excalidraw file"
|
||||
description: "Excalidraw file",
|
||||
},
|
||||
(window as any).handle
|
||||
(window as any).handle,
|
||||
);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ export async function loadFromJSON() {
|
||||
const blob = await fileOpen({
|
||||
description: "Excalidraw files",
|
||||
extensions: ["json"],
|
||||
mimeTypes: ["application/json"]
|
||||
mimeTypes: ["application/json"],
|
||||
});
|
||||
if (blob.handle) {
|
||||
(window as any).handle = blob.handle;
|
||||
@ -101,12 +101,12 @@ export async function loadFromJSON() {
|
||||
|
||||
export async function exportToBackend(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState
|
||||
appState: AppState,
|
||||
) {
|
||||
const response = await fetch(BACKEND_POST, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: serializeAsJSON(elements, appState)
|
||||
body: serializeAsJSON(elements, appState),
|
||||
});
|
||||
const json = await response.json();
|
||||
if (json.id) {
|
||||
@ -117,8 +117,8 @@ export async function exportToBackend(
|
||||
window.alert(
|
||||
i18n.t("alerts.copiedToClipboard", {
|
||||
url: url.toString(),
|
||||
interpolation: { escapeValue: false }
|
||||
})
|
||||
interpolation: { escapeValue: false },
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
window.alert(i18n.t("alerts.couldNotCreateShareableLink"));
|
||||
@ -129,7 +129,7 @@ export async function importFromBackend(id: string | null) {
|
||||
let elements: readonly ExcalidrawElement[] = [];
|
||||
let appState: AppState = getDefaultAppState();
|
||||
const response = await fetch(`${BACKEND_GET}${id}.json`).then(data =>
|
||||
data.clone().json()
|
||||
data.clone().json(),
|
||||
);
|
||||
if (response != null) {
|
||||
try {
|
||||
@ -152,14 +152,14 @@ export async function exportCanvas(
|
||||
exportPadding = 10,
|
||||
viewBackgroundColor,
|
||||
name,
|
||||
scale = 1
|
||||
scale = 1,
|
||||
}: {
|
||||
exportBackground: boolean;
|
||||
exportPadding?: number;
|
||||
viewBackgroundColor: string;
|
||||
name: string;
|
||||
scale?: number;
|
||||
}
|
||||
},
|
||||
) {
|
||||
if (!elements.length)
|
||||
return window.alert(i18n.t("alerts.cannotExportEmptyCanvas"));
|
||||
@ -169,7 +169,7 @@ export async function exportCanvas(
|
||||
exportBackground,
|
||||
viewBackgroundColor,
|
||||
exportPadding,
|
||||
scale
|
||||
scale,
|
||||
});
|
||||
tempCanvas.style.display = "none";
|
||||
document.body.appendChild(tempCanvas);
|
||||
@ -180,7 +180,7 @@ export async function exportCanvas(
|
||||
if (blob) {
|
||||
await fileSave(blob, {
|
||||
fileName: fileName,
|
||||
description: "Excalidraw image"
|
||||
description: "Excalidraw image",
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -190,7 +190,7 @@ export async function exportCanvas(
|
||||
tempCanvas.toBlob(async function(blob: any) {
|
||||
try {
|
||||
await navigator.clipboard.write([
|
||||
new window.ClipboardItem({ "image/png": blob })
|
||||
new window.ClipboardItem({ "image/png": blob }),
|
||||
]);
|
||||
} catch (err) {
|
||||
window.alert(errorMsg);
|
||||
@ -213,7 +213,7 @@ export async function exportCanvas(
|
||||
|
||||
function restore(
|
||||
savedElements: readonly ExcalidrawElement[],
|
||||
savedState: AppState
|
||||
savedState: AppState,
|
||||
): DataState {
|
||||
return {
|
||||
elements: savedElements.map(element => ({
|
||||
@ -225,9 +225,9 @@ function restore(
|
||||
opacity:
|
||||
element.opacity === null || element.opacity === undefined
|
||||
? 100
|
||||
: element.opacity
|
||||
: element.opacity,
|
||||
})),
|
||||
appState: savedState
|
||||
appState: savedState,
|
||||
};
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ export function restoreFromLocalStorage() {
|
||||
if (savedElements) {
|
||||
try {
|
||||
elements = JSON.parse(savedElements).map(
|
||||
({ shape, ...element }: ExcalidrawElement) => element
|
||||
({ shape, ...element }: ExcalidrawElement) => element,
|
||||
);
|
||||
} catch (e) {
|
||||
// Do nothing because elements array is already empty
|
||||
@ -260,7 +260,7 @@ export function restoreFromLocalStorage() {
|
||||
|
||||
export function saveToLocalStorage(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
state: AppState
|
||||
state: AppState,
|
||||
) {
|
||||
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(elements));
|
||||
localStorage.setItem(LOCAL_STORAGE_KEY_STATE, JSON.stringify(state));
|
||||
|
Reference in New Issue
Block a user