diff --git a/src/components/control_panel.jsx b/src/components/control_panel.jsx index c99f011..7e94965 100644 --- a/src/components/control_panel.jsx +++ b/src/components/control_panel.jsx @@ -417,7 +417,7 @@ export default function ControlPanel(props) { setNotes(data.notes); }; - const addTable = () =>{ + const addTable = () => { setTables((prev) => [ ...prev, { @@ -443,33 +443,33 @@ export default function ControlPanel(props) { color: defaultTableTheme, }, ]); - setUndoStack((prev)=>[...prev, { - action: "add", - element: "table", - }]) - } + }; - const undo = () =>{ - if(undoStack.length===0) return; + const undo = () => { + if (undoStack.length === 0) return; const a = undoStack.pop(); - if(a.action==="add"){ - if(a.element==="table"){ - setTables(prev=>prev.filter(e=>e.id!==prev.length-1).map((e, i)=>({...e, id: i}))) + if (a.action === "add") { + if (a.element === "table") { + setTables((prev) => + prev + .filter((e) => e.id !== prev.length - 1) + .map((e, i) => ({ ...e, id: i })) + ); } } - setRedoStack(prev=>[...prev, a]) - } + setRedoStack((prev) => [...prev, a]); + }; - const redo = () =>{ - if(redoStack.length===0) return; + const redo = () => { + if (redoStack.length === 0) return; const a = redoStack.pop(); - if(a.action==="add"){ - if(a.element==="table"){ + if (a.action === "add") { + if (a.element === "table") { addTable(); } } - setUndoStack(prev=>[...prev, a]) - } + setUndoStack((prev) => [...prev, a]); + }; return (