Open notebooks in a new browser tab

pull/6294/head
Jeremy Tuloup 5 years ago
parent b9d0cdc5f7
commit 595b1e2183

@ -70,6 +70,7 @@ async function main() {
let mods = [
// @jupyterlab-classic plugins
require('@jupyterlab-classic/application-extension'),
require('@jupyterlab-classic/docmanager-extension'),
require('@jupyterlab-classic/notebook-extension'),
// @jupyterlab plugins

@ -12,6 +12,7 @@
"dependencies": {
"@jupyterlab-classic/application": "^0.1.0",
"@jupyterlab-classic/application-extension": "^0.1.0",
"@jupyterlab-classic/docmanager-extension": "^0.1.0",
"@jupyterlab-classic/filebrowser-extension": "^0.1.0",
"@jupyterlab-classic/notebook-extension": "^0.1.0",
"@jupyterlab-classic/ui-components": "^0.1.0",

@ -102,13 +102,15 @@ export class ClassicShell extends Widget implements JupyterFrontEnd.IShell {
if (area === 'menu') {
return this._menuHandler.addWidget(widget, rank);
}
// TODO: better handle this
this._main.widgets.forEach(w => {
w.close();
});
this._main.addWidget(widget);
this._main.update();
this._currentChanged.emit(void 0);
if (area === 'main') {
if (this._main.widgets.length > 0) {
// do not add the widget if there is already one
return;
}
this._main.addWidget(widget);
this._main.update();
this._currentChanged.emit(void 0);
}
}
/**

@ -0,0 +1,53 @@
{
"name": "@jupyterlab-classic/docmanager-extension",
"version": "0.1.0",
"description": "JupyterLab Classic - Document Manager 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"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"directories": {
"lib": "lib/"
},
"files": [
"lib/*.d.ts",
"lib/*.js.map",
"lib/*.js",
"schema/*.json",
"style/**/*.css"
],
"scripts": {
"build": "tsc -b",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"docs": "typedoc src",
"prepublishOnly": "npm run build",
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyterlab/application": "^3.0.0-rc.12",
"@jupyterlab/coreutils": "^5.0.0-rc.12",
"@lumino/algorithm": "^1.3.3"
},
"devDependencies": {
"rimraf": "~3.0.0",
"typescript": "~4.0.2"
},
"publishConfig": {
"access": "public"
},
"jupyterlab": {
"extension": true
}
}

@ -0,0 +1,42 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { PageConfig } from '@jupyterlab/coreutils';
import { IDocumentManager } from '@jupyterlab/docmanager';
import { toArray } from '@lumino/algorithm';
/**
* A plugin to open document in a new browser tab.
*
* TODO: remove and use a custom doc manager?
*/
const opener: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab-classic/docmanager-extension:opener',
autoStart: true,
activate: (app: JupyterFrontEnd, docManager: IDocumentManager) => {
const { commands, shell } = app;
const baseUrl = PageConfig.getBaseUrl();
commands.commandExecuted.connect((sender, executedArgs) => {
const widgets = toArray(shell.widgets('main'));
const { id, args } = executedArgs;
const path = args['path'] as string;
if (id === 'docmanager:open' && widgets.length > 0 && path) {
window.open(`${baseUrl}classic/notebooks/${path}`, '_blank');
}
});
}
};
/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [opener];
export default plugins;

@ -0,0 +1 @@
@import url('./base.css');

@ -0,0 +1,8 @@
{
"extends": "../../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"]
}

@ -4,10 +4,5 @@
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"],
"references": [
{
"path": "../application"
}
]
"include": ["src/**/*"]
}

Loading…
Cancel
Save