mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Allow some objects to be dragged/dropped into the Query Tool to insert their signature into the query text. Fixes #4139
This commit is contained in:
committed by
Dave Page
parent
bdb8f20aed
commit
173b812b93
@@ -341,8 +341,31 @@ define('tools.querytool', [
|
||||
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
|
||||
extraKeys: pgBrowser.editor_shortcut_keys,
|
||||
scrollbarStyle: 'simple',
|
||||
dragDrop: false,
|
||||
});
|
||||
|
||||
if(self.handler.is_query_tool) {
|
||||
self.query_tool_obj.setOption('dragDrop', true);
|
||||
self.query_tool_obj.on('drop', (editor, e) => {
|
||||
var cursor = editor.coordsChar({
|
||||
left: e.x,
|
||||
top: e.y,
|
||||
});
|
||||
var dropDetails = JSON.parse(e.dataTransfer.getData('text'));
|
||||
e.codemirrorIgnore = true;
|
||||
e.dataTransfer.clearData('text');
|
||||
editor.replaceRange(dropDetails.text, cursor);
|
||||
editor.focus();
|
||||
editor.setSelection({
|
||||
...cursor,
|
||||
ch: cursor.ch + dropDetails.cur.from,
|
||||
},{
|
||||
...cursor,
|
||||
ch: cursor.ch +dropDetails.cur.to,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
pgBrowser.Events.on('pgadmin:query_tool:sql_panel:focus', ()=>{
|
||||
self.query_tool_obj.focus();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user