@jupyterlab/fileeditor-extension 4.5.0-alpha.0 → 4.5.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands.d.ts +7 -3
- package/lib/commands.js +341 -28
- package/lib/commands.js.map +1 -1
- package/lib/index.js +44 -14
- package/lib/index.js.map +1 -1
- package/package.json +25 -23
- package/src/commands.ts +381 -42
- package/src/index.ts +61 -24
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/src/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
} from '@jupyterlab/lsp';
|
|
59
59
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
60
60
|
import { IObservableList } from '@jupyterlab/observables';
|
|
61
|
+
import { IMarkdownParser } from '@jupyterlab/rendermime';
|
|
61
62
|
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
|
|
62
63
|
import { Session } from '@jupyterlab/services';
|
|
63
64
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
@@ -67,6 +68,7 @@ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
|
67
68
|
import { IFormRendererRegistry, MenuSvg } from '@jupyterlab/ui-components';
|
|
68
69
|
import { find } from '@lumino/algorithm';
|
|
69
70
|
import { JSONObject } from '@lumino/coreutils';
|
|
71
|
+
import { IDisposable } from '@lumino/disposable';
|
|
70
72
|
import { Widget } from '@lumino/widgets';
|
|
71
73
|
|
|
72
74
|
import { CommandIDs, Commands, FACTORY, IFileTypeData } from './commands';
|
|
@@ -99,7 +101,8 @@ const plugin: JupyterFrontEndPlugin<IEditorTracker> = {
|
|
|
99
101
|
ISessionContextDialogs,
|
|
100
102
|
ITableOfContentsRegistry,
|
|
101
103
|
ITranslator,
|
|
102
|
-
IFormRendererRegistry
|
|
104
|
+
IFormRendererRegistry,
|
|
105
|
+
IMarkdownParser
|
|
103
106
|
],
|
|
104
107
|
provides: IEditorTracker,
|
|
105
108
|
autoStart: true
|
|
@@ -333,7 +336,8 @@ function activate(
|
|
|
333
336
|
sessionDialogs_: ISessionContextDialogs | null,
|
|
334
337
|
tocRegistry: ITableOfContentsRegistry | null,
|
|
335
338
|
translator_: ITranslator | null,
|
|
336
|
-
formRegistry: IFormRendererRegistry | null
|
|
339
|
+
formRegistry: IFormRendererRegistry | null,
|
|
340
|
+
parser: IMarkdownParser | null
|
|
337
341
|
): IEditorTracker {
|
|
338
342
|
const id = plugin.id;
|
|
339
343
|
const translator = translator_ ?? nullTranslator;
|
|
@@ -405,6 +409,59 @@ function activate(
|
|
|
405
409
|
return fileTypes;
|
|
406
410
|
};
|
|
407
411
|
|
|
412
|
+
let launcherDisposables: IDisposable | null = null;
|
|
413
|
+
let paletteDisposables: IDisposable | null = null;
|
|
414
|
+
let menuDisposables: IDisposable | null = null;
|
|
415
|
+
|
|
416
|
+
const updateKernelFileTypeComponents = (fileTypes: Set<IFileTypeData>) => {
|
|
417
|
+
// Dispose of previous entries if they exist
|
|
418
|
+
if (launcherDisposables) {
|
|
419
|
+
launcherDisposables.dispose();
|
|
420
|
+
launcherDisposables = null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (paletteDisposables) {
|
|
424
|
+
paletteDisposables.dispose();
|
|
425
|
+
paletteDisposables = null;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (menuDisposables) {
|
|
429
|
+
menuDisposables.dispose();
|
|
430
|
+
menuDisposables = null;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (launcher) {
|
|
434
|
+
launcherDisposables = Commands.addKernelLanguageLauncherItems(
|
|
435
|
+
launcher,
|
|
436
|
+
trans,
|
|
437
|
+
fileTypes
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (palette) {
|
|
442
|
+
paletteDisposables = Commands.addKernelLanguagePaletteItems(
|
|
443
|
+
palette,
|
|
444
|
+
trans,
|
|
445
|
+
fileTypes
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (menu) {
|
|
450
|
+
menuDisposables = Commands.addKernelLanguageMenuItems(menu, fileTypes);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// Update if new specs are added later
|
|
455
|
+
const specsManager = app.serviceManager.kernelspecs;
|
|
456
|
+
specsManager.specsChanged.connect(async () => {
|
|
457
|
+
try {
|
|
458
|
+
const updatedFileTypes = await getAvailableKernelFileTypes();
|
|
459
|
+
updateKernelFileTypeComponents(updatedFileTypes);
|
|
460
|
+
} catch (error) {
|
|
461
|
+
console.error('Error updating kernel file types:', error);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
408
465
|
// Handle state restoration.
|
|
409
466
|
if (restorer) {
|
|
410
467
|
void restorer.restore(tracker, {
|
|
@@ -566,34 +623,14 @@ function activate(
|
|
|
566
623
|
}
|
|
567
624
|
|
|
568
625
|
getAvailableKernelFileTypes()
|
|
569
|
-
.then(
|
|
570
|
-
if (launcher) {
|
|
571
|
-
Commands.addKernelLanguageLauncherItems(
|
|
572
|
-
launcher,
|
|
573
|
-
trans,
|
|
574
|
-
availableKernelFileTypes
|
|
575
|
-
);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
if (palette) {
|
|
579
|
-
Commands.addKernelLanguagePaletteItems(
|
|
580
|
-
palette,
|
|
581
|
-
trans,
|
|
582
|
-
availableKernelFileTypes
|
|
583
|
-
);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
if (menu) {
|
|
587
|
-
Commands.addKernelLanguageMenuItems(menu, availableKernelFileTypes);
|
|
588
|
-
}
|
|
589
|
-
})
|
|
626
|
+
.then(updateKernelFileTypeComponents)
|
|
590
627
|
.catch((reason: Error) => {
|
|
591
628
|
console.error(reason.message);
|
|
592
629
|
});
|
|
593
630
|
|
|
594
631
|
if (tocRegistry) {
|
|
595
632
|
tocRegistry.add(new LaTeXTableOfContentsFactory(tracker));
|
|
596
|
-
tocRegistry.add(new MarkdownTableOfContentsFactory(tracker));
|
|
633
|
+
tocRegistry.add(new MarkdownTableOfContentsFactory(tracker, parser));
|
|
597
634
|
tocRegistry.add(new PythonTableOfContentsFactory(tracker));
|
|
598
635
|
}
|
|
599
636
|
|
package/style/index.css
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
@import url('~@jupyterlab/statusbar/style/index.css');
|
|
10
10
|
@import url('~@jupyterlab/apputils/style/index.css');
|
|
11
11
|
@import url('~@jupyterlab/codeeditor/style/index.css');
|
|
12
|
+
@import url('~@jupyterlab/rendermime/style/index.css');
|
|
12
13
|
@import url('~@jupyterlab/docregistry/style/index.css');
|
|
13
14
|
@import url('~@jupyterlab/application/style/index.css');
|
|
14
15
|
@import url('~@jupyterlab/documentsearch/style/index.css');
|
package/style/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import '@jupyterlab/ui-components/style/index.js';
|
|
|
9
9
|
import '@jupyterlab/statusbar/style/index.js';
|
|
10
10
|
import '@jupyterlab/apputils/style/index.js';
|
|
11
11
|
import '@jupyterlab/codeeditor/style/index.js';
|
|
12
|
+
import '@jupyterlab/rendermime/style/index.js';
|
|
12
13
|
import '@jupyterlab/docregistry/style/index.js';
|
|
13
14
|
import '@jupyterlab/application/style/index.js';
|
|
14
15
|
import '@jupyterlab/documentsearch/style/index.js';
|