@@ -3,21 +3,22 @@ import {
33 JupyterFrontEndPlugin
44} from '@jupyterlab/application' ;
55
6- import { NotebookPanel , NotebookWidgetFactory } from '@jupyterlab/notebook' ;
76import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
87import { IEditorServices } from '@jupyterlab/codeeditor' ;
9-
10- const factoryName = 'Deepnote Notebook' ;
8+ import { IToolbarWidgetRegistry , ToolbarButton } from '@jupyterlab/apputils' ;
9+ import { NotebookPanel } from '@jupyterlab/notebook' ;
10+ import { Widget } from '@lumino/widgets' ;
1111
1212const plugin : JupyterFrontEndPlugin < void > = {
1313 id : 'jupyterlab-deepnote:plugin' ,
1414 description : 'Open .deepnote files as notebooks.' ,
1515 autoStart : true ,
16- requires : [ IRenderMimeRegistry , IEditorServices ] ,
16+ requires : [ IRenderMimeRegistry , IEditorServices , IToolbarWidgetRegistry ] ,
1717 activate : (
1818 app : JupyterFrontEnd ,
1919 rendermime : IRenderMimeRegistry ,
20- editorServices : IEditorServices
20+ editorServices : IEditorServices ,
21+ toolbarRegistry : IToolbarWidgetRegistry
2122 ) => {
2223 // 1) File type
2324 app . docRegistry . addFileType (
@@ -27,27 +28,31 @@ const plugin: JupyterFrontEndPlugin<void> = {
2728 extensions : [ '.deepnote' ] ,
2829 mimeTypes : [ 'text/yaml' , 'application/x-yaml' ] ,
2930 fileFormat : 'text' ,
30- contentType : 'notebook '
31+ contentType : 'file '
3132 } ,
32- [ factoryName ]
33+ [ 'Notebook' ]
3334 ) ;
3435
35- // 2) Widget factory that reuses the stock notebook UI
36- const contentFactory = new NotebookPanel . ContentFactory ( {
37- editorFactory : editorServices . factoryService . newInlineEditor
38- } ) ;
36+ app . docRegistry . setDefaultWidgetFactory ( 'deepnote' , 'Notebook' ) ;
3937
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- } ) ;
38+ toolbarRegistry . addFactory < NotebookPanel > (
39+ 'Notebook' ,
40+ 'deepnote:switch-notebook' ,
41+ panel => {
42+ if ( ! panel . context . path . endsWith ( '.deepnote' ) ) {
43+ return new Widget ( ) ; // don’t render for .ipynb or others
44+ }
4945
50- app . docRegistry . addWidgetFactory ( widgetFactory ) ;
46+ return new ToolbarButton ( {
47+ className : 'debug-deepnote-button' ,
48+ label : 'Deepnote' ,
49+ tooltip : 'Do a Deepnote action' ,
50+ onClick : ( ) => {
51+ console . log ( 'clicked for' , panel . context . path ) ;
52+ }
53+ } ) ;
54+ }
55+ ) ;
5156 }
5257} ;
5358
0 commit comments