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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 }
|
||||
Reference in New Issue
Block a user