feat: ener keybindings for single line editor

This commit is contained in:
Anoop M D 2023-01-21 01:23:33 +05:30
parent 60fc13c765
commit ae70680ceb
2 changed files with 39 additions and 5 deletions

View File

@ -43,6 +43,7 @@ const QueryUrl = ({ item, collection, handleRun }) => {
<SingleLineEditor <SingleLineEditor
value={url} value={url}
onChange={(newValue) => onUrlChange(newValue)} onChange={(newValue) => onUrlChange(newValue)}
onRun={handleRun}
collection={collection} collection={collection}
/> />
<div className="flex items-center h-full mr-2 cursor-pointer" id="send-request" onClick={handleRun}> <div className="flex items-center h-full mr-2 cursor-pointer" id="send-request" onClick={handleRun}>

View File

@ -25,11 +25,44 @@ class SingleLineEditor extends Component {
autofocus: true, autofocus: true,
mode: "brunovariables", mode: "brunovariables",
extraKeys: { extraKeys: {
"Enter": () => {}, "Enter": () => {
"Ctrl-Enter": () => {}, if (this.props.onRun) {
"Cmd-Enter": () => {}, this.props.onRun();
"Alt-Enter": () => {}, }
"Shift-Enter": () => {} },
"Ctrl-Enter": () => {
if (this.props.onRun) {
this.props.onRun();
}
},
"Cmd-Enter": () => {
if (this.props.onRun) {
this.props.onRun();
}
},
"Alt-Enter": () => {
if (this.props.onRun) {
this.props.onRun();
}
},
"Shift-Enter": () => {
if (this.props.onRun) {
this.props.onRun();
}
},
'Cmd-S': () => {
if (this.props.onSave) {
this.props.onSave();
}
},
'Ctrl-S': () => {
if (this.props.onSave) {
this.props.onSave();
}
},
'Cmd-F': () => {},
'Ctrl-F': () => {},
'Tab': () => {}
}, },
}); });
this.editor.setValue(this.props.value) this.editor.setValue(this.props.value)