Skip to content

Commit eb13cba

Browse files
committed
feat: redo/undo btns not working
1 parent cb343b8 commit eb13cba

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

components/pdf-container/toolbar.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { useExportCapability } from "@embedpdf/plugin-export/react"
2+
import { useHistoryCapability } from "@embedpdf/plugin-history/react"
23
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"
45
import { useEffect, useState } from "react"
56
import { useAnnotationCapability } from "./plugin-annotation-2"
67

78
export const Toolbar = () => {
89
const { provides: annotationApi } = useAnnotationCapability()
910
const { provides: exportApi } = useExportCapability()
1011
const { provides: zoom } = useZoom()
12+
const { provides: history } = useHistoryCapability()
1113
const [activeTool, setActiveTool] = useState<string | null>(null)
1214
const [canDelete, setCanDelete] = useState(false)
1315

@@ -53,6 +55,21 @@ export const Toolbar = () => {
5355
</button>
5456
))}
5557
<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>
5673
<button
5774
onClick={() => zoom?.zoomOut()}
5875
disabled={!zoom}

0 commit comments

Comments
 (0)