|
1 | 1 | import { useExportCapability } from "@embedpdf/plugin-export/react" |
| 2 | +import { useHistoryCapability } from "@embedpdf/plugin-history/react" |
2 | 3 | import { useZoom } from "@embedpdf/plugin-zoom/react" |
3 | | -import { Download, Highlighter, Trash2, Underline, ZoomIn, ZoomOut } from "lucide-react" |
| 4 | +import { Download, Highlighter, Redo, Trash2, Underline, Undo, ZoomIn, ZoomOut } from "lucide-react" |
4 | 5 | import { useEffect, useState } from "react" |
5 | 6 | import { useAnnotationCapability } from "./plugin-annotation-2" |
6 | 7 |
|
7 | 8 | export const Toolbar = () => { |
8 | 9 | const { provides: annotationApi } = useAnnotationCapability() |
9 | 10 | const { provides: exportApi } = useExportCapability() |
10 | 11 | const { provides: zoom } = useZoom() |
| 12 | + const { provides: history } = useHistoryCapability() |
11 | 13 | const [activeTool, setActiveTool] = useState<string | null>(null) |
12 | 14 | const [canDelete, setCanDelete] = useState(false) |
13 | 15 |
|
@@ -53,6 +55,21 @@ export const Toolbar = () => { |
53 | 55 | </button> |
54 | 56 | ))} |
55 | 57 | <div className="h-6 w-px bg-gray-200"></div> |
| 58 | + <button |
| 59 | + onClick={() => history?.undo} |
| 60 | + disabled={!history} |
| 61 | + className="rounded-md bg-purple-500 px-3 py-1 text-sm font-medium text-white transition-colors hover:bg-purple-600 disabled:cursor-not-allowed disabled:bg-purple-300" |
| 62 | + > |
| 63 | + <Undo size={18} /> |
| 64 | + </button> |
| 65 | + <button |
| 66 | + onClick={() => history?.redo()} |
| 67 | + disabled={!history} |
| 68 | + className="rounded-md bg-purple-500 px-3 py-1 text-sm font-medium text-white transition-colors hover:bg-purple-600 disabled:cursor-not-allowed disabled:bg-purple-300" |
| 69 | + > |
| 70 | + <Redo size={18} /> |
| 71 | + </button> |
| 72 | + <div className="h-6 w-px bg-gray-200"></div> |
56 | 73 | <button |
57 | 74 | onClick={() => zoom?.zoomOut()} |
58 | 75 | disabled={!zoom} |
|
0 commit comments