From 817bd741a82dd4fdd044316c7342b3a01c1799a4 Mon Sep 17 00:00:00 2001 From: ruinivist Date: Sun, 24 May 2026 22:57:44 +0200 Subject: [PATCH] refactor: remove sidebar exports --- src/App.tsx | 83 +------------------------------------------------- src/styles.css | 8 ----- 2 files changed, 1 insertion(+), 90 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 6e0bd0e..a9e6c82 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,9 +1,5 @@ import "../node_modules/@excalidraw/excalidraw/dist/prod/index.css"; -import { - Excalidraw, - exportToBlob, - serializeAsJSON, -} from "@excalidraw/excalidraw"; +import { Excalidraw } from "@excalidraw/excalidraw"; import type { AppState, BinaryFiles, @@ -65,32 +61,6 @@ function sceneFromEditor( }; } -function downloadBlob(blob: Blob, filename: string) { - const url = URL.createObjectURL(blob); - const link = document.createElement("a"); - link.href = url; - link.download = filename; - link.click(); - URL.revokeObjectURL(url); -} - -function filenameBase(title: string): string { - const safeTitle = title - .trim() - .toLowerCase() - .replace(/[^a-z0-9]+/g, "-") - .replace(/^-+|-+$/g, ""); - - const now = new Date(); - const stamp = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String( - now.getDate(), - ).padStart(2, "0")}-${String(now.getHours()).padStart(2, "0")}${String( - now.getMinutes(), - ).padStart(2, "0")}`; - - return `${safeTitle || "drawing"}-${stamp}`; -} - async function requestJson(url: string, init?: RequestInit): Promise { const response = await fetch(url, { ...init, @@ -332,49 +302,6 @@ export function App() { } }, []); - const exportPng = useCallback(async () => { - const latest = latestSceneRef.current; - if (!latest) { - return; - } - - const blob = await exportToBlob({ - elements: latest.elements as never[], - appState: { - ...(latest.appState as unknown as AppState), - exportBackground: true, - }, - files: latest.files as BinaryFiles, - mimeType: "image/png", - getDimensions: (width: number, height: number) => ({ - width, - height, - scale: 2, - }), - }); - - downloadBlob(blob, `${filenameBase(currentTitleRef.current)}.png`); - }, []); - - const exportExcalidraw = useCallback(() => { - const latest = latestSceneRef.current; - if (!latest) { - return; - } - - const json = serializeAsJSON( - latest.elements as never[], - latest.appState as Partial, - latest.files as BinaryFiles, - "local", - ); - - downloadBlob( - new Blob([json], { type: "application/json" }), - `${filenameBase(currentTitleRef.current)}.excalidraw`, - ); - }, []); - const syncThemeTokens = useCallback(() => { const appShell = appShellRef.current; const excalidrawRoot = appShell?.querySelector(".excalidraw"); @@ -536,14 +463,6 @@ export function App() { -
- - -
{drawings.map((drawing) => (