Skip to content

Commit 697843a

Browse files
committed
refactor(CodeEditor): update module references for undo/redo functionality
- Changed references from `modules` to `coreModules` in the `handleUndo` and `handleRedo` functions to align with the updated module loading structure. - Improved code clarity and maintainability by ensuring consistent usage of the core modules for command handling.
1 parent 84dfbab commit 697843a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/code-editor/src/CodeEditor/CodeEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,30 +166,30 @@ export const CodeEditor = forwardRef<CodeEditorHandle, CodeEditorProps>(
166166
* @returns boolean indicating if undo was successful
167167
*/
168168
const handleUndo = useCallback((): boolean => {
169-
const commands = modules?.['@codemirror/commands'];
169+
const commands = coreModules?.['@codemirror/commands'];
170170

171171
if (!editorViewRef.current || !commands) {
172172
console.warn('Undo is not available - editor or commands not loaded');
173173
return false;
174174
}
175175

176176
return commands.undo(editorViewRef.current);
177-
}, [modules]);
177+
}, [coreModules]);
178178

179179
/**
180180
* Redoes the last undone editor action if possible.
181181
* @returns boolean indicating if redo was successful
182182
*/
183183
const handleRedo = useCallback((): boolean => {
184-
const commands = modules?.['@codemirror/commands'];
184+
const commands = coreModules?.['@codemirror/commands'];
185185

186186
if (!editorViewRef.current || !commands) {
187187
console.warn('Redo is not available - editor or commands not loaded');
188188
return false;
189189
}
190190

191191
return commands.redo(editorViewRef.current);
192-
}, [modules]);
192+
}, [coreModules]);
193193

194194
useLayoutEffect(() => {
195195
const EditorView = coreModules?.['@codemirror/view'];

0 commit comments

Comments
 (0)