44 ILayoutRestorer
55} from '@jupyterlab/application' ;
66import { ICommandPalette , WidgetTracker } from '@jupyterlab/apputils' ;
7+ import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
8+
79import { IEditorServices } from '@jupyterlab/codeeditor' ;
810import { LabIcon } from '@jupyterlab/ui-components' ;
911
@@ -23,6 +25,7 @@ import {
2325
2426const CODE_SNIPPET_EXTENSION_ID = 'code-snippet-extension' ;
2527
28+ const CODE_SNIPPET_SETTING_ID = 'jupyterlab-code-snippets:settings' ;
2629/**
2730 * Snippet Editor Icon
2831 */
@@ -150,7 +153,7 @@ function activateCodeSnippet(
150153 } ) ;
151154
152155 //Add an application command
153- const saveCommand = 'save as code snippet' ;
156+ const saveCommand = 'codeSnippet: save-as- snippet' ;
154157 const toggled = false ;
155158 app . commands . addCommand ( saveCommand , {
156159 label : 'Save As Code Snippet' ,
@@ -181,14 +184,6 @@ function activateCodeSnippet(
181184 selector : '.jp-FileEditor'
182185 } ) ;
183186
184- // Add keybinding to save
185- app . commands . addKeyBinding ( {
186- command : saveCommand ,
187- args : { } ,
188- keys : [ 'Accel Shift S' ] ,
189- selector : '.jp-Cell'
190- } ) ;
191-
192187 // Track and restore the widget state
193188 const tracker = new WidgetTracker < CodeSnippetEditor > ( {
194189 namespace : 'codeSnippetEditor'
@@ -217,6 +212,18 @@ function activateCodeSnippet(
217212 } ) ;
218213}
219214
215+ const codeSnippetExtensionSetting : JupyterFrontEndPlugin < void > = {
216+ id : CODE_SNIPPET_SETTING_ID ,
217+ autoStart : true ,
218+ requires : [ ISettingRegistry ] ,
219+ activate : ( app : JupyterFrontEnd , settingRegistry : ISettingRegistry ) => {
220+ void settingRegistry
221+ . load ( CODE_SNIPPET_SETTING_ID )
222+ . then ( _ => console . log ( 'settingRegistry successfully loaded!' ) )
223+ . catch ( e => console . log ( e ) ) ;
224+ }
225+ } ;
226+
220227function getSelectedText ( ) : string {
221228 let selectedText ;
222229 // window.getSelection
@@ -230,4 +237,4 @@ function getSelectedText(): string {
230237 return selectedText . toString ( ) ;
231238}
232239
233- export default code_snippet_extension ;
240+ export default [ code_snippet_extension , codeSnippetExtensionSetting ] ;
0 commit comments