import React from 'react'; import type { WorkspaceSummary } from '../workspace/workspaceTypes'; import type { WorkspaceCommandRecord } from '../workspace/workspaceCommands'; interface WorkspacePanelProps { hasPdf: boolean; isBusy: boolean; activeWorkspaceId: string | null; workspaceName: string; workspaceDirty: boolean; workspaceMessage: string | null; workspaces: WorkspaceSummary[]; history: WorkspaceCommandRecord[]; redoHistory: WorkspaceCommandRecord[]; onWorkspaceNameChange: (value: string) => void; onSaveWorkspace: () => void; onLoadWorkspace: (workspaceId: string) => void; onDeleteWorkspace: (workspaceId: string) => void; onRefreshWorkspaces: () => void; onResetWorkspace: () => void; onUndo: () => void; onRedo: () => void; } const WorkspacePanel: React.FC = ({ hasPdf, isBusy, activeWorkspaceId, workspaceName, workspaceDirty, workspaceMessage, workspaces, history, redoHistory, onWorkspaceNameChange, onSaveWorkspace, onLoadWorkspace, onDeleteWorkspace, onRefreshWorkspaces, onResetWorkspace, onUndo, onRedo, }) => { const canUndo = history.length > 0; const canRedo = redoHistory.length > 0; const latestUndo = history[history.length - 1]; const latestRedo = redoHistory[redoHistory.length - 1]; return (

Workspace

Save named workspaces in this browser. PDF binaries are stored in IndexedDB; nothing is uploaded.

onWorkspaceNameChange(e.target.value)} placeholder="Workspace name" disabled={!hasPdf || isBusy} style={{ flex: '1 1 220px', minWidth: 0, padding: '0.45rem 0.55rem', borderRadius: '0.5rem', border: '1px solid #d1d5db', fontSize: '0.9rem', }} />
{workspaceDirty && hasPdf && (
Unsaved workspace changes.
)} {workspaceMessage && (
{workspaceMessage}
)} {workspaces.length > 0 && (
Saved workspaces
{workspaces.map((workspace) => { const active = workspace.id === activeWorkspaceId; return (
{workspace.name} {active && ( · active )}
{workspace.pdfName} · source pages:{' '} {workspace.sourcePageCount} · workspace pages:{' '} {workspace.workspacePageCount} · undo:{' '} {workspace.historyCount} · redo: {workspace.redoCount} · updated {new Date(workspace.updatedAt).toLocaleString()}
); })}
)} {(history.length > 0 || redoHistory.length > 0) && (
Command history ({history.length} undo / {redoHistory.length} redo)
{history.map((entry, index) => (
Undo {history.length - index}. {entry.label}
{new Date(entry.timestamp).toLocaleString()}
))}
{redoHistory .slice() .reverse() .map((entry, index) => (
Redo {index + 1}. {entry.label}
{new Date(entry.timestamp).toLocaleString()}
))}
)}
); }; export default WorkspacePanel;