import React from "react"; import { Tooltip, ActionIcon, Paper } from "@mantine/core"; import UndoIcon from "@mui/icons-material/Undo"; import RedoIcon from "@mui/icons-material/Redo"; import ContentCutIcon from "@mui/icons-material/ContentCut"; import DownloadIcon from "@mui/icons-material/Download"; import RotateLeftIcon from "@mui/icons-material/RotateLeft"; import RotateRightIcon from "@mui/icons-material/RotateRight"; import DeleteIcon from "@mui/icons-material/Delete"; import CloseIcon from "@mui/icons-material/Close"; import InsertPageBreakIcon from "@mui/icons-material/InsertPageBreak"; interface PageEditorControlsProps { // Close/Reset functions onClosePdf: () => void; // Undo/Redo onUndo: () => void; onRedo: () => void; canUndo: boolean; canRedo: boolean; // Page operations onRotate: (direction: 'left' | 'right') => void; onDelete: () => void; onSplit: () => void; onSplitAll: () => void; onPageBreak: () => void; onPageBreakAll: () => void; // Export functions onExportSelected: () => void; onExportAll: () => void; exportLoading: boolean; // Selection state selectionMode: boolean; selectedPages: number[]; // Split state (for tooltip logic) splitPositions?: Set; totalPages?: number; } const PageEditorControls = ({ onClosePdf, onUndo, onRedo, canUndo, canRedo, onRotate, onDelete, onSplit, onSplitAll, onPageBreak, onPageBreakAll, onExportSelected, onExportAll, exportLoading, selectionMode, selectedPages, splitPositions, totalPages }: PageEditorControlsProps) => { // Calculate split all tooltip text const getSplitAllTooltip = () => { if (selectionMode) { return "Split Selected"; } if (!splitPositions || !totalPages) { return "Split All"; } // Check if all possible splits are active const allPossibleSplitsCount = totalPages - 1; const hasAllSplits = splitPositions.size === allPossibleSplitsCount && Array.from({length: allPossibleSplitsCount}, (_, i) => i).every(pos => splitPositions.has(pos)); return hasAllSplits ? "Remove All Splits" : "Split All"; }; // Calculate page break tooltip text const getPageBreakTooltip = () => { if (selectionMode) { return selectedPages.length > 0 ? `Insert ${selectedPages.length} Page Break${selectedPages.length > 1 ? 's' : ''}` : "Insert Page Breaks"; } return "Insert Page Breaks After All Pages"; }; return (
{/* Close PDF */}
{/* Undo/Redo */}
{/* Page Operations */} onRotate('left')} disabled={selectionMode && selectedPages.length === 0} variant={selectionMode && selectedPages.length > 0 ? "light" : "default"} color={selectionMode && selectedPages.length > 0 ? "blue" : undefined} size="lg" > onRotate('right')} disabled={selectionMode && selectedPages.length === 0} variant={selectionMode && selectedPages.length > 0 ? "light" : "default"} color={selectionMode && selectedPages.length > 0 ? "blue" : undefined} size="lg" > {selectionMode && ( 0 ? "light" : "default"} size="lg" > )} 0 ? "light" : "default"} color={selectionMode && selectedPages.length > 0 ? "blue" : undefined} size="lg" > 0 ? "light" : "default"} color={selectionMode && selectedPages.length > 0 ? "orange" : undefined} size="lg" >
{/* Export Controls */} {selectionMode && ( 0 ? "light" : "default"} size="lg" > )}
); }; export default PageEditorControls;