fix: move getMonacoEditor to separate file to fix react-refresh lint error

react-refresh/only-export-components disallows mixing component and
non-component exports. Moved the editor ref to monacoEditorRef.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-02-10 09:57:44 -05:00
parent 5c9b9c4074
commit 6863f8e6e5
3 changed files with 12 additions and 7 deletions

View File

@@ -8,10 +8,7 @@ import { resolutionFlowTheme, THEME_ID } from './resolutionFlowTheme'
import { createCompletionProvider } from './resolutionFlowCompletions'
import { CodeModeToolbar } from './CodeModeToolbar'
import { SyntaxHelpPanel } from './SyntaxHelpPanel'
// Module-level ref so TreeEditorPage can trigger Monaco undo/redo from toolbar buttons
let _monacoEditor: MonacoEditor.IStandaloneCodeEditor | null = null
export function getMonacoEditor() { return _monacoEditor }
import { setMonacoEditor } from './monacoEditorRef'
export function CodeModeEditor() {
const editorRef = useRef<MonacoEditor.IStandaloneCodeEditor | null>(null)
@@ -58,7 +55,7 @@ export function CodeModeEditor() {
// Editor mounted
const handleEditorDidMount: OnMount = useCallback((editor) => {
editorRef.current = editor
_monacoEditor = editor
setMonacoEditor(editor)
editor.focus()
}, [])
@@ -139,7 +136,7 @@ export function CodeModeEditor() {
// Cleanup on unmount
useEffect(() => {
return () => {
_monacoEditor = null
setMonacoEditor(null)
if (validationTimeoutRef.current) {
clearTimeout(validationTimeoutRef.current)
}

View File

@@ -1,3 +1,4 @@
export { CodeModeEditor, getMonacoEditor } from './CodeModeEditor'
export { CodeModeEditor } from './CodeModeEditor'
export { CodeModeToolbar } from './CodeModeToolbar'
export { SyntaxHelpPanel } from './SyntaxHelpPanel'
export { getMonacoEditor } from './monacoEditorRef'

View File

@@ -0,0 +1,7 @@
import type { editor as MonacoEditor } from 'monaco-editor'
// Module-level ref so TreeEditorPage can trigger Monaco undo/redo from toolbar buttons
let _monacoEditor: MonacoEditor.IStandaloneCodeEditor | null = null
export function getMonacoEditor() { return _monacoEditor }
export function setMonacoEditor(editor: MonacoEditor.IStandaloneCodeEditor | null) { _monacoEditor = editor }