Store background color in backend (#475)
* Store background color in backend * Background
This commit is contained in:
parent
4487e9af8a
commit
a210f442f4
@ -175,13 +175,14 @@ export async function loadFromJSON() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function exportToBackend(elements: readonly ExcalidrawElement[]) {
|
export async function exportToBackend(
|
||||||
|
elements: readonly ExcalidrawElement[],
|
||||||
|
appState: AppState
|
||||||
|
) {
|
||||||
const response = await fetch(BACKEND_POST, {
|
const response = await fetch(BACKEND_POST, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: { "Content-Type": "application/json" },
|
||||||
"Content-Type": "application/json"
|
body: serializeAsJSON(elements, appState)
|
||||||
},
|
|
||||||
body: serializeAsJSON(elements)
|
|
||||||
});
|
});
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
if (json.id) {
|
if (json.id) {
|
||||||
@ -189,7 +190,7 @@ export async function exportToBackend(elements: readonly ExcalidrawElement[]) {
|
|||||||
url.searchParams.append("json", json.id);
|
url.searchParams.append("json", json.id);
|
||||||
|
|
||||||
await navigator.clipboard.writeText(url.toString());
|
await navigator.clipboard.writeText(url.toString());
|
||||||
window.alert(`Copied shareable link ${url.toString()} to clipboard`);
|
window.alert(`Copied to clipboard: ${url.toString()}`);
|
||||||
} else {
|
} else {
|
||||||
window.alert("Couldn't create shareable link");
|
window.alert("Couldn't create shareable link");
|
||||||
}
|
}
|
||||||
@ -269,7 +270,11 @@ export async function exportCanvas(
|
|||||||
window.alert("Couldn't copy to clipboard. Try using Chrome browser.");
|
window.alert("Couldn't copy to clipboard. Try using Chrome browser.");
|
||||||
}
|
}
|
||||||
} else if (type === "backend") {
|
} else if (type === "backend") {
|
||||||
exportToBackend(elements);
|
const appState = getDefaultAppState();
|
||||||
|
if (exportBackground) {
|
||||||
|
appState.viewBackgroundColor = viewBackgroundColor;
|
||||||
|
}
|
||||||
|
exportToBackend(elements, appState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up the DOM
|
// clean up the DOM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user