@@ -3,22 +3,16 @@ import {
33 JupyterFrontEndPlugin
44} from '@jupyterlab/application' ;
55
6- import { NotebookPanel , NotebookWidgetFactory } from '@jupyterlab/notebook' ;
7- import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
8- import { IEditorServices } from '@jupyterlab/codeeditor' ;
9-
10- const factoryName = 'Deepnote Notebook' ;
6+ import { IToolbarWidgetRegistry , ToolbarButton } from '@jupyterlab/apputils' ;
7+ import { NotebookPanel } from '@jupyterlab/notebook' ;
8+ import { Widget } from '@lumino/widgets' ;
119
1210const plugin : JupyterFrontEndPlugin < void > = {
1311 id : 'jupyterlab-deepnote:plugin' ,
1412 description : 'Open .deepnote files as notebooks.' ,
1513 autoStart : true ,
16- requires : [ IRenderMimeRegistry , IEditorServices ] ,
17- activate : (
18- app : JupyterFrontEnd ,
19- rendermime : IRenderMimeRegistry ,
20- editorServices : IEditorServices
21- ) => {
14+ requires : [ IToolbarWidgetRegistry ] ,
15+ activate : ( app : JupyterFrontEnd , toolbarRegistry : IToolbarWidgetRegistry ) => {
2216 // 1) File type
2317 app . docRegistry . addFileType (
2418 {
@@ -27,27 +21,31 @@ const plugin: JupyterFrontEndPlugin<void> = {
2721 extensions : [ '.deepnote' ] ,
2822 mimeTypes : [ 'text/yaml' , 'application/x-yaml' ] ,
2923 fileFormat : 'text' ,
30- contentType : 'notebook '
24+ contentType : 'file '
3125 } ,
32- [ factoryName ]
26+ [ 'Notebook' ]
3327 ) ;
3428
35- // 2) Widget factory that reuses the stock notebook UI
36- const contentFactory = new NotebookPanel . ContentFactory ( {
37- editorFactory : editorServices . factoryService . newInlineEditor
38- } ) ;
29+ app . docRegistry . setDefaultWidgetFactory ( 'deepnote' , 'Notebook' ) ;
3930
40- const widgetFactory = new NotebookWidgetFactory ( {
41- name : factoryName ,
42- modelName : 'notebook' , // built-in notebook model
43- fileTypes : [ 'deepnote' ] ,
44- defaultFor : [ 'deepnote' ] ,
45- rendermime,
46- contentFactory,
47- mimeTypeService : editorServices . mimeTypeService
48- } ) ;
31+ toolbarRegistry . addFactory < NotebookPanel > (
32+ 'Notebook' ,
33+ 'deepnote:switch-notebook' ,
34+ panel => {
35+ if ( ! panel . context . path . endsWith ( '.deepnote' ) ) {
36+ return new Widget ( ) ; // don’t render for .ipynb or others
37+ }
4938
50- app . docRegistry . addWidgetFactory ( widgetFactory ) ;
39+ return new ToolbarButton ( {
40+ className : 'debug-deepnote-button' ,
41+ label : 'Deepnote' ,
42+ tooltip : 'Do a Deepnote action' ,
43+ onClick : ( ) => {
44+ console . log ( 'clicked for' , panel . context . path ) ;
45+ }
46+ } ) ;
47+ }
48+ ) ;
5149 }
5250} ;
5351
0 commit comments