|
@@ -9,6 +9,7 @@ import NewlinePlugin from './slate-plugins/newline';
|
|
|
import RunnerPlugin from './slate-plugins/runner';
|
|
import RunnerPlugin from './slate-plugins/runner';
|
|
|
|
|
|
|
|
import Typeahead from './typeahead';
|
|
import Typeahead from './typeahead';
|
|
|
|
|
+import { getKeybindingSrv, KeybindingSrv } from 'app/core/services/keybindingSrv';
|
|
|
|
|
|
|
|
import { Block, Document, Text, Value } from 'slate';
|
|
import { Block, Document, Text, Value } from 'slate';
|
|
|
import { Editor } from 'slate-react';
|
|
import { Editor } from 'slate-react';
|
|
@@ -61,6 +62,7 @@ class QueryField extends React.Component<any, any> {
|
|
|
menuEl: any;
|
|
menuEl: any;
|
|
|
plugins: any;
|
|
plugins: any;
|
|
|
resetTimer: any;
|
|
resetTimer: any;
|
|
|
|
|
+ keybindingSrv: KeybindingSrv = getKeybindingSrv();
|
|
|
|
|
|
|
|
constructor(props, context) {
|
|
constructor(props, context) {
|
|
|
super(props, context);
|
|
super(props, context);
|
|
@@ -90,6 +92,7 @@ class QueryField extends React.Component<any, any> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
|
|
|
+ this.restoreEscapeKeyBinding();
|
|
|
clearTimeout(this.resetTimer);
|
|
clearTimeout(this.resetTimer);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -218,6 +221,7 @@ class QueryField extends React.Component<any, any> {
|
|
|
if (onBlur) {
|
|
if (onBlur) {
|
|
|
onBlur();
|
|
onBlur();
|
|
|
}
|
|
}
|
|
|
|
|
+ this.restoreEscapeKeyBinding();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
handleFocus = () => {
|
|
handleFocus = () => {
|
|
@@ -225,8 +229,18 @@ class QueryField extends React.Component<any, any> {
|
|
|
if (onFocus) {
|
|
if (onFocus) {
|
|
|
onFocus();
|
|
onFocus();
|
|
|
}
|
|
}
|
|
|
|
|
+ // Don't go back to dashboard if Escape pressed inside the editor.
|
|
|
|
|
+ this.removeEscapeKeyBinding();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ removeEscapeKeyBinding() {
|
|
|
|
|
+ this.keybindingSrv.unbind('esc', 'keydown');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ restoreEscapeKeyBinding() {
|
|
|
|
|
+ this.keybindingSrv.setupGlobal();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
onClickItem = item => {
|
|
onClickItem = item => {
|
|
|
const { suggestions } = this.state;
|
|
const { suggestions } = this.state;
|
|
|
if (!suggestions || suggestions.length === 0) {
|
|
if (!suggestions || suggestions.length === 0) {
|