@@ -8,9 +8,10 @@ import './CodeEditor.css';
88 * - file?: { name, language, content }
99 * - readOnly?: boolean
1010 * - onChange?: (next: string) => void
11- * - currentUser?: { name: string, role: 'host'|'edit'|'view', code?: string } // ✅ 뱃지 표시용
11+ * - currentUser?: { name: string, role: 'host'|'edit'|'view', code?: string }
12+ * - selectFileAction?: React.ReactNode // ✅ 파일 선택 버튼을 받기 위한 prop
1213 */
13- export default function CodeEditor ( { file, readOnly = false , onChange, currentUser, isDark } ) {
14+ export default function CodeEditor ( { file, readOnly = false , onChange, currentUser, isDark, selectFileAction } ) {
1415 const initialValue = useMemo ( ( ) => file ?. content ?? '' , [ file ?. content ] ) ;
1516 const [ code , setCode ] = useState ( initialValue ) ;
1617
@@ -28,33 +29,35 @@ export default function CodeEditor({ file, readOnly = false, onChange, currentUs
2829 return '' ;
2930 } ;
3031
31- const theme = isDark ? 'vs-dark' : 'vs-light' ; // ✅ props 우선
32+ const theme = isDark ? 'vs-dark' : 'vs-light' ;
3233
3334 return (
3435 < section className = "code-editor" >
3536 < div className = "editor-header" >
36- { /* ✅ 사용자 뱃지 복원, 권한 뱃지 제거 */ }
37+ { /* 사용자 뱃지 */ }
3738 { currentUser ?. name && (
3839 < div className = "current-user-badge" >
3940 { roleIcon ( currentUser . role ) } { currentUser . name }
4041 </ div >
4142 ) }
4243
43- { /*<button className="run-button" onClick={handleRun}>
44- <FaPlay /> 실행
45- </button>*/ }
46- { /* ✅ 오른쪽 툴바: 실행 + 시각화 */ }
44+ { /* ✅ 오른쪽 툴바: 파일 선택 + 실행 + 시각화 */ }
4745 < div className = "toolbar-right" >
46+ { /* 1. 파일 선택 버튼 (CodecastLive.js에서 전달됨) */ }
47+ { selectFileAction }
48+
49+ { /* 2. 실행 버튼 */ }
4850 < button className = "run-button" onClick = { handleRun } >
4951 < FaPlay /> 실행
5052 </ button >
53+
54+ { /* 3. 시각화 버튼 */ }
5155 < button className = "viz-button" onClick = { handleVisualize } >
5256 < FaChartBar /> 시각화
5357 </ button >
5458 </ div >
5559 </ div >
5660
57- { /* 필요 시 height=100%로 바꿔도 됩니다 (부모 컨테이너가 flex:1이면) */ }
5861 < Editor
5962 height = "90%"
6063 language = { language }
@@ -76,4 +79,4 @@ export default function CodeEditor({ file, readOnly = false, onChange, currentUs
7679 />
7780 </ section >
7881 ) ;
79- }
82+ }
0 commit comments