How to use the @jupyterlab/notebook.NotebookModelFactory function in @jupyterlab/notebook

To help you get started, we’ve selected a few @jupyterlab/notebook 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 spyder-ide / spyder-notebook / spyder_notebook / server / 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;
  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);
github jupyterlab / jupyterlab-data-explorer / 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;
  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);
github jupyterlab / jupyterlab / tests / test-notebook / src / modelfactory.spec.ts View on Github external
it('should get the file format', () => {
        const factory = new NotebookModelFactory({});
        expect(factory.fileFormat).to.equal('json');
      });
    });
github jupyterlab / jupyterlab / tests / test-notebook / src / modelfactory.spec.ts View on Github external
it('should always return an empty string', () => {
        const factory = new NotebookModelFactory({});
        expect(factory.preferredLanguage('')).to.equal('');
        expect(factory.preferredLanguage('.ipynb')).to.equal('');
      });
    });
github jupyterlab / jupyterlab / tests / test-notebook / src / modelfactory.spec.ts View on Github external
it('should get whether the factory is disposed', () => {
        const factory = new NotebookModelFactory({});
        expect(factory.isDisposed).to.equal(false);
        factory.dispose();
        expect(factory.isDisposed).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-notebook / src / modelfactory.spec.ts View on Github external
it('should get the file type', () => {
        const factory = new NotebookModelFactory({});
        expect(factory.contentType).to.equal('notebook');
      });
    });
github jupyterlab / jupyterlab / tests / test-notebook / src / modelfactory.spec.ts View on Github external
it('should accept a language preference', () => {
        const factory = new NotebookModelFactory({});
        const model = factory.createNew('foo');
        expect(model.defaultKernelLanguage).to.equal('foo');
      });
    });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / testutils / src / index.ts View on Github external
const node = host.getElementsByClassName('jp-Dialog')[0];

  if (node) {
    simulate(node as HTMLElement, 'keydown', { keyCode: 27 });
  }
}

/**
 * A namespace for private data.
 */
namespace Private {
  let manager: ServiceManager;

  export const textFactory = new TextModelFactory();

  export const notebookFactory = new NotebookModelFactory({});

  /**
   * Get or create the service manager singleton.
   */
  export function getManager(): ServiceManager {
    if (!manager) {
      manager = new ServiceManager({ standby: 'never' });
    }
    return manager;
  }
}
github yuvipanda / simplest-notebook / tests / utils.ts View on Github external
const node = host.getElementsByClassName('jp-Dialog')[0];

  if (node) {
    simulate(node as HTMLElement, 'keydown', { keyCode: 27 });
  }
}

/**
 * A namespace for private data.
 */
namespace Private {
  export const manager = new ServiceManager();

  export const textFactory = new TextModelFactory();

  export const notebookFactory = new NotebookModelFactory({});

  class JSONRenderer extends RenderedHTML {
    mimeType = 'text/html';

    renderModel(model: IRenderMime.IMimeModel): Promise {
      let source = model.data['application/json'];
      model.setData({ data: { 'text/html': json2html(source) } });
      return super.renderModel(model);
    }
  }

  const jsonRendererFactory = {
    mimeTypes: ['application/json'],
    safe: true,
    createRenderer(
      options: IRenderMime.IRendererOptions