@@ -4,14 +4,16 @@ import {
44 JupyterFrontEndPlugin
55} from '@jupyterlab/application' ;
66import { ICommandPalette , IToolbarWidgetRegistry } from '@jupyterlab/apputils' ;
7+ import { IEditorServices } from '@jupyterlab/codeeditor' ;
78import { IDefaultFileBrowser } from '@jupyterlab/filebrowser' ;
89import { INotebookTracker , NotebookPanel } from '@jupyterlab/notebook' ;
910import { Contents , ContentsManager } from '@jupyterlab/services' ;
1011import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
1112import { runIcon } from '@jupyterlab/ui-components' ;
1213
14+ import { CustomContentFactory } from './cellfactory' ;
1315import { requestAPI } from './handler' ;
14- import { CommandIDs , METADATA_SQL_FORMAT , SqlCell } from './common' ;
16+ import { CommandIDs , SQL_MIMETYPE , SqlCell } from './common' ;
1517import { SqlWidget } from './widget' ;
1618
1719/**
@@ -79,11 +81,12 @@ const plugin: JupyterFrontEndPlugin<void> = {
7981 if ( ! model || model . type !== 'raw' ) {
8082 return ;
8183 }
82- if ( model . getMetadata ( 'format' ) !== METADATA_SQL_FORMAT ) {
83- model . setMetadata ( 'format' , METADATA_SQL_FORMAT ) ;
84- } else if ( model . getMetadata ( 'format' ) === METADATA_SQL_FORMAT ) {
84+ if ( model . getMetadata ( 'format' ) !== SQL_MIMETYPE ) {
85+ model . setMetadata ( 'format' , SQL_MIMETYPE ) ;
86+ } else if ( model . getMetadata ( 'format' ) === SQL_MIMETYPE ) {
8587 model . deleteMetadata ( 'format' ) ;
8688 }
89+
8790 app . commands . notifyCommandChanged ( CommandIDs . switchSQL ) ;
8891 app . commands . notifyCommandChanged ( CommandIDs . run ) ;
8992 } ,
@@ -100,6 +103,21 @@ const plugin: JupyterFrontEndPlugin<void> = {
100103 }
101104} ;
102105
106+ /**
107+ * The notebook cell factory provider, to handle SQL cells.
108+ */
109+ const cellFactory : JupyterFrontEndPlugin < NotebookPanel . IContentFactory > = {
110+ id : '@jupyter/sql-cell:content-factory' ,
111+ description : 'Provides the notebook cell factory.' ,
112+ provides : NotebookPanel . IContentFactory ,
113+ requires : [ IEditorServices ] ,
114+ autoStart : true ,
115+ activate : ( app : JupyterFrontEnd , editorServices : IEditorServices ) => {
116+ const editorFactory = editorServices . factoryService . newInlineEditor ;
117+ return new CustomContentFactory ( { editorFactory } ) ;
118+ }
119+ } ;
120+
103121/**
104122 * The notebook toolbar widget.
105123 */
@@ -143,7 +161,7 @@ const notebookToolbarWidget: JupyterFrontEndPlugin<void> = {
143161 }
144162} ;
145163
146- export default [ notebookToolbarWidget , plugin ] ;
164+ export default [ cellFactory , notebookToolbarWidget , plugin ] ;
147165
148166namespace Private {
149167 /**
0 commit comments