Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(() => {
const opener: DocumentManager.IWidgetOpener = {
open: widget => {
/* no op */
}
};
registry = new DocumentRegistry({
textModelFactory: new TextModelFactory()
});
serviceManager = new ServiceManager({ standby: 'never' });
manager = new DocumentManager({
registry,
opener,
manager: serviceManager
});
state = new StateDB();
});
before(async () => {
const opener: DocumentManager.IWidgetOpener = {
open: widget => {
/* no op */
}
};
registry = new DocumentRegistry({
textModelFactory: new TextModelFactory()
});
serviceManager = new ServiceManager({ standby: 'never' });
iconRegistry = defaultIconRegistry;
manager = new DocumentManager({
registry,
opener,
manager: serviceManager
});
const contents = serviceManager.contents;
await contents.newUntitled({ type: 'directory' });
await contents.newUntitled({ type: 'file' });
await contents.newUntitled({ type: 'notebook' });
});
// 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({});
let editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService);
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileExtensions: ['.ipynb'],
defaultFor: ['.ipynb'],
preferKernel: true,
let rendermime = new RenderMimeRegistry({
initialFactories: initialFactories,
latexTypesetter: new MathJaxTypesetter({
url: PageConfig.getOption('mathjaxUrl'),
config: PageConfig.getOption('mathjaxConfig')
})
});
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({});
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
let rendermime = new RenderMimeRegistry({
initialFactories: initialFactories,
latexTypesetter: new MathJaxTypesetter({
url: PageConfig.getOption('mathjaxUrl'),
config: PageConfig.getOption('mathjaxConfig')
})
});
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({});
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
it('should add a file type to the document registry', () => {
registry = new DocumentRegistry({ initialFileTypes: [] });
let fileType = { name: 'notebook', extensions: ['.ipynb'] };
registry.addFileType(fileType);
expect(registry.fileTypes().next().name).to.be(fileType.name);
});
it('should get the registered file types', () => {
registry = new DocumentRegistry({ initialFileTypes: [] });
expect(toArray(registry.fileTypes()).length).to.be(0);
let fileTypes = [
{ name: 'notebook', extensions: ['.ipynb'] },
{ name: 'python', extensions: ['.py'] },
{ name: 'table', extensions: ['.table.json'] }
];
registry.addFileType(fileTypes[0]);
registry.addFileType(fileTypes[1]);
registry.addFileType(fileTypes[2]);
let values = registry.fileTypes();
expect(values.next().name).to.be(fileTypes[0].name);
expect(values.next().name).to.be(fileTypes[1].name);
expect(values.next().name).to.be(fileTypes[2].name);
});
beforeEach(() => {
registry = new DocumentRegistry();
registry.addFileType({
name: 'foobar',
extensions: ['.foo.bar']
});
});
beforeEach(() => {
registry = new DocumentRegistry();
registry.addFileType({
name: 'foobar',
extensions: ['.foo.bar']
});
registry.addFileType({
name: 'baz',
extensions: ['.baz']
});
});
let opener = {
open: (widget: Widget) => {
if (widgets.indexOf(widget) === -1) {
dock.addWidget(widget, { mode: 'tab-after' });
widgets.push(widget);
}
dock.activateWidget(widget);
activeWidget = widget;
widget.disposed.connect((w: Widget) => {
let index = widgets.indexOf(w);
widgets.splice(index, 1);
});
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let editorServices = {
factoryService: new CodeMirrorEditorFactory(),
mimeTypeService: new CodeMirrorMimeTypeService()
};
let wFactory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: 'Editor',
modelName: 'text',
fileTypes: ['*'],
defaultFor: ['*'],