@jupyter-notebook/help-extension 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +6 -0
- package/lib/index.js +114 -0
- package/package.json +59 -0
- package/style/base.css +51 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { showDialog, Dialog } from '@jupyterlab/apputils';
|
|
4
|
+
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
5
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
6
|
+
import { jupyterIcon } from '@jupyter-notebook/ui-components';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* A list of resources to show in the help menu.
|
|
10
|
+
*/
|
|
11
|
+
const RESOURCES = [
|
|
12
|
+
{
|
|
13
|
+
text: 'About Jupyter',
|
|
14
|
+
url: 'https://jupyter.org'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
text: 'Markdown Reference',
|
|
18
|
+
url: 'https://commonmark.org/help/'
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* The command IDs used by the help plugin.
|
|
23
|
+
*/
|
|
24
|
+
var CommandIDs;
|
|
25
|
+
(function (CommandIDs) {
|
|
26
|
+
CommandIDs.open = 'help:open';
|
|
27
|
+
CommandIDs.shortcuts = 'help:shortcuts';
|
|
28
|
+
CommandIDs.about = 'help:about';
|
|
29
|
+
})(CommandIDs || (CommandIDs = {}));
|
|
30
|
+
/**
|
|
31
|
+
* The help plugin.
|
|
32
|
+
*/
|
|
33
|
+
const plugin = {
|
|
34
|
+
id: '@jupyter-notebook/help-extension:plugin',
|
|
35
|
+
autoStart: true,
|
|
36
|
+
requires: [ITranslator],
|
|
37
|
+
optional: [IMainMenu],
|
|
38
|
+
activate: (app, translator, menu) => {
|
|
39
|
+
const { commands } = app;
|
|
40
|
+
const trans = translator.load('notebook');
|
|
41
|
+
commands.addCommand(CommandIDs.open, {
|
|
42
|
+
label: args => args['text'],
|
|
43
|
+
execute: args => {
|
|
44
|
+
const url = args['url'];
|
|
45
|
+
window.open(url);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
commands.addCommand(CommandIDs.shortcuts, {
|
|
49
|
+
label: trans.__('Keyboard Shortcuts'),
|
|
50
|
+
execute: () => {
|
|
51
|
+
const title = (React.createElement("span", { className: "jp-AboutNotebook-about-header" },
|
|
52
|
+
React.createElement("div", { className: "jp-AboutNotebook-about-header-info" }, trans.__('Keyboard Shortcuts'))));
|
|
53
|
+
const body = (React.createElement("table", { className: "jp-AboutNotebook-shortcuts" },
|
|
54
|
+
React.createElement("thead", null,
|
|
55
|
+
React.createElement("tr", null,
|
|
56
|
+
React.createElement("th", null, trans.__('Name')),
|
|
57
|
+
React.createElement("th", null, trans.__('Shortcut')))),
|
|
58
|
+
React.createElement("tbody", null, commands.keyBindings
|
|
59
|
+
.filter(binding => commands.isEnabled(binding.command))
|
|
60
|
+
.map((binding, i) => (React.createElement("tr", { key: i },
|
|
61
|
+
React.createElement("td", null, commands.label(binding.command)),
|
|
62
|
+
React.createElement("td", null,
|
|
63
|
+
React.createElement("pre", null, binding.keys.join(', ')))))))));
|
|
64
|
+
return showDialog({
|
|
65
|
+
title,
|
|
66
|
+
body,
|
|
67
|
+
buttons: [
|
|
68
|
+
Dialog.createButton({
|
|
69
|
+
label: trans.__('Dismiss'),
|
|
70
|
+
className: 'jp-AboutNotebook-about-button jp-mod-reject jp-mod-styled'
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
commands.addCommand(CommandIDs.about, {
|
|
77
|
+
label: trans.__('About %1', app.name),
|
|
78
|
+
execute: () => {
|
|
79
|
+
const title = (React.createElement(React.Fragment, null,
|
|
80
|
+
React.createElement("span", { className: "jp-AboutNotebook-header" },
|
|
81
|
+
React.createElement(jupyterIcon.react, { width: "196px", height: "auto" }))));
|
|
82
|
+
const notebookURL = 'https://github.com/jupyter/notebook';
|
|
83
|
+
const linkLabel = trans.__('JUPYTER NOTEBOOK ON GITHUB');
|
|
84
|
+
const externalLinks = (React.createElement("span", null,
|
|
85
|
+
React.createElement("a", { href: notebookURL, target: "_blank", rel: "noopener noreferrer", className: "jp-Button-flat jp-AboutNotebook-about-externalLinks" }, linkLabel)));
|
|
86
|
+
const version = trans.__('Version: %1', app.version);
|
|
87
|
+
const body = (React.createElement(React.Fragment, null,
|
|
88
|
+
React.createElement("span", { className: "jp-AboutNotebook-body" }, version),
|
|
89
|
+
React.createElement("div", null, externalLinks)));
|
|
90
|
+
const dialog = new Dialog({
|
|
91
|
+
title,
|
|
92
|
+
body,
|
|
93
|
+
buttons: [
|
|
94
|
+
Dialog.createButton({
|
|
95
|
+
label: trans.__('Dismiss'),
|
|
96
|
+
className: 'jp-AboutNotebook-about-button jp-mod-reject jp-mod-styled'
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
dialog.addClass('jp-AboutNotebook');
|
|
101
|
+
void dialog.launch();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const resourcesGroup = RESOURCES.map(args => ({
|
|
105
|
+
args,
|
|
106
|
+
command: CommandIDs.open
|
|
107
|
+
}));
|
|
108
|
+
if (menu) {
|
|
109
|
+
menu.helpMenu.addGroup([{ command: CommandIDs.shortcuts }]);
|
|
110
|
+
menu.helpMenu.addGroup(resourcesGroup);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
export default plugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jupyter-notebook/help-extension",
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
|
+
"description": "Jupyter Notebook - Help Extension",
|
|
5
|
+
"homepage": "https://github.com/jupyter/notebook",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/jupyter/notebook/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/jupyter/notebook.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "BSD-3-Clause",
|
|
14
|
+
"author": "Project Jupyter",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"style/**/*.css",
|
|
17
|
+
"style/index.js"
|
|
18
|
+
],
|
|
19
|
+
"main": "lib/index.js",
|
|
20
|
+
"types": "lib/index.d.ts",
|
|
21
|
+
"style": "style/index.css",
|
|
22
|
+
"directories": {
|
|
23
|
+
"lib": "lib/"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/*.d.ts",
|
|
27
|
+
"lib/*.js.map",
|
|
28
|
+
"lib/*.js",
|
|
29
|
+
"schema/*.json",
|
|
30
|
+
"style/**/*.css",
|
|
31
|
+
"style/index.js"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -b",
|
|
35
|
+
"build:prod": "tsc -b",
|
|
36
|
+
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
|
|
37
|
+
"docs": "typedoc src",
|
|
38
|
+
"prepublishOnly": "npm run build",
|
|
39
|
+
"watch": "tsc -b --watch"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@jupyter-notebook/ui-components": "^7.0.0-alpha.1",
|
|
43
|
+
"@jupyterlab/application": "^4.0.0-alpha.5",
|
|
44
|
+
"@jupyterlab/apputils": "^4.0.0-alpha.5",
|
|
45
|
+
"@jupyterlab/mainmenu": "^4.0.0-alpha.5",
|
|
46
|
+
"@jupyterlab/translation": "^4.0.0-alpha.4"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"rimraf": "~3.0.0",
|
|
50
|
+
"typescript": "~4.1.3"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"jupyterlab": {
|
|
56
|
+
"extension": true
|
|
57
|
+
},
|
|
58
|
+
"styleModule": "style/index.js"
|
|
59
|
+
}
|
package/style/base.css
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.jp-AboutNotebook .jp-Dialog-header {
|
|
2
|
+
justify-content: center;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.jp-AboutNotebook-header {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
align-items: center;
|
|
9
|
+
padding: var(--jp-flat-button-padding);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.jp-AboutNotebook-header-text {
|
|
13
|
+
margin-left: 16px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.jp-AboutNotebook-body {
|
|
17
|
+
display: flex;
|
|
18
|
+
font-size: var(--jp-ui-font-size2);
|
|
19
|
+
padding: var(--jp-flat-button-padding);
|
|
20
|
+
color: var(--jp-ui-font-color1);
|
|
21
|
+
text-align: left;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
min-width: 360px;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.jp-AboutNotebook-about-body pre {
|
|
28
|
+
white-space: pre-wrap;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.jp-AboutNotebook-about-externalLinks {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
justify-content: flex-start;
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
padding-top: 12px;
|
|
37
|
+
color: var(--jp-warn-color0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.jp-AboutNotebook-shortcuts {
|
|
41
|
+
padding: 10px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.jp-AboutNotebook-shortcuts pre {
|
|
45
|
+
padding: 5px;
|
|
46
|
+
margin: 0 0 10px;
|
|
47
|
+
background: var(--jp-layout-color2);
|
|
48
|
+
border: 1px solid var(--jp-border-color0);
|
|
49
|
+
border-radius: 2px;
|
|
50
|
+
word-break: break-all;
|
|
51
|
+
}
|
package/style/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import url('./base.css');
|
package/style/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './base.css';
|