How to use the @jupyterlab/docregistry.DocumentRegistry.extname function in @jupyterlab/docregistry

To help you get started, we’ve selected a few @jupyterlab/docregistry 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 yuvipanda / simplest-notebook / packages / filebrowser-extension / src / index.ts View on Github external
function createContextMenu(path: string, commands: CommandRegistry, registry: DocumentRegistry):  Menu {
  const menu = new Menu({ commands });

  menu.addItem({ command: CommandIDs.open });

  const ext = DocumentRegistry.extname(path);
  const factories = registry.preferredWidgetFactories(ext).map(f => f.name);
  if (path && factories.length > 1) {
    const command =  'docmanager:open';
    const openWith = new Menu({ commands });
    openWith.title.label = 'Open With...';
    factories.forEach(factory => {
      openWith.addItem({ args: { factory, path }, command });
    });
    menu.addItem({ type: 'submenu', submenu: openWith });
  }

  menu.addItem({ command: CommandIDs.rename });
  menu.addItem({ command: CommandIDs.del });
  menu.addItem({ command: CommandIDs.duplicate });
  menu.addItem({ command: CommandIDs.cut });
  menu.addItem({ command: CommandIDs.copy });
github jupyterlab / jupyterlab / packages / filebrowser / src / dialogs.ts View on Github external
get ext(): string {
    return DocumentRegistry.extname(this.inputNode.value);
  }
github jupyterlab / jupyterlab / packages / filebrowser / src / dialogs.ts View on Github external
constructor(path: string, manager: DocumentManager) {
    super({ node: Private.createOpenWithNode() });
    this._manager = manager;

    this.inputNode.textContent = path;
    this._ext = DocumentRegistry.extname(path);

    this.populateFactories();
    this.widgetDropdown.onchange = this.widgetChanged.bind(this);
  }