33 JupyterFrontEndPlugin ,
44 ILayoutRestorer
55} from '@jupyterlab/application' ;
6+ import { jsonIcon } from '@jupyterlab/ui-components' ;
67import { WidgetTracker } from '@jupyterlab/apputils' ;
78import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
89import { ICommandPalette } from '@jupyterlab/apputils' ;
@@ -12,7 +13,7 @@ import { ITranslator } from '@jupyterlab/translation';
1213import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
1314
1415import { BlocklyEditorFactory } from './factory' ;
15- import { IBlocklyManager } from './token' ;
16+ import { IBlocklyRegisty } from './token' ;
1617import { BlocklyEditor } from './widget' ;
1718
1819import { blockly_icon } from './icons' ;
@@ -36,7 +37,7 @@ const PLUGIN_ID = '@jupyterlab/translation-extension:plugin';
3637/**
3738 * Initialization data for the jupyterlab-blocky extension.
3839 */
39- const plugin : JupyterFrontEndPlugin < IBlocklyManager > = {
40+ const plugin : JupyterFrontEndPlugin < IBlocklyRegisty > = {
4041 id : 'jupyterlab-blocky:plugin' ,
4142 autoStart : true ,
4243 requires : [
@@ -47,7 +48,7 @@ const plugin: JupyterFrontEndPlugin<IBlocklyManager> = {
4748 ITranslator
4849 ] ,
4950 optional : [ ILauncher , ICommandPalette ] ,
50- provides : IBlocklyManager ,
51+ provides : IBlocklyRegisty ,
5152 activate : (
5253 app : JupyterFrontEnd ,
5354 restorer : ILayoutRestorer ,
@@ -57,7 +58,7 @@ const plugin: JupyterFrontEndPlugin<IBlocklyManager> = {
5758 translator : ITranslator ,
5859 launcher : ILauncher | null ,
5960 palette : ICommandPalette | null
60- ) : IBlocklyManager => {
61+ ) : IBlocklyRegisty => {
6162 console . log ( 'JupyterLab extension jupyterlab-blocky is activated!' ) ;
6263
6364 // Namespace for the tracker
@@ -84,8 +85,8 @@ const plugin: JupyterFrontEndPlugin<IBlocklyManager> = {
8485 const widgetFactory = new BlocklyEditorFactory ( {
8586 name : FACTORY ,
8687 modelName : 'text' ,
87- fileTypes : [ 'json ' ] ,
88- defaultFor : [ 'json ' ] ,
88+ fileTypes : [ 'blockly ' ] ,
89+ defaultFor : [ 'blockly ' ] ,
8990
9091 // Kernel options, in this case we need to execute the code generated
9192 // in the blockly editor. The best way would be to use kernels, for
@@ -114,6 +115,17 @@ const plugin: JupyterFrontEndPlugin<IBlocklyManager> = {
114115 } ) ;
115116 tracker . add ( widget ) ;
116117 } ) ;
118+ // Registering the file type
119+ app . docRegistry . addFileType ( {
120+ name : 'blockly' ,
121+ displayName : 'Blockly' ,
122+ contentType : 'file' ,
123+ fileFormat : 'json' ,
124+ extensions : [ '.jpblockly' ] ,
125+ mimeTypes : [ 'application/json' ] ,
126+ icon : jsonIcon ,
127+ iconLabel : 'JupyterLab-Blockly'
128+ } ) ;
117129 // Registering the widget factory
118130 app . docRegistry . addWidgetFactory ( widgetFactory ) ;
119131
@@ -140,7 +152,7 @@ const plugin: JupyterFrontEndPlugin<IBlocklyManager> = {
140152 console . log ( `Current Language : '${ language } '` ) ;
141153
142154 // Transmitting the current language to the manager.
143- widgetFactory . manager . setlanguage ( language ) ;
155+ widgetFactory . registry . setlanguage ( language ) ;
144156 } ) ;
145157
146158 commands . addCommand ( command , {
@@ -187,7 +199,7 @@ const plugin: JupyterFrontEndPlugin<IBlocklyManager> = {
187199 } ) ;
188200 }
189201
190- return widgetFactory . manager ;
202+ return widgetFactory . registry ;
191203 }
192204} ;
193205
0 commit comments