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.
*/
// 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.
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 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;
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 });
let panel = new SplitPanel();
panel.id = 'main';
panel.orientation = 'horizontal';
});
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,
canStartKernel: true,
rendermime, contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
function buildConsole(manager: ServiceManager.IManager) {
let commands = new CommandRegistry();
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
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';
metadata: {}
},
{
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.
*/
import {
ModelDB,
ObservableMap,
ObservableList,
ICollaborator
} from '@jupyterlab/observables';
import { Chatbox, ChatEntry } from '../../lib/chatbox';
import { defaultRenderMime } from './util';
/**
* Factory stuff.
*/
const editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService
);
const contentFactory = new Chatbox.ContentFactory({ editorFactory });
const rendermime = defaultRenderMime();
/**
* Create a dummy collaborator map.
*/
class DummyCollaboratorMap extends ObservableMap {
type: 'Map';
readonly localCollaborator: ICollaborator = {
userId: '1234',
sessionId: '5678',
displayName: 'A. U. Thor',
color: '#00FF33',
shortName: 'AU'
/**
* The common file model.
*/
const FILE: Partial = {
path: uuid() + '.txt',
type: 'file',
mimetype: 'text/plain',
content: 'Hello, world',
format: 'text'
};
/**
* Factory stuff.
*/
const editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService
);
const contentFactory = new ChatboxPanel.ContentFactory({ editorFactory });
const rendermime = defaultRenderMime();
describe('chatbox/panel', () => {
let panel: ChatboxPanel;
let context: Context;
let manager: ServiceManager.IManager;
before(() => {
manager = new ServiceManager();
return manager.ready.then(() => {
return manager.contents.save(FILE.path, FILE);
});
});
/**
* The common file model.
*/
const FILE: Partial = {
path: uuid() + '.txt',
type: 'file',
mimetype: 'text/plain',
content: 'Hello, world',
format: 'text'
};
/**
* Factory stuff.
*/
const editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService
);
const contentFactory = new ChatboxPanel.ContentFactory({ editorFactory });
const rendermime = defaultRenderMime();
describe('chatbox/panel', () => {
let panel: ChatboxPanel;
let context: Context;
let manager: ServiceManager.IManager;
before(() => {
manager = new ServiceManager();
return manager.ready.then(() => {
return manager.contents.save(FILE.path, FILE);
});
});