2019-01-02 04:24:12 -06:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2022-01-04 02:24:25 -06:00
|
|
|
// Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
2019-01-02 04:24:12 -06:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2017-07-18 09:14:59 -05:00
|
|
|
import CodeMirror from 'codemirror/lib/codemirror';
|
|
|
|
import 'codemirror/mode/sql/sql';
|
|
|
|
import 'codemirror/addon/selection/mark-selection';
|
|
|
|
import 'codemirror/addon/selection/active-line';
|
|
|
|
import 'codemirror/addon/fold/foldcode';
|
|
|
|
import 'codemirror/addon/fold/foldgutter';
|
|
|
|
import 'codemirror/addon/hint/show-hint';
|
|
|
|
import 'codemirror/addon/hint/sql-hint';
|
|
|
|
import 'codemirror/addon/scroll/simplescrollbars';
|
|
|
|
import 'codemirror/addon/dialog/dialog';
|
|
|
|
import 'codemirror/addon/search/search';
|
|
|
|
import 'codemirror/addon/search/searchcursor';
|
|
|
|
import 'codemirror/addon/search/jump-to-line';
|
|
|
|
import 'codemirror/addon/edit/matchbrackets';
|
|
|
|
import 'codemirror/addon/edit/closebrackets';
|
2018-01-17 01:54:25 -06:00
|
|
|
import 'codemirror/addon/comment/comment';
|
2018-08-29 07:50:45 -05:00
|
|
|
import 'sources/codemirror/addon/fold/pgadmin-sqlfoldcode';
|
|
|
|
import 'sources/codemirror/extension/centre_on_line';
|
2017-07-18 09:14:59 -05:00
|
|
|
|
2022-09-08 07:38:58 -05:00
|
|
|
let cmds = CodeMirror.commands;
|
2019-11-15 00:01:19 -06:00
|
|
|
cmds.focusOut = function(){
|
|
|
|
event.stopPropagation();
|
|
|
|
document.activeElement.blur();
|
2020-01-31 01:07:44 -06:00
|
|
|
if(event.currentTarget.hasOwnProperty('parents') && event.currentTarget.parents().find('.sql-code-control')) {
|
2019-11-15 00:01:19 -06:00
|
|
|
// for code mirror in dialogs
|
|
|
|
event.currentTarget.parents().find('.sql-code-control').focus();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-03 00:17:39 -05:00
|
|
|
CodeMirror.defineInitHook(function (codeMirror) {
|
|
|
|
codeMirror.addKeyMap({
|
|
|
|
Tab: function (cm) {
|
|
|
|
if(cm.somethingSelected()){
|
|
|
|
cm.execCommand('indentMore');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (cm.getOption('indentWithTabs')) {
|
|
|
|
cm.replaceSelection('\t', 'end', '+input');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cm.execCommand('insertSoftTab');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2019-11-15 00:01:19 -06:00
|
|
|
|
2020-07-03 00:17:39 -05:00
|
|
|
CodeMirror.keyMap.default['Esc'] = 'focusOut';
|
2018-08-29 07:50:45 -05:00
|
|
|
export default CodeMirror;
|