diff --git a/components/whiteboard/index.tsx b/components/whiteboard/index.tsx
index e862493..efdd894 100644
--- a/components/whiteboard/index.tsx
+++ b/components/whiteboard/index.tsx
@@ -1,11 +1,13 @@
'use client';
-import { useRef } from 'react';
+import { useRef, useState } from 'react';
import { motion, AnimatePresence } from 'motion/react';
-import { Eraser, Minimize2, PencilLine } from 'lucide-react';
+import { Eraser, History, Minimize2, PencilLine } from 'lucide-react';
import { WhiteboardCanvas } from './whiteboard-canvas';
+import { WhiteboardHistory } from './whiteboard-history';
import { useStageStore } from '@/lib/store';
import { useCanvasStore } from '@/lib/store/canvas';
+import { useWhiteboardHistoryStore } from '@/lib/store/whiteboard-history';
import { createStageAPI } from '@/lib/api/stage-api';
import { toast } from 'sonner';
import { useI18n } from '@/lib/hooks/use-i18n';
@@ -23,6 +25,8 @@ export function Whiteboard({ isOpen, onClose }: WhiteboardProps) {
const stage = useStageStore.use.stage();
const isClearing = useCanvasStore.use.whiteboardClearing();
const clearingRef = useRef(false);
+ const [historyOpen, setHistoryOpen] = useState(false);
+ const snapshotCount = useWhiteboardHistoryStore((s) => s.snapshots.length);
// Get element count for indicator
const whiteboard = stage?.whiteboard?.[0];
@@ -34,6 +38,13 @@ export function Whiteboard({ isOpen, onClose }: WhiteboardProps) {
if (!whiteboard || elementCount === 0 || clearingRef.current) return;
clearingRef.current = true;
+ // Save snapshot before clearing
+ if (whiteboard.elements && whiteboard.elements.length > 0) {
+ useWhiteboardHistoryStore
+ .getState()
+ .pushSnapshot(whiteboard.elements, t('whiteboard.beforeClear'));
+ }
+
// Trigger cascade exit animation
useCanvasStore.getState().setWhiteboardClearing(true);
@@ -108,6 +119,20 @@ export function Whiteboard({ isOpen, onClose }: WhiteboardProps) {
+ setHistoryOpen(!historyOpen)}
+ whileTap={{ scale: 0.9 }}
+ className="relative p-2 text-gray-400 dark:text-gray-500 hover:text-purple-500 dark:hover:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/20 rounded-lg transition-colors"
+ title={t('whiteboard.history')}
+ >
+
+ {snapshotCount > 0 && (
+
+ {snapshotCount}
+
+ )}
+