@@ -102,7 +102,7 @@ const StyledEditorDiv = styled(Box)(({ theme }) => ({
102102 } ,
103103} ) ) ;
104104
105- const ResizableDiv = ( { columnIndex, children, ...otherProps } ) => {
105+ const ResizableDiv = ( { columnIndex, children, resizeKey , defaultSize , ...otherProps } ) => {
106106
107107 const editorRef = React . useRef ( null ) ;
108108 const { getCellElement} = useContext ( RowInfoContext ) ;
@@ -124,11 +124,20 @@ const ResizableDiv = ({columnIndex, children, ...otherProps}) => {
124124 if ( box . right > innerWidth ) {
125125 editorRef . current . firstChild . style . width = `${ currentWidth - widthDiff - 20 } px` ;
126126 }
127+ // logic to save the height and width of the editor
128+ if ( currentHeight || currentWidth ) {
129+ window . resizeKeys = window . resizeKeys || { } ;
130+ window . resizeKeys [ resizeKey ] = { height : editorRef . current . firstChild . style . height , width : editorRef . current . firstChild . style . width } ;
131+ }
132+
127133 } ;
128134
129135 editorRef . current . addEventListener ( 'mousedown' , ( ) => {
130136 document . addEventListener ( 'mouseup' , resizeEditor , { once : true } ) ;
131137 } ) ;
138+ // Fetch the saved height and width from window object
139+ editorRef . current . firstChild . style . height = window . resizeKeys ?. [ resizeKey ] ?. height || defaultSize . height ;
140+ editorRef . current . firstChild . style . width = window . resizeKeys ?. [ resizeKey ] ?. width || defaultSize . width ;
132141
133142 return ( ) => document . removeEventListener ( 'mouseup' , resizeEditor ) ;
134143
@@ -146,7 +155,9 @@ const ResizableDiv = ({columnIndex, children, ...otherProps}) => {
146155ResizableDiv . displayName = 'ResizableDiv' ;
147156ResizableDiv . propTypes = {
148157 children : CustomPropTypes . children ,
149- columnIndex : PropTypes . number
158+ columnIndex : PropTypes . number ,
159+ resizeKey : PropTypes . string ,
160+ defaultSize : PropTypes . object ,
150161} ;
151162
152163function autoFocusAndSelect ( input ) {
@@ -249,7 +260,7 @@ export function TextEditor({row, column, onRowChange, onClose}) {
249260 return (
250261 < Portal container = { document . body } >
251262 < ResizableDiv columnIndex = { column . idx }
252- className = 'Editors-textEditor' data-label = "pg-editor" onKeyDown = { suppressEnterKey } >
263+ className = 'Editors-textEditor' data-label = "pg-editor" resizeKey = { 'text' } defaultSize = { { height : '80px' , width : '250px' } } onKeyDown = { suppressEnterKey } >
253264 < textarea ref = { autoFocusAndSelect } className = 'Editors-textarea' value = { localVal } onChange = { onChange } onKeyDown = { onkeydown } />
254265 < Box display = "flex" justifyContent = "flex-end" >
255266 < DefaultButton startIcon = { < CloseIcon /> } onClick = { ( ) => onClose ( false ) } size = "small" >
@@ -436,7 +447,7 @@ export function JsonTextEditor({row, column, onRowChange, onClose}) {
436447 return (
437448 < Portal container = { document . body } >
438449 < ResizableDiv columnIndex = { column . idx }
439- className = 'Editors-jsonEditor' data-label = "pg-editor" onKeyDown = { suppressEnterKey } >
450+ className = 'Editors-jsonEditor' data-label = "pg-editor" resizeKey = { 'json' } defaultSize = { { height : '500px' , width : '600px' } } onKeyDown = { suppressEnterKey } >
440451 < JsonEditor
441452 setJsonEditorSize = { setJsonEditorSize }
442453 value = { localVal }
0 commit comments