Skip to content

Commit 0823b1c

Browse files
committed
Add more comments
1 parent 3370908 commit 0823b1c

File tree

1 file changed

+12
-4
lines changed
  • packages/application-extension/src

1 file changed

+12
-4
lines changed

packages/application-extension/src/index.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ const TREE_PATTERN = new RegExp('/(notebooks|edit)/(.*)');
7171
*/
7272
const STRIP_IPYNB = /\.ipynb$/;
7373

74+
/**
75+
* The JupyterLab document manager plugin id.
76+
*/
77+
const JUPYTERLAB_DOCMANAGER_PLUGIN_ID =
78+
'@jupyterlab/docmanager-extension:plugin';
79+
7480
/**
7581
* The command IDs used by the application plugin.
7682
*/
@@ -189,7 +195,7 @@ const opener: JupyterFrontEndPlugin<void> = {
189195

190196
const command = 'router:tree';
191197
commands.addCommand(command, {
192-
execute: async (args: any) => {
198+
execute: (args: any) => {
193199
const parsed = args as IRouter.ILocation;
194200
const matches = parsed.path.match(TREE_PATTERN) ?? [];
195201
const [, , path] = matches;
@@ -204,17 +210,19 @@ const opener: JupyterFrontEndPlugin<void> = {
204210

205211
// Explicitely get the default viewers from the settings because
206212
// 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
207214
if (settingRegistry) {
208215
const settings = await settingRegistry.load(
209-
'@jupyterlab/docmanager-extension:plugin'
216+
JUPYTERLAB_DOCMANAGER_PLUGIN_ID
210217
);
211-
// Handle default widget factory overrides.
212218
const defaultViewers = settings.get('defaultViewers').composite as {
213219
[ft: string]: string;
214220
};
215-
216221
// get the file types for the path
217222
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
218226
types.forEach((ft) => {
219227
if (
220228
defaultViewers[ft.name] !== undefined &&

0 commit comments

Comments
 (0)