commit
5d9fa08593
@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "@jupyterlab-classic/help-extension",
|
||||
"version": "0.1.0",
|
||||
"description": "JupyterLab Classic - Help Extension",
|
||||
"homepage": "https://github.com/jtpio/jupyterlab-classic",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jtpio/jupyterlab-classic/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jtpio/jupyterlab-classic.git"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"author": "Project Jupyter",
|
||||
"sideEffects": [
|
||||
"style/**/*.css",
|
||||
"style/index.js"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"style": "style/index.css",
|
||||
"styleModule": "style/index.js",
|
||||
"directories": {
|
||||
"lib": "lib/"
|
||||
},
|
||||
"files": [
|
||||
"lib/*.d.ts",
|
||||
"lib/*.js.map",
|
||||
"lib/*.js",
|
||||
"schema/*.json",
|
||||
"style/**/*.css",
|
||||
"style/index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc -b",
|
||||
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
|
||||
"docs": "typedoc src",
|
||||
"prepublishOnly": "npm run build",
|
||||
"watch": "tsc -b --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jupyterlab-classic/ui-components": "^0.1.0",
|
||||
"@jupyterlab/application": "^3.0.0-rc.13",
|
||||
"@jupyterlab/apputils": "^3.0.0-rc.13",
|
||||
"@jupyterlab/mainmenu": "^3.0.0-rc.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "~3.0.0",
|
||||
"typescript": "~4.0.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"jupyterlab": {
|
||||
"extension": true
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,166 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import {
|
||||
JupyterFrontEnd,
|
||||
JupyterFrontEndPlugin
|
||||
} from '@jupyterlab/application';
|
||||
|
||||
import { showDialog, Dialog } from '@jupyterlab/apputils';
|
||||
|
||||
import { IMainMenu } from '@jupyterlab/mainmenu';
|
||||
|
||||
import { jupyterIcon } from '@jupyterlab-classic/ui-components';
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* A list of resources to show in the help menu.
|
||||
*/
|
||||
const RESOURCES = [
|
||||
{
|
||||
text: 'About Jupyter',
|
||||
url: 'https://jupyter.org'
|
||||
},
|
||||
{
|
||||
text: 'Markdown Reference',
|
||||
url: 'https://commonmark.org/help/'
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* The command IDs used by the help plugin.
|
||||
*/
|
||||
namespace CommandIDs {
|
||||
export const open = 'help:open';
|
||||
|
||||
export const shortcuts = 'help:shortcuts';
|
||||
|
||||
export const about = 'help:about';
|
||||
}
|
||||
|
||||
/**
|
||||
* The help plugin.
|
||||
*/
|
||||
const plugin: JupyterFrontEndPlugin<void> = {
|
||||
id: '@jupyterlab-classic/help-extension:plugin',
|
||||
autoStart: true,
|
||||
optional: [IMainMenu],
|
||||
activate: (app: JupyterFrontEnd, menu: IMainMenu): void => {
|
||||
const { commands } = app;
|
||||
|
||||
commands.addCommand(CommandIDs.open, {
|
||||
label: args => args['text'] as string,
|
||||
execute: args => {
|
||||
const url = args['url'] as string;
|
||||
window.open(url);
|
||||
}
|
||||
});
|
||||
|
||||
commands.addCommand(CommandIDs.shortcuts, {
|
||||
label: 'Keyboard Shortcuts',
|
||||
execute: () => {
|
||||
const title = (
|
||||
<span className="jp-AboutClassic-about-header">
|
||||
<div className="jp-AboutClassic-about-header-info">
|
||||
Keyboard Shortcuts
|
||||
</div>
|
||||
</span>
|
||||
);
|
||||
|
||||
const body = (
|
||||
<table className="jp-AboutClassic-shortcuts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Shortcut</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{commands.keyBindings
|
||||
.filter(binding => commands.isEnabled(binding.command))
|
||||
.map((binding, i) => (
|
||||
<tr key={i}>
|
||||
<td>{commands.label(binding.command)}</td>
|
||||
<td>
|
||||
<pre>{binding.keys.join(', ')}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
|
||||
return showDialog({
|
||||
title,
|
||||
body,
|
||||
buttons: [
|
||||
Dialog.createButton({
|
||||
label: 'Dismiss',
|
||||
className:
|
||||
'jp-AboutClassic-about-button jp-mod-reject jp-mod-styled'
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
commands.addCommand(CommandIDs.about, {
|
||||
label: `About ${app.name}`,
|
||||
execute: () => {
|
||||
const title = (
|
||||
<>
|
||||
<span className="jp-AboutClassic-header">
|
||||
<jupyterIcon.react height="32px" width="auto" />
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
|
||||
const classicNotebookURL =
|
||||
'https://github.com/jtpio/jupyterlab-classic';
|
||||
const externalLinks = (
|
||||
<span>
|
||||
<a
|
||||
href={classicNotebookURL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="jp-Button-flat jp-AboutClassic-about-externalLinks"
|
||||
>
|
||||
JUPYTERLAB CLASSIC ON GITHUB
|
||||
</a>
|
||||
</span>
|
||||
);
|
||||
const body = (
|
||||
<>
|
||||
<span className="jp-AboutClassic-body">JupyterLab Classic</span>
|
||||
<span className="jp-AboutClassic-body">Version: {app.version}</span>
|
||||
<div>{externalLinks}</div>
|
||||
</>
|
||||
);
|
||||
|
||||
return showDialog({
|
||||
title,
|
||||
body,
|
||||
buttons: [
|
||||
Dialog.createButton({
|
||||
label: 'Dismiss',
|
||||
className:
|
||||
'jp-AboutClassic-about-button jp-mod-reject jp-mod-styled'
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const resourcesGroup = RESOURCES.map(args => ({
|
||||
args,
|
||||
command: CommandIDs.open
|
||||
}));
|
||||
|
||||
menu.helpMenu.addGroup([{ command: CommandIDs.about }]);
|
||||
menu.helpMenu.addGroup([{ command: CommandIDs.shortcuts }]);
|
||||
menu.helpMenu.addGroup(resourcesGroup);
|
||||
}
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
@ -0,0 +1,48 @@
|
||||
.jp-AboutClassic-header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: calc(1.5 * var(--jp-private-topbar-height));
|
||||
padding: var(--jp-flat-button-padding);
|
||||
}
|
||||
|
||||
.jp-AboutClassic-header-text {
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.jp-AboutClassic-body {
|
||||
display: flex;
|
||||
font-size: var(--jp-ui-font-size3);
|
||||
padding: var(--jp-flat-button-padding);
|
||||
color: var(--jp-ui-font-color1);
|
||||
text-align: left;
|
||||
flex-direction: column;
|
||||
min-width: 360px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.jp-AboutClassic-about-body pre {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.jp-AboutClassic-about-externalLinks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
padding-top: 12px;
|
||||
color: var(--jp-warn-color0);
|
||||
}
|
||||
|
||||
.jp-AboutClassic-shortcuts {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.jp-AboutClassic-shortcuts pre {
|
||||
padding: 5px;
|
||||
margin: 0 0 10px;
|
||||
background: var(--jp-layout-color2);
|
||||
border: 1px solid var(--jp-border-color0);
|
||||
border-radius: 2px;
|
||||
word-break: break-all;
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
@import url('./base.css');
|
||||
@ -0,0 +1 @@
|
||||
import './base.css';
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfigbase",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 8.0 KiB |
Loading…
Reference in new issue