Add support for mimeextensions

This commit is contained in:
Jeremy Tuloup 2021-04-18 22:25:22 +02:00
parent 7d81a01fe2
commit 92e77a821f
2 changed files with 23 additions and 1 deletions

View File

@ -46,6 +46,7 @@
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/coreutils": "^5.0.0",
"@jupyterlab/docregistry": "^3.0.0",
"@jupyterlab/rendermime-interfaces": "^3.0.0",
"@jupyterlab/ui-components": "^3.0.0",
"@lumino/algorithm": "^1.3.3",
"@lumino/coreutils": "^1.5.3",

View File

@ -6,8 +6,12 @@ import {
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { createRendermimePlugins } from '@jupyterlab/application/lib/mimerenderers';
import { PageConfig } from '@jupyterlab/coreutils';
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
import { Throttler } from '@lumino/polling';
import { IClassicShell, ClassicShell } from './shell';
@ -26,6 +30,11 @@ export class App extends JupyterFrontEnd<IClassicShell> {
...options,
shell: options.shell ?? new ClassicShell()
});
if (options.mimeExtensions) {
for (const plugin of createRendermimePlugins(options.mimeExtensions)) {
this.registerPlugin(plugin);
}
}
void this._formatter.invoke();
}
@ -135,7 +144,19 @@ export namespace App {
/**
* The instantiation options for an App application.
*/
export type IOptions = JupyterFrontEnd.IOptions<IClassicShell>;
export interface IOptions
extends JupyterFrontEnd.IOptions<IClassicShell>,
Partial<IInfo> {}
/**
* The information about a JupyterLab Classic application.
*/
export interface IInfo {
/**
* The mime renderer extensions.
*/
readonly mimeExtensions: IRenderMime.IExtensionModule[];
}
/**
* The interface for a module that exports a plugin or plugins as