mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-24 21:54:56 +00:00
Deleted molecules now using JSON-ui implementations: - AppBranding, CodeExplanationDialog, ComponentBindingDialog - DataSourceCard, DataSourceEditorDialog, GitHubBuildStatus - LazyBarChart, LazyD3BarChart, LazyLineChart - NavigationGroupHeader, SaveIndicator, StorageSettings Updated src/components/molecules/index.ts to import these from @/lib/json-ui/json-components instead of TSX files. Updated src/components/CodeEditor.tsx to import CodeExplanationDialog from json-components. Organisms still depend on some molecules (CanvasRenderer, ComponentPalette, ComponentTree, PropertyEditor, etc) so those remain as TSX. Build passes successfully with no errors. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
88 lines
2.7 KiB
TypeScript
88 lines
2.7 KiB
TypeScript
import { ProjectFile } from '@/types/project'
|
|
import { useDialogState } from '@/hooks/use-dialog-state'
|
|
import { useFileFilters } from '@/hooks/use-file-filters'
|
|
import { useCodeExplanation } from '@/hooks/use-code-explanation'
|
|
import { useAIOperations } from '@/hooks/use-ai-operations'
|
|
import { EditorToolbar } from '@/components/molecules/EditorToolbar'
|
|
import { MonacoEditorPanel } from '@/components/molecules/MonacoEditorPanel'
|
|
import { EmptyEditorState } from '@/components/molecules/EmptyEditorState'
|
|
import { CodeExplanationDialog } from '@/lib/json-ui/json-components'
|
|
|
|
interface CodeEditorProps {
|
|
files: ProjectFile[]
|
|
activeFileId: string | null
|
|
onFileChange: (fileId: string, content: string) => void
|
|
onFileSelect: (fileId: string) => void
|
|
onFileClose: (fileId: string) => void
|
|
}
|
|
|
|
export function CodeEditor({
|
|
files,
|
|
activeFileId,
|
|
onFileChange,
|
|
onFileSelect,
|
|
onFileClose,
|
|
}: CodeEditorProps) {
|
|
const { isOpen: showExplainDialog, setIsOpen: setShowExplainDialog } = useDialogState()
|
|
const { explanation, isExplaining, explain } = useCodeExplanation()
|
|
const { improveCode } = useAIOperations()
|
|
const { getOpenFiles, findFileById } = useFileFilters(files)
|
|
|
|
const activeFile = findFileById(activeFileId) || undefined
|
|
const openFiles = getOpenFiles(activeFileId)
|
|
|
|
const handleImproveCode = async () => {
|
|
if (!activeFile) return
|
|
|
|
const instruction = prompt('How would you like to improve this code?')
|
|
if (!instruction) return
|
|
|
|
const improvedCode = await improveCode(activeFile.content, instruction)
|
|
if (improvedCode) {
|
|
onFileChange(activeFile.id, improvedCode)
|
|
}
|
|
}
|
|
|
|
const handleExplainCode = async () => {
|
|
if (!activeFile) return
|
|
setShowExplainDialog(true)
|
|
await explain(activeFile.content)
|
|
}
|
|
|
|
return (
|
|
<div className="h-full flex flex-col">
|
|
{openFiles.length > 0 ? (
|
|
<>
|
|
<EditorToolbar
|
|
openFiles={openFiles}
|
|
activeFileId={activeFileId}
|
|
activeFile={activeFile}
|
|
onFileSelect={onFileSelect}
|
|
onFileClose={onFileClose}
|
|
onExplain={handleExplainCode}
|
|
onImprove={handleImproveCode}
|
|
/>
|
|
<div className="flex-1">
|
|
{activeFile && (
|
|
<MonacoEditorPanel
|
|
file={activeFile}
|
|
onChange={(content) => onFileChange(activeFile.id, content)}
|
|
/>
|
|
)}
|
|
</div>
|
|
</>
|
|
) : (
|
|
<EmptyEditorState />
|
|
)}
|
|
|
|
<CodeExplanationDialog
|
|
open={showExplainDialog}
|
|
onOpenChange={setShowExplainDialog}
|
|
fileName={activeFile?.name}
|
|
explanation={explanation}
|
|
isLoading={isExplaining}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|