| 40 | }); |
| 41 | |
| 42 | interface HistoryStore { |
| 43 | current: CanvasState; |
| 44 | |
| 45 | past: CanvasState[]; |
| 46 | future: CanvasState[]; |
| 47 | |
| 48 | maxHistorySize: number; |
| 49 | |
| 50 | setFreeDrawingLines: (lines: FreeDrawingLineWithProps[]) => void; |
| 51 | addFreeDrawingLine: (line: FreeDrawingLineWithProps) => void; |
| 52 | updateLastFreeDrawingLine: ( |
| 53 | updater: (line: FreeDrawingLineWithProps) => FreeDrawingLineWithProps |
| 54 | ) => void; |
| 55 | |
| 56 | setLines: (lines: LineShapeWithProps[]) => void; |
| 57 | addLine: (line: LineShapeWithProps) => void; |
| 58 | updateLine: (id: string, updates: Partial<LineShapeWithProps>) => void; |
| 59 | |
| 60 | setRectangles: (rectangles: RectangleShapeWithProps[]) => void; |
| 61 | addRectangle: (rectangle: RectangleShapeWithProps) => void; |
| 62 | updateRectangle: ( |
| 63 | id: string, |
| 64 | updates: Partial<RectangleShapeWithProps> |
| 65 | ) => void; |
| 66 | |
| 67 | setEllipses: (ellipses: EllipseShapeWithProps[]) => void; |
| 68 | addEllipse: (ellipse: EllipseShapeWithProps) => void; |
| 69 | updateEllipse: (id: string, updates: Partial<EllipseShapeWithProps>) => void; |
| 70 | |
| 71 | setArrows: (arrows: ArrowShapeWithProps[]) => void; |
| 72 | addArrow: (arrow: ArrowShapeWithProps) => void; |
| 73 | updateArrow: (id: string, updates: Partial<ArrowShapeWithProps>) => void; |
| 74 | |
| 75 | saveToHistory: () => void; |
| 76 | undo: () => void; |
| 77 | redo: () => void; |
| 78 | canUndo: () => boolean; |
| 79 | canRedo: () => boolean; |
| 80 | } |
| 81 | |
| 82 | const useHistoryStore = create<HistoryStore>((set, get) => ({ |
| 83 | current: createEmptyState(), |
nothing calls this directly
no outgoing calls
no test coverage detected