Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 27fbff9

Browse files
authored
Merge pull request #333 from meeseeksmachine/auto-backport-of-pr-330-on-0.3.x
Backport PR #330 on branch 0.3.x (Add `Accel Enter` shortcut to execute a cell)
2 parents 3470287 + a328c19 commit 27fbff9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/notebook-extension/src/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ const kernelStatus: JupyterFrontEndPlugin<void> = {
223223
}
224224
};
225225

226+
/**
227+
* A plugin to add an extra shortcut to execute a cell in place via Cmd-Enter on Mac.
228+
* TODO: switch to settings define menus when fixed upstream: https://github.com/jupyterlab/jupyterlab/issues/11754
229+
*/
230+
const runShortcut: JupyterFrontEndPlugin<void> = {
231+
id: '@retrolab/notebook-extension:run-shortcut',
232+
autoStart: true,
233+
activate: (app: JupyterFrontEnd) => {
234+
app.commands.addKeyBinding({
235+
command: 'notebook:run-cell',
236+
keys: ['Accel Enter'],
237+
selector: '.jp-Notebook:focus'
238+
});
239+
240+
app.commands.addKeyBinding({
241+
command: 'notebook:run-cell',
242+
keys: ['Accel Enter'],
243+
selector: '.jp-Notebook.jp-mod-editMode'
244+
});
245+
}
246+
};
247+
226248
/**
227249
* A plugin to enable scrolling for outputs by default.
228250
* Mimic the logic from the classic notebook, as found here:
@@ -319,6 +341,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
319341
checkpoints,
320342
kernelLogo,
321343
kernelStatus,
344+
runShortcut,
322345
scrollOutput
323346
];
324347

0 commit comments

Comments
 (0)