Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createApp(manager: ServiceManager.IManager): void {
// Initialize the command registry with the bindings.
let commands = new CommandRegistry();
let useCapture = true;
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
commands.processKeydownEvent(event);
}, useCapture);
let rendermime = new RenderMime({
initialFactories: defaultRendererFactories
});
let opener = {
open: (widget: Widget) => {
// Do nothing for sibling widgets for now.
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let mFactory = new NotebookModelFactory({});
function startApp(path: string, manager: ServiceManager.IManager) {
// Initialize the command registry with the key bindings.
let commands = new CommandRegistry();
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
commands.processKeydownEvent(event);
});
let rendermime = new RenderMime({
initialFactories: defaultRendererFactories
});
let editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService);
let contentFactory = new ConsolePanel.ContentFactory({ editorFactory });
let consolePanel = new ConsolePanel({
rendermime,
manager,
path,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
consolePanel.title.label = TITLE;
let palette = new CommandPalette({ commands });
import { RenderMime, defaultRendererFactories } from '@jupyterlab/rendermime';
export const renderMime = new RenderMime({
initialFactories: defaultRendererFactories
});
settingsDir: options.settingsDir || '',
assetsDir: options.assetsDir || ''
};
if (options.devMode) {
this.shell.addClass('jp-mod-devMode');
}
let linker = new CommandLinker({ commands: this.commands });
this.commandLinker = linker;
let linkHandler = {
handleLink: (node: HTMLElement, path: string) => {
linker.connectNode(node, 'docmanager:open', { path });
}
};
let initialFactories = defaultRendererFactories;
this.rendermime = new RenderMime({ initialFactories, linkHandler });
let registry = this.docRegistry = new DocumentRegistry();
registry.addModelFactory(new TextModelFactory());
registry.addModelFactory(new Base64ModelFactory());
registry.addFileType({
name: 'Text',
extension: '.txt',
contentType: 'file',
fileFormat: 'text'
});
registry.addCreator({ name: 'Text File', fileType: 'Text', });
if (options.mimeExtensions) {
let plugins = createRendermimePlugins(options.mimeExtensions);
plugins.forEach(plugin => { this.registerPlugin(plugin); });
}
function activate(app: JupyterLab, linker: ICommandLinker): IRenderMime {
let linkHandler = {
handleLink: (node: HTMLElement, path: string) => {
linker.connectNode(node, 'file-operations:open', { path });
}
};
let items = RenderMime.getDefaultItems();
return new RenderMime({ items, linkHandler });
};