Skip to content

Commit c527248

Browse files
Updated docs and add logic to remember editor size.
1 parent b6e2e7d commit c527248

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

-2.24 KB
Loading

docs/en_US/preferences.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ preferences for copied data.
543543
* Specify the number of records to fetch in one batch. Changing this value will
544544
override DATA_RESULT_ROWS_PER_PAGE setting from config file.
545545
* Use the *Max column data display length* to specify the maximum number of
546-
characters to display in a cell. If the data is larger than this value, it
547-
will be truncated.
546+
characters to be visible in the data output cell. If the data is larger
547+
than this value, it will be truncated.
548548
* Use the *Result copy field separator* drop-down listbox to select the field
549549
separator for copied data.
550550
* Use the *Result copy quote character* drop-down listbox to select the quote

web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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,12 +124,20 @@ const ResizableDiv = ({columnIndex, children, ...otherProps}) => {
124124
if (box.right > innerWidth) {
125125
editorRef.current.firstChild.style.width = `${currentWidth - widthDiff - 20}px`;
126126
}
127+
if (currentHeight || currentWidth) {
128+
window.resizeKeys = window.resizeKeys || {};
129+
window.resizeKeys[resizeKey] = {height: editorRef.current.firstChild.style.height, width: editorRef.current.firstChild.style.width};
130+
}
131+
127132
};
128133

129134
editorRef.current.addEventListener('mousedown', () => {
130135
document.addEventListener('mouseup', resizeEditor, {once: true});
131136
});
132137

138+
editorRef.current.firstChild.style.height = window.resizeKeys?.[resizeKey]?.height || defaultSize.height;
139+
editorRef.current.firstChild.style.width = window.resizeKeys?.[resizeKey]?.width || defaultSize.width;
140+
133141
return () => document.removeEventListener('mouseup', resizeEditor);
134142

135143
},[]);
@@ -146,7 +154,9 @@ const ResizableDiv = ({columnIndex, children, ...otherProps}) => {
146154
ResizableDiv.displayName = 'ResizableDiv';
147155
ResizableDiv.propTypes = {
148156
children: CustomPropTypes.children,
149-
columnIndex: PropTypes.number
157+
columnIndex: PropTypes.number,
158+
resizeKey: PropTypes.string,
159+
defaultSize: PropTypes.object,
150160
};
151161

152162
function autoFocusAndSelect(input) {
@@ -249,7 +259,7 @@ export function TextEditor({row, column, onRowChange, onClose}) {
249259
return (
250260
<Portal container={document.body}>
251261
<ResizableDiv columnIndex={column.idx}
252-
className='Editors-textEditor' data-label="pg-editor" onKeyDown={suppressEnterKey} >
262+
className='Editors-textEditor' data-label="pg-editor" resizeKey={'text'} defaultSize={{height:'80px', width:'250px'}} onKeyDown={suppressEnterKey} >
253263
<textarea ref={autoFocusAndSelect} className='Editors-textarea' value={localVal} onChange={onChange} onKeyDown={onkeydown} />
254264
<Box display="flex" justifyContent="flex-end">
255265
<DefaultButton startIcon={<CloseIcon />} onClick={()=>onClose(false)} size="small">
@@ -436,7 +446,7 @@ export function JsonTextEditor({row, column, onRowChange, onClose}) {
436446
return (
437447
<Portal container={document.body}>
438448
<ResizableDiv columnIndex={column.idx}
439-
className='Editors-jsonEditor' data-label="pg-editor" onKeyDown={suppressEnterKey} >
449+
className='Editors-jsonEditor' data-label="pg-editor" resizeKey={'json'} defaultSize={{height:'500px', width:'600px'}} onKeyDown={suppressEnterKey} >
440450
<JsonEditor
441451
setJsonEditorSize={setJsonEditorSize}
442452
value={localVal}

web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ def register_query_tool_preferences(self):
379379
'Results_grid', 'max_column_data_display_length',
380380
gettext("Max column data display length"), 'integer',
381381
200, category_label=PREF_LABEL_RESULTS_GRID,
382-
help_str=gettext('Maximum number of characters to display in the'
383-
' data preview.')
382+
help_str=gettext('Maximum number of characters to be visible in the'
383+
' data output cell.')
384384
)
385385

386386
self.sql_font_size = self.preference.register(

0 commit comments

Comments
 (0)