jupyterlab_advanced_image_viewer_extension 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -23,6 +23,7 @@ The viewer toolbar adds zoom in / out / fit controls and a `help` link that list
23
23
  - **Arrow-key navigation** - Left and Right open the previous and next image in the same folder, advancing within one viewer instead of opening new tabs
24
24
  - **Copy to clipboard** - right-click a raster image (PNG/JPG/…) and choose "Copy to Clipboard" to copy it as PNG to the system clipboard
25
25
  - **Refresh** - a toolbar refresh button reloads the image from disk, the same control the HTML viewer provides
26
+ - **WebP support** - `.webp` files open in the image viewer with every feature above; stock JupyterLab opens them in the text editor
26
27
 
27
28
  ## Requirements
28
29
 
package/lib/index.js CHANGED
@@ -132,6 +132,17 @@ const plugin = {
132
132
  };
133
133
  tracker.forEach(widget => attach(widget));
134
134
  tracker.widgetAdded.connect((_, widget) => attach(widget));
135
+ // JupyterLab registers a 'webp' file type but binds no image viewer to it,
136
+ // so a .webp falls through to the text editor and fails with "not UTF-8
137
+ // encoded". Bind the stock 'Image' factory to it rather than a factory of
138
+ // our own: the document manager finds an open tab by path and factory
139
+ // name, and the file browser, the /tree route, the layout restorer and
140
+ // navigate() must all name the same factory or each opens its own tab.
141
+ // The stock factory then tracks the widget and sets its icon, as for a PNG.
142
+ const webp = app.docRegistry.getFileType('webp');
143
+ if (webp) {
144
+ app.docRegistry.addFileType(webp, ['Image']);
145
+ }
135
146
  app.commands.addCommand(CommandIDs.zoomIn, {
136
147
  label: 'Zoom In (Advanced Image Viewer)',
137
148
  isEnabled: () => currentController() !== null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyterlab_advanced_image_viewer_extension",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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",
package/src/index.ts CHANGED
@@ -191,6 +191,18 @@ const plugin: JupyterFrontEndPlugin<void> = {
191
191
  tracker.forEach(widget => attach(widget));
192
192
  tracker.widgetAdded.connect((_, widget) => attach(widget));
193
193
 
194
+ // JupyterLab registers a 'webp' file type but binds no image viewer to it,
195
+ // so a .webp falls through to the text editor and fails with "not UTF-8
196
+ // encoded". Bind the stock 'Image' factory to it rather than a factory of
197
+ // our own: the document manager finds an open tab by path and factory
198
+ // name, and the file browser, the /tree route, the layout restorer and
199
+ // navigate() must all name the same factory or each opens its own tab.
200
+ // The stock factory then tracks the widget and sets its icon, as for a PNG.
201
+ const webp = app.docRegistry.getFileType('webp');
202
+ if (webp) {
203
+ app.docRegistry.addFileType(webp, ['Image']);
204
+ }
205
+
194
206
  app.commands.addCommand(CommandIDs.zoomIn, {
195
207
  label: 'Zoom In (Advanced Image Viewer)',
196
208
  isEnabled: () => currentController() !== null,