How to use the @jupyterlab/codemirror.editorServices.factoryService function in @jupyterlab/codemirror

To help you get started, we’ve selected a few @jupyterlab/codemirror examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / tests / test-console / src / utils.ts View on Github external
// 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.
 */
github jupyterlab / jupyterlab / tests / test-console / src / utils.ts View on Github external
// 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.
github jupyterlab / jupyterlab-data-explorer / jupyterlab / examples / console / src / index.ts View on Github external
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;
github yuvipanda / simplest-notebook / examples / console / src / index.ts View on Github external
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';
github jupyterlab / jupyterlab / examples / notebook / src / index.ts View on Github external
});

  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);
github pymedphys / pymedphys / packages / pymedphys / src / pymedphys / gui / src / jupyter.tsx View on Github external
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';
github jupyterlab / jupyterlab / testutils / src / notebook-utils.ts View on Github external
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.
   */
github jupyterlab / jupyterlab-google-drive / test / src / chatbox.spec.ts View on Github external
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'
github jupyterlab / jupyterlab-google-drive / test / src / panel.spec.ts View on Github external
/**
 * 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);
    });
  });
github jupyterlab / jupyterlab-google-drive / test / src / panel.spec.ts View on Github external
/**
 * 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);
    });
  });