Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { editorServices } from '@jupyterlab/codemirror';
import { CodeConsole, ConsolePanel } from '@jupyterlab/console';
import { defaultRenderMime } from '../../utils';
export const editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService
);
export const mimeTypeService = editorServices.mimeTypeService;
export const rendermime = defaultRenderMime();
/**
* Create a console content factory.
*/
export function createConsoleFactory(): CodeConsole.IContentFactory {
return new CodeConsole.ContentFactory({ editorFactory });
}
/**
* Create a panel content factory.
*/
export function createConsolePanelFactory(): ConsolePanel.IContentFactory {
return new ConsolePanel.ContentFactory({ editorFactory });
}
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,
rendermime,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
let notebookPath = PageConfig.getOption('notebookPath');
let nbWidget = docManager.open(notebookPath) as NotebookPanel;
let palette = new CommandPalette({ commands });
const editor =
nbWidget.content.activeCell && nbWidget.content.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session: nbWidget.session });
const handler = new CompletionHandler({ completer, connector });
// Set the handler's editor.
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,
rendermime,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
let notebookPath = PageConfig.getOption('notebookPath');
let nbWidget = docManager.open(notebookPath) as NotebookPanel;
// Create menu bar.
let menuBar = new MenuBar();
menuBar.addClass('notebookMenuBar');
const editor =
nbWidget.content.activeCell && nbWidget.content.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session: nbWidget.session });
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,
canStartKernel: true,
rendermime, contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
let nbWidget = docManager.open(NOTEBOOK) as NotebookPanel;
let palette = new CommandPalette({ commands });
const editor = nbWidget.notebook.activeCell && nbWidget.notebook.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const handler = new CompletionHandler({ completer, session: nbWidget.session });
// Set the handler's editor.
handler.editor = editor;
// Listen for active cell changes.
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
commands.processKeydownEvent(event);
});
let rendermime = new RenderMimeRegistry({ initialFactories });
let editorFactory = editorServices.factoryService.newInlineEditor;
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 });
let panel = new SplitPanel();
panel.id = 'main';
panel.orientation = 'horizontal';
panel.spacing = 0;
SplitPanel.setStretch(palette, 0);
SplitPanel.setStretch(consolePanel, 1);
panel.addWidget(palette);
panel.addWidget(consolePanel);
// Attach the panel to the DOM.
Widget.attach(panel, document.body);
commands.processKeydownEvent(event);
});
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new ConsolePanel.ContentFactory({ editorFactory });
// let consoleWidget = new CodeConsole({
// contentFactory,
// rendermime,
// mimeTypeService: editorServices.mimeTypeService,
// session:
// })
let consolePanel = new ConsolePanel({
rendermime,
manager,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
let panel = new SplitPanel();
panel.id = 'console-panel';
panel.orientation = 'horizontal';
panel.spacing = 0;
SplitPanel.setStretch(consolePanel, 1);
panel.addWidget(consolePanel);
// Attach the panel to the DOM.
// Widget.attach(panel, app);
// Handle resize events.
window.addEventListener('resize', () => {
panel.update();
});
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
commands.processKeydownEvent(event);
});
let rendermime = new RenderMimeRegistry({ initialFactories });
let editorFactory = editorServices.factoryService.newInlineEditor;
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 });
let panel = new SplitPanel();
panel.id = 'main';
panel.orientation = 'horizontal';
panel.spacing = 0;
SplitPanel.setStretch(palette, 0);
SplitPanel.setStretch(consolePanel, 1);
panel.addWidget(palette);
panel.addWidget(consolePanel);
// Attach the panel to the DOM.
Widget.attach(panel, document.body);
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,
rendermime,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
let notebookPath = PageConfig.getOption('notebookPath');
let nbWidget = docManager.open(notebookPath) as NotebookPanel;
let palette = new CommandPalette({ commands });
const editor =
nbWidget.content.activeCell && nbWidget.content.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session: nbWidget.session });
const handler = new CompletionHandler({ completer, connector });
// Set the handler's editor.
output_type: 'error',
ename: 'foo',
evalue: 'bar',
traceback: ['fizz', 'buzz']
}
];
export const DEFAULT_CONTENT: nbformat.INotebookContent = require('../default.json') as nbformat.INotebookContent;
export const defaultEditorConfig = { ...StaticNotebook.defaultEditorConfig };
export const editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService
);
export const mimeTypeService = editorServices.mimeTypeService;
/**
* Get a copy of the default rendermime instance.
*/
export function defaultRenderMime(): RenderMimeRegistry {
return localRendermime();
}
export const clipboard = Clipboard.getInstance();
/**
* Create a base cell content factory.
*/
export function createBaseCellFactory(): Cell.IContentFactory {
return new Cell.ContentFactory({ editorFactory });
}
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,
rendermime: this.props.rendermime,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
this.nbWidget = docManager.open(this.props.notebookPath) as NotebookPanel;
this.addCommands();
}