Skip to content

Commit f0866be

Browse files
authored
feat: keybindings customisation (#7603)
1 parent 882b11c commit f0866be

31 files changed

Lines changed: 3685 additions & 416 deletions

File tree

packages/bruno-app/src/components/ApiSpecPanel/FileEditor/CodeEditor/index.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@ export default class CodeEditor extends React.Component {
5757
scrollbarStyle: 'overlay',
5858
theme: this.props.theme === 'dark' ? 'monokai' : 'default',
5959
extraKeys: {
60-
'Cmd-S': () => {
61-
if (this.props.onSave) {
62-
this.props.onSave();
63-
}
64-
},
65-
'Ctrl-S': () => {
66-
if (this.props.onSave) {
67-
this.props.onSave();
68-
}
69-
},
7060
'Cmd-F': 'findPersistent',
7161
'Ctrl-F': 'findPersistent',
7262
'Cmd-H': 'replace',

packages/bruno-app/src/components/CodeEditor/index.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,6 @@ export default class CodeEditor extends React.Component {
7474
scrollbarStyle: 'overlay',
7575
theme: this.props.theme === 'dark' ? 'monokai' : 'default',
7676
extraKeys: {
77-
'Cmd-Enter': () => {
78-
if (this.props.onRun) {
79-
this.props.onRun();
80-
}
81-
},
82-
'Ctrl-Enter': () => {
83-
if (this.props.onRun) {
84-
this.props.onRun();
85-
}
86-
},
87-
'Cmd-S': () => {
88-
if (this.props.onSave) {
89-
this.props.onSave();
90-
}
91-
},
92-
'Ctrl-S': () => {
93-
if (this.props.onSave) {
94-
this.props.onSave();
95-
}
96-
},
9777
'Cmd-F': (cm) => {
9878
this.setState({ searchBarVisible: true }, () => {
9979
this.searchBarRef.current?.focus();
@@ -217,6 +197,12 @@ export default class CodeEditor extends React.Component {
217197

218198
// Setup lint error tooltip on line number hover
219199
this.cleanupLintErrorTooltip = setupLintErrorTooltip(editor);
200+
201+
// Add mousetrap class so Mousetrap captures shortcuts even when CodeMirror is focused
202+
const cmInput = editor.getInputField();
203+
if (cmInput) {
204+
cmInput.classList.add('mousetrap');
205+
}
220206
}
221207
}
222208

packages/bruno-app/src/components/Devtools/Console/TerminalTab/SessionList.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const SessionList = ({ sessions, activeSessionId, onSelectSession, onCloseSessio
113113

114114
return (
115115
<StyledSessionList>
116-
{sessions.map((session) => {
116+
{sessions.map((session, idx) => {
117117
const { name } = getSessionDisplayInfo(session);
118118
return (
119119
<ToolHint
@@ -125,6 +125,7 @@ const SessionList = ({ sessions, activeSessionId, onSelectSession, onCloseSessio
125125
>
126126
<div
127127
className={`session-list-item ${activeSessionId === session.sessionId ? 'active' : ''}`}
128+
data-testid={`session-list-${idx}`}
128129
onClick={() => onSelectSession(session.sessionId)}
129130
>
130131
<div className="session-name">
@@ -133,6 +134,7 @@ const SessionList = ({ sessions, activeSessionId, onSelectSession, onCloseSessio
133134
</div>
134135
<div
135136
className="session-close-btn"
137+
data-testid={`session-close-${idx}`}
136138
onClick={(e) => {
137139
e.stopPropagation();
138140
onCloseSession(session.sessionId);

packages/bruno-app/src/components/GlobalSearchModal/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ const GlobalSearchModal = ({ isOpen, onClose }) => {
402402
aria-activedescendant={results.length > 0 ? `search-result-${selectedIndex}` : undefined}
403403
role="combobox"
404404
aria-autocomplete="list"
405+
data-testid="global-search-input"
405406
/>
406407
{query && (
407408
<button

packages/bruno-app/src/components/MultiLineEditor/index.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ class MultiLineEditor extends Component {
4545
readOnly: this.props.readOnly,
4646
tabindex: 0,
4747
extraKeys: {
48-
'Ctrl-Enter': () => {
49-
if (this.props.onRun) {
50-
this.props.onRun();
51-
}
52-
},
53-
'Cmd-Enter': () => {
54-
if (this.props.onRun) {
55-
this.props.onRun();
56-
}
57-
},
58-
'Cmd-S': () => {
59-
if (this.props.onSave) {
60-
this.props.onSave();
61-
}
62-
},
63-
'Ctrl-S': () => {
64-
if (this.props.onSave) {
65-
this.props.onSave();
66-
}
67-
},
6848
'Cmd-F': () => {},
6949
'Ctrl-F': () => {},
7050
// Tabbing disabled to make tabindex work
@@ -90,6 +70,12 @@ class MultiLineEditor extends Component {
9070

9171
setupLinkAware(this.editor);
9272

73+
// Add mousetrap calss so Mousetrap captures shortcuts even when Codemirror is focused
74+
const cmInput = this.editor.getInputField();
75+
if (cmInput) {
76+
cmInput.classList.add('mousetrap');
77+
}
78+
9379
this.editor.setValue(String(this.props.value) || '');
9480
this.editor.on('change', this._onEdit);
9581
this.addOverlay(variables);

0 commit comments

Comments
 (0)