UNPKG

@voila-dashboards/jupyterlab-gridstack

Version:

A gridstack-based template for [![voila-gridstack](assets/voila.png)](https://github.com/voila-dashboards/voila).

71 lines (70 loc) 2.42 kB
import { ABCWidgetFactory } from '@jupyterlab/docregistry'; import { NotebookPanel, StaticNotebook, } from '@jupyterlab/notebook'; import { VoilaGridStackWidget } from './widget'; import { VoilaGridStackPanel } from './panel'; /** * A widget factory for `VoilaGridstack` Widget. */ export class VoilaGridStackWidgetFactory extends ABCWidgetFactory { /** * Construct a new `VoilaGridStackWidgetFactory`. * * @param options - The options used to construct the factory. */ constructor(options) { super(options); this.rendermime = options.rendermime; this.contentFactory = options.contentFactory || new NotebookPanel.ContentFactory({ editorFactory: options.editorFactoryService.newInlineEditor, }); this.mimeTypeService = options.mimeTypeService; this._editorConfig = options.editorConfig || StaticNotebook.defaultEditorConfig; this._notebookConfig = options.notebookConfig || StaticNotebook.defaultNotebookConfig; } /** * A configuration object for cell editor settings. */ get editorConfig() { return this._editorConfig; } set editorConfig(value) { this._editorConfig = value; } /** * A configuration object for notebook settings. */ get notebookConfig() { return this._notebookConfig; } set notebookConfig(value) { this._notebookConfig = value; } /** * Creates a new `VoilaGridstackWidget`. * * @param context - The Notebook context. * @param source - An optional `VoilaGridstackWidget`. * * #### Notes * The factory will start the appropriate kernel. */ createNewWidget(context, source) { const options = { context: context, rendermime: source ? source.content.rendermime : this.rendermime.clone({ resolver: context.urlResolver }), contentFactory: this.contentFactory, mimeTypeService: this.mimeTypeService, editorConfig: source ? source.content.editorConfig : this._editorConfig, notebookConfig: source ? source.content.notebookConfig : this._notebookConfig, }; return new VoilaGridStackWidget(context, new VoilaGridStackPanel(options)); } }