You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ef19aeb
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,42 @@ Please follow these steps to have your contribution considered by the maintainer
64
64
- Ensure your code passes ESLint.
65
65
- Make sure the code base is in English, this includes comments and variable names.
66
66
67
+
## Undo/Redo: pushUndo vs setUndoStack
68
+
69
+
When recording history, prefer the high-level helper `pushUndo(action)` from UI/components for simple append-and-clear behavior. `pushUndo` centralizes validation, deduplication and coalescing so the app maintains a sane undo/redo history.
70
+
71
+
However, some modules implement the low-level undo/redo engine and must manipulate the stacks directly using `setUndoStack` / `setRedoStack`. Do NOT replace those internal usages with `pushUndo`.
72
+
73
+
Files that intentionally use direct stack manipulation include (but are not limited to):
74
+
75
+
-`src/components/EditorCanvas/Canvas.jsx`
76
+
-`src/components/EditorHeader/ControlPanel.jsx`
77
+
-`src/components/EditorHeader/Modal/Modal.jsx`
78
+
-`src/components/Workspace.jsx`
79
+
-`src/context/UndoRedoContext.jsx`
80
+
81
+
Correct usage (UI-side append+clear):
82
+
```js
83
+
// Add a simple EDIT action and clear redo
84
+
pushUndo({
85
+
action:Action.EDIT,
86
+
element:ObjectType.TABLE,
87
+
tid,
88
+
undo,
89
+
redo,
90
+
message,
91
+
});
92
+
```
93
+
94
+
Incorrect to change internal code to this (keep low-level code as-is):
95
+
```js
96
+
// Internal undo engine — keep setUndoStack for low-level manipulation
97
+
setUndoStack((prev) =>prev.filter((_, i) => i !==prev.length-1));
98
+
setRedoStack((prev) => [...prev, action]);
99
+
```
100
+
101
+
If you're unsure which to use, prefer `pushUndo` for component-level changes and ask during code review for anything touching the stacks directly.
102
+
67
103
## Additional Notes
68
104
69
105
### Issue and Pull Request Labels
@@ -87,3 +123,4 @@ If you have any questions, please feel free to reach out to us through the follo
0 commit comments