How to use @jupyterlab/markdownviewer - 5 common examples

To help you get started, we’ve selected a few @jupyterlab/markdownviewer 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-data-explorer / jupyterlab / packages / markdownviewer-extension / src / index.ts View on Github external
// Fetch the initial state of the settings.
  settingRegistry
    .load(plugin.id)
    .then((settings: ISettingRegistry.ISettings) => {
      settings.changed.connect(() => {
        updateSettings(settings);
      });
      updateSettings(settings);
    })
    .catch((reason: Error) => {
      console.error(reason.message);
    });

  // Register the MarkdownViewer factory.
  const factory = new MarkdownViewerFactory({
    rendermime,
    name: FACTORY,
    primaryFileType: docRegistry.getFileType('markdown'),
    fileTypes: ['markdown'],
    defaultRendered: ['markdown']
  });
  factory.widgetCreated.connect((sender, widget) => {
    // Notify the instance tracker if restore data needs to update.
    widget.context.pathChanged.connect(() => {
      void tracker.save(widget);
    });
    // Handle the settings of new widgets.
    updateWidget(widget.content);
    void tracker.add(widget);
  });
  docRegistry.addWidgetFactory(factory);
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / markdownviewer-extension / src / index.ts View on Github external
restorer: ILayoutRestorer,
  rendermime: IRenderMimeRegistry,
  settingRegistry: ISettingRegistry
): IMarkdownViewerTracker {
  const { commands, docRegistry } = app;

  // Add the markdown renderer factory.
  rendermime.addFactory(markdownRendererFactory);

  const namespace = 'markdownviewer-widget';
  const tracker = new InstanceTracker({
    namespace
  });

  let config: Partial = {
    ...MarkdownViewer.defaultConfig
  };

  /**
   * Update the settings of a widget.
   */
  function updateWidget(widget: MarkdownViewer): void {
    Object.keys(config).forEach((k: keyof MarkdownViewer.IConfig) => {
      widget.setOption(k, config[k]);
    });
  }

  /**
   * Update the setting values.
   */
  function updateSettings(settings: ISettingRegistry.ISettings) {
    config = settings.composite as Partial;
github jupyterlab / jupyterlab / test / src / markdownviewer / widget.spec.ts View on Github external
it('should require a context parameter', () => {
        let widget = new MarkdownViewer(context, RENDERMIME);
        expect(widget).to.be.a(MarkdownViewer);
      });
github jupyterlab / jupyterlab / test / src / markdownviewer / widget.spec.ts View on Github external
it('should be fulfilled when the widget is done rendering', () => {
        let widget = new MarkdownViewer(context, RENDERMIME);
        context.save();
        return widget.ready.then(() => {
          let layout = widget.layout as PanelLayout;
          expect(layout.widgets.length).to.be(2);
        });
      });
github jupyterlab / jupyterlab / test / src / markdownviewer / widget.spec.ts View on Github external
it('should require a context parameter', () => {
        let widgetFactory = new MarkdownViewerFactory({
          name: 'markdown',
          fileExtensions: ['.md'],
          rendermime: RENDERMIME
        });
        expect(widgetFactory.createNew(context)).to.be.a(MarkdownViewer);
      });

@jupyterlab/markdownviewer

JupyterLab - Markdown viewer Widget

BSD-3-Clause
Latest version published 19 days ago

Package Health Score

95 / 100
Full package analysis