Trash ID Update Collections

This commit is contained in:
Zimeng Xiong
2025-11-21 19:31:59 -08:00
parent 4e8beae0ee
commit 0878b5e87f
16 changed files with 169 additions and 101 deletions
+15 -1
View File
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useState, useRef } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { ArrowLeft } from 'lucide-react';
import { Excalidraw, convertToExcalidrawElements } from '@excalidraw/excalidraw';
import { Excalidraw, convertToExcalidrawElements, exportToSvg } from '@excalidraw/excalidraw';
import '@excalidraw/excalidraw/index.css';
import debounce from 'lodash/debounce';
import { Toaster, toast } from 'sonner';
@@ -37,10 +37,24 @@ export const Editor: React.FC = () => {
viewBackgroundColor: appState.viewBackgroundColor,
gridSize: appState.gridSize,
};
// Generate preview
const files = excalidrawAPI.current?.getFiles() || null;
const svg = await exportToSvg({
elements,
appState: {
...appState,
exportBackground: true,
viewBackgroundColor: appState.viewBackgroundColor || '#ffffff',
},
files,
});
const preview = svg.outerHTML;
await api.updateDrawing(id, {
elements,
appState: persistableAppState,
preview,
});
} catch (err) {
console.error('Failed to save drawing', err);