Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Close the browser tab when clicking on "Close and Shut Down Notebook"#6937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jtpio merged 12 commits intojupyter:mainfromjtpio:close-and-shutdown
Jun 22, 2023
Merged
Changes from1 commit
Commits
Show all changes
12 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Close the browser tab when clicking on "Close and Shut Down Notebook"
  • Loading branch information
@jtpio
jtpio committedJun 20, 2023
commitfef47d7e66a549e7cf42a8182c1bdf4b39d2a570
38 changes: 37 additions & 1 deletionpackages/notebook-extension/src/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,8 @@ import { Text, Time } from '@jupyterlab/coreutils';

import { IDocumentManager } from '@jupyterlab/docmanager';

import { IMainMenu } from '@jupyterlab/mainmenu';

import {
NotebookPanel,
INotebookTracker,
Expand All@@ -26,7 +28,7 @@ import {

import { ISettingRegistry } from '@jupyterlab/settingregistry';

import { ITranslator } from '@jupyterlab/translation';
import { ITranslator, nullTranslator } from '@jupyterlab/translation';

import { INotebookShell } from '@jupyter-notebook/application';

Expand DownExpand Up@@ -126,6 +128,39 @@ const checkpoints: JupyterFrontEndPlugin<void> = {
},
};

/**
* Add a command to close the browser tab when clicking on "Close and Shut Down"
*/
const closeTab: JupyterFrontEndPlugin<void> = {
id: '@jupyter-notebook/notebook-extension:close-tab',
autoStart: true,
requires: [IMainMenu],
optional: [ITranslator],
activate: (
app: JupyterFrontEnd,
menu: IMainMenu,
translator: ITranslator | null
) => {
const { commands } = app;
translator = translator ?? nullTranslator;
const trans = translator.load('notebook');

const id = 'notebook:close-browser-tab';
commands.addCommand(id, {
label: trans.__('Close and Shut Down Notebook'),
execute: async () => {
await commands.execute('notebook:close-and-shutdown');
window.close();
},
});
menu.fileMenu.closeAndCleaners.add({
id,
isEnabled: () => true,
rank: 0,
});
},
};

/**
* The kernel logo plugin.
*/
Expand DownExpand Up@@ -402,6 +437,7 @@ const trusted: JupyterFrontEndPlugin<void> = {
*/
const plugins: JupyterFrontEndPlugin<any>[] = [
checkpoints,
closeTab,
kernelLogo,
kernelStatus,
scrollOutput,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp