-
-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (58 loc) · 1.99 KB
/
Copy pathindex.js
File metadata and controls
69 lines (58 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const $ = require('jquery');
require("jquery-ui");
global.__VP_CSS_LOADER__ = function(path) {
return path + '.css';
}
global.__VP_TEXT_LOADER__ = function(path) {
return '!!text-loader!' + path;
}
global.__VP_RAW_LOADER__ = function(path) {
return path;
}
const vpId = 'jupyterlab-visualpython:plugin';
const { ICommandPalette } = require('@jupyterlab/apputils');
global.$ = $;
global.vpBase = path.resolve(__dirname, "lib") + '/';
module.exports = [{
id: vpId,
autoStart: true,
requires: [ICommandPalette],
activate: function (app, palette) {
console.log(
'JupyterLab extension visualpython is activated!'
);
global.vpExtType = 'lab';
if (app.name === 'JupyterLite') {
global.vpExtType = 'lite';
}
global.vpLab = app;
const VpPanel = require('./VpPanel');
// Add vp to the right area:
var vpPanel = new VpPanel(app);
app.shell.add(vpPanel, 'right', { rank: 900, type: 'Visual Python' });
// Add toggle button
let isVpVisible = app.name !== 'JupyterLab'; // compatible for notebook 7.x (hidden for jupyterlab)
let toggleCommand = 'jupyterlab-visualpython:toggle-panel';
let vpLabel = isVpVisible?'Toggle Visual Python':'';
app.commands.addCommand(toggleCommand, {
isEnabled: () => isVpVisible,
isVisible: () => isVpVisible,
iconClass: 'jp-vp-icon',
iconLabel: vpLabel,
execute: () => {
if (app.shell.rightCollapsed === true || $('#vp_wrapper').is(':visible') === false) {
app.shell.activateById('vp_wrapper');
} else {
app.shell.collapseRight();
}
}
});
// Add command palette
palette.addItem({
command: toggleCommand,
category: 'Visual Python',
label: 'Toggle Visual Python'
});
}
}];