@@ -139,6 +139,8 @@ export const Editor: React.FC<EditorProps> = ({ query, onChange, startDate, endD
139139 const tableNameRef = useRef < string > ( tableName || '' ) ;
140140 const [ editorHeight , setEditorHeight ] = useState ( "250px" ) ;
141141 const lastMousePosition = useRef ( { x : 0 , y : 0 } ) ;
142+ const containerRef = useRef < HTMLDivElement > ( null ) ;
143+ const isDraggingRef = useRef ( false ) ;
142144
143145 useEffect ( ( ) => {
144146 tableDefinitionsRef . current = tableDefinitions || [ ] ;
@@ -561,8 +563,40 @@ export const Editor: React.FC<EditorProps> = ({ query, onChange, startDate, endD
561563 }
562564 } ;
563565
566+ const handleMouseDown = ( e : React . MouseEvent ) => {
567+ isDraggingRef . current = true ;
568+ document . addEventListener ( 'mousemove' , handleMouseMove ) ;
569+ document . addEventListener ( 'mouseup' , handleMouseUp ) ;
570+ } ;
571+
572+ const handleMouseMove = useCallback ( ( e : MouseEvent ) => {
573+ if ( ! isDraggingRef . current || ! containerRef . current ) return ;
574+
575+ const containerRect = containerRef . current . getBoundingClientRect ( ) ;
576+ const newHeight = Math . max ( 150 , e . clientY - containerRect . top ) ;
577+ setEditorHeight ( `${ newHeight } px` ) ;
578+
579+ // Trigger Monaco editor layout update
580+ if ( editorRef . current ) {
581+ editorRef . current . layout ( ) ;
582+ }
583+ } , [ ] ) ;
584+
585+ const handleMouseUp = useCallback ( ( ) => {
586+ isDraggingRef . current = false ;
587+ document . removeEventListener ( 'mousemove' , handleMouseMove ) ;
588+ document . removeEventListener ( 'mouseup' , handleMouseUp ) ;
589+ } , [ handleMouseMove ] ) ;
590+
591+ useEffect ( ( ) => {
592+ return ( ) => {
593+ document . removeEventListener ( 'mousemove' , handleMouseMove ) ;
594+ document . removeEventListener ( 'mouseup' , handleMouseUp ) ;
595+ } ;
596+ } , [ handleMouseMove , handleMouseUp ] ) ;
597+
564598 return (
565- < div className = "EditorContainer" >
599+ < div ref = { containerRef } className = "EditorContainer" style = { { position : 'relative' } } >
566600 < MonacoEditor
567601 height = { editorHeight }
568602 language = "pipe-sql"
@@ -583,7 +617,19 @@ export const Editor: React.FC<EditorProps> = ({ query, onChange, startDate, endD
583617 onChange = { handleChange }
584618 onMount = { handleEditorDidMount }
585619 />
586-
620+ < div
621+ className = "resize-handle"
622+ onMouseDown = { handleMouseDown }
623+ style = { {
624+ position : 'absolute' ,
625+ bottom : 0 ,
626+ right : 0 ,
627+ width : '20px' ,
628+ height : '20px' ,
629+ cursor : 'se-resize' ,
630+ background : 'transparent'
631+ } }
632+ />
587633 </ div >
588634 ) ;
589635} ;
0 commit comments