jupyterlab_advanced_image_viewer_extension 0.4.7 → 1.0.3
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.js +27 -1
- package/package.json +3 -2
- package/src/index.ts +37 -1
- package/style/base.css +13 -0
package/lib/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ToolbarButton } from '@jupyterlab/apputils';
|
|
1
|
+
import { Dialog, showDialog, Toolbar, ToolbarButton } from '@jupyterlab/apputils';
|
|
2
2
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
3
3
|
import { IImageTracker } from '@jupyterlab/imageviewer';
|
|
4
4
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
5
|
+
import { Widget } from '@lumino/widgets';
|
|
5
6
|
import { ViewerController } from './controller';
|
|
6
7
|
const PLUGIN_ID = 'jupyterlab_advanced_image_viewer_extension:plugin';
|
|
7
8
|
const CommandIDs = {
|
|
@@ -43,6 +44,24 @@ const plugin = {
|
|
|
43
44
|
}
|
|
44
45
|
return (_a = controllers.get(widget.content)) !== null && _a !== void 0 ? _a : null;
|
|
45
46
|
};
|
|
47
|
+
const showHelp = () => {
|
|
48
|
+
const body = new Widget();
|
|
49
|
+
body.addClass('jp-AdvancedImageViewer-help');
|
|
50
|
+
body.node.innerHTML = [
|
|
51
|
+
'<p>Interactive viewing layered on the standard image viewer.</p>',
|
|
52
|
+
'<ul>',
|
|
53
|
+
'<li><b>Wheel up / down</b> - zoom in / out at the cursor</li>',
|
|
54
|
+
'<li><b>Click and drag</b> - pan a zoomed-in image</li>',
|
|
55
|
+
'<li><b>+ / - / Fit</b> - zoom in, zoom out, reset to fit</li>',
|
|
56
|
+
'<li><b>Left / Right arrows</b> - previous / next image in the folder</li>',
|
|
57
|
+
'</ul>'
|
|
58
|
+
].join('');
|
|
59
|
+
void showDialog({
|
|
60
|
+
title: 'Advanced Image Viewer',
|
|
61
|
+
body,
|
|
62
|
+
buttons: [Dialog.okButton({ label: 'Close' })]
|
|
63
|
+
});
|
|
64
|
+
};
|
|
46
65
|
const attach = (widget) => {
|
|
47
66
|
const viewer = widget.content;
|
|
48
67
|
if (controllers.has(viewer)) {
|
|
@@ -74,6 +93,13 @@ const plugin = {
|
|
|
74
93
|
tooltip: 'Reset to fit',
|
|
75
94
|
onClick: () => app.commands.execute(CommandIDs.resetFit)
|
|
76
95
|
}));
|
|
96
|
+
widget.toolbar.addItem('advanced-spacer', Toolbar.createSpacerItem());
|
|
97
|
+
widget.toolbar.addItem('advanced-help', new ToolbarButton({
|
|
98
|
+
label: '?',
|
|
99
|
+
tooltip: 'Keybindings and help',
|
|
100
|
+
className: 'jp-AdvancedImageViewer-help-button',
|
|
101
|
+
onClick: () => showHelp()
|
|
102
|
+
}));
|
|
77
103
|
};
|
|
78
104
|
tracker.forEach(widget => attach(widget));
|
|
79
105
|
tracker.widgetAdded.connect((_, widget) => attach(widget));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jupyterlab_advanced_image_viewer_extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "JupyterLab extension for advanced image viewing: fit-to-screen, cursor-anchored wheel zoom, drag-to-pan, and Left/Right arrow keys to move to the previous and next image in a folder",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"@jupyterlab/docregistry": "^4.0.0",
|
|
63
63
|
"@jupyterlab/imageviewer": "^4.0.0",
|
|
64
64
|
"@jupyterlab/settingregistry": "^4.0.0",
|
|
65
|
-
"@lumino/disposable": "^2.0.0"
|
|
65
|
+
"@lumino/disposable": "^2.0.0",
|
|
66
|
+
"@lumino/widgets": "^2.0.0"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@jupyterlab/builder": "^4.0.0",
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,12 @@ import {
|
|
|
3
3
|
JupyterFrontEndPlugin
|
|
4
4
|
} from '@jupyterlab/application';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Dialog,
|
|
8
|
+
showDialog,
|
|
9
|
+
Toolbar,
|
|
10
|
+
ToolbarButton
|
|
11
|
+
} from '@jupyterlab/apputils';
|
|
7
12
|
|
|
8
13
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
9
14
|
|
|
@@ -15,6 +20,8 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
|
15
20
|
|
|
16
21
|
import { IDisposable } from '@lumino/disposable';
|
|
17
22
|
|
|
23
|
+
import { Widget } from '@lumino/widgets';
|
|
24
|
+
|
|
18
25
|
import { ViewerController } from './controller';
|
|
19
26
|
|
|
20
27
|
const PLUGIN_ID = 'jupyterlab_advanced_image_viewer_extension:plugin';
|
|
@@ -74,6 +81,25 @@ const plugin: JupyterFrontEndPlugin<void> = {
|
|
|
74
81
|
return controllers.get(widget.content) ?? null;
|
|
75
82
|
};
|
|
76
83
|
|
|
84
|
+
const showHelp = (): void => {
|
|
85
|
+
const body = new Widget();
|
|
86
|
+
body.addClass('jp-AdvancedImageViewer-help');
|
|
87
|
+
body.node.innerHTML = [
|
|
88
|
+
'<p>Interactive viewing layered on the standard image viewer.</p>',
|
|
89
|
+
'<ul>',
|
|
90
|
+
'<li><b>Wheel up / down</b> - zoom in / out at the cursor</li>',
|
|
91
|
+
'<li><b>Click and drag</b> - pan a zoomed-in image</li>',
|
|
92
|
+
'<li><b>+ / - / Fit</b> - zoom in, zoom out, reset to fit</li>',
|
|
93
|
+
'<li><b>Left / Right arrows</b> - previous / next image in the folder</li>',
|
|
94
|
+
'</ul>'
|
|
95
|
+
].join('');
|
|
96
|
+
void showDialog({
|
|
97
|
+
title: 'Advanced Image Viewer',
|
|
98
|
+
body,
|
|
99
|
+
buttons: [Dialog.okButton({ label: 'Close' })]
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
77
103
|
const attach = (widget: IDocumentWidget<ImageViewer>): void => {
|
|
78
104
|
const viewer = widget.content;
|
|
79
105
|
if (controllers.has(viewer)) {
|
|
@@ -119,6 +145,16 @@ const plugin: JupyterFrontEndPlugin<void> = {
|
|
|
119
145
|
onClick: () => app.commands.execute(CommandIDs.resetFit)
|
|
120
146
|
})
|
|
121
147
|
);
|
|
148
|
+
widget.toolbar.addItem('advanced-spacer', Toolbar.createSpacerItem());
|
|
149
|
+
widget.toolbar.addItem(
|
|
150
|
+
'advanced-help',
|
|
151
|
+
new ToolbarButton({
|
|
152
|
+
label: '?',
|
|
153
|
+
tooltip: 'Keybindings and help',
|
|
154
|
+
className: 'jp-AdvancedImageViewer-help-button',
|
|
155
|
+
onClick: () => showHelp()
|
|
156
|
+
})
|
|
157
|
+
);
|
|
122
158
|
};
|
|
123
159
|
|
|
124
160
|
tracker.forEach(widget => attach(widget));
|
package/style/base.css
CHANGED
|
@@ -3,3 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
https://jupyterlab.readthedocs.io/en/stable/developer/css.html
|
|
5
5
|
*/
|
|
6
|
+
|
|
7
|
+
.jp-AdvancedImageViewer-help {
|
|
8
|
+
max-width: 360px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.jp-AdvancedImageViewer-help ul {
|
|
12
|
+
margin: 8px 0 0;
|
|
13
|
+
padding-left: 18px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.jp-AdvancedImageViewer-help li {
|
|
17
|
+
margin: 2px 0;
|
|
18
|
+
}
|