@@ -71,6 +71,12 @@ const TREE_PATTERN = new RegExp('/(notebooks|edit)/(.*)');
71
71
*/
72
72
const STRIP_IPYNB = / \. i p y n b $ / ;
73
73
74
+ /**
75
+ * The JupyterLab document manager plugin id.
76
+ */
77
+ const JUPYTERLAB_DOCMANAGER_PLUGIN_ID =
78
+ '@jupyterlab/docmanager-extension:plugin' ;
79
+
74
80
/**
75
81
* The command IDs used by the application plugin.
76
82
*/
@@ -189,7 +195,7 @@ const opener: JupyterFrontEndPlugin<void> = {
189
195
190
196
const command = 'router:tree' ;
191
197
commands . addCommand ( command , {
192
- execute : async ( args : any ) => {
198
+ execute : ( args : any ) => {
193
199
const parsed = args as IRouter . ILocation ;
194
200
const matches = parsed . path . match ( TREE_PATTERN ) ?? [ ] ;
195
201
const [ , , path ] = matches ;
@@ -204,17 +210,19 @@ const opener: JupyterFrontEndPlugin<void> = {
204
210
205
211
// Explicitely get the default viewers from the settings because
206
212
// JupyterLab might not have had the time to load the settings yet (race condition)
213
+ // Relevant code: https://github.com/jupyterlab/jupyterlab/blob/d56ff811f39b3c10c6d8b6eb27a94624b753eb53/packages/docmanager-extension/src/index.tsx#L265-L293
207
214
if ( settingRegistry ) {
208
215
const settings = await settingRegistry . load (
209
- '@jupyterlab/docmanager-extension:plugin'
216
+ JUPYTERLAB_DOCMANAGER_PLUGIN_ID
210
217
) ;
211
- // Handle default widget factory overrides.
212
218
const defaultViewers = settings . get ( 'defaultViewers' ) . composite as {
213
219
[ ft : string ] : string ;
214
220
} ;
215
-
216
221
// get the file types for the path
217
222
const types = docRegistry . getFileTypesForPath ( path ) ;
223
+ // for each file type, check if there is a default viewer and if it
224
+ // is available in the docRegistry. If it is the case, use it as the
225
+ // default factory
218
226
types . forEach ( ( ft ) => {
219
227
if (
220
228
defaultViewers [ ft . name ] !== undefined &&
0 commit comments