How to use the @lumino/commands.CommandRegistry function in @lumino/commands

To help you get started, we’ve selected a few @lumino/commands 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 / examples / console / src / index.ts View on Github external
function startApp(path: string, manager: ServiceManager.IManager) {
  console.log('starting app');
  // 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
github jupyterlab / jupyterlab / examples / cell / src / index.ts View on Github external
function main(): void {
  const manager = new SessionManager();
  const session = new ClientSession({ manager, name: 'Example' });
  const mimeService = new CodeMirrorMimeTypeService();

  // Initialize the command registry with the bindings.
  const commands = new CommandRegistry();
  const useCapture = true;

  // Setup the keydown listener for the document.
  document.addEventListener(
    'keydown',
    event => {
      commands.processKeydownEvent(event);
    },
    useCapture
  );

  // Create the cell widget with a default rendermime instance.
  const rendermime = new RenderMimeRegistry({ initialFactories });

  const cellWidget = new CodeCell({
    rendermime,
github jupyterlab / jupyterlab / examples / filebrowser / src / index.ts View on Github external
mimeTypeService: new CodeMirrorMimeTypeService()
  };
  let wFactory = new FileEditorFactory({
    editorServices,
    factoryOptions: {
      name: 'Editor',
      modelName: 'text',
      fileTypes: ['*'],
      defaultFor: ['*'],
      preferKernel: false,
      canStartKernel: true
    }
  });
  docRegistry.addWidgetFactory(wFactory);

  let commands = new CommandRegistry();

  let fbModel = new FileBrowserModel({
    manager: docManager,
    iconRegistry: defaultIconRegistry
  });
  let fbWidget = new FileBrowser({
    id: 'filebrowser',
    model: fbModel
  });

  // Add a creator toolbar item.
  let creator = new ToolbarButton({
    iconClassName: 'jp-AddIcon jp-Icon jp-Icon-16',
    onClick: () => {
      void docManager
        .newUntitled({
github jupyterlab / lumino / packages / application / src / index.ts View on Github external
constructor(options: Application.IOptions) {
    // Create the application command registry.
    let commands = new CommandRegistry();

    // Create the application context menu.
    let renderer = options.contextMenuRenderer;
    let contextMenu = new ContextMenu({ commands, renderer });

    // Initialize the application state.
    this.commands = commands;
    this.contextMenu = contextMenu;
    this.shell = options.shell;
  }
github jupyterlab / jupyterlab / tests / test-application / src / layoutrestorer.spec.ts View on Github external
it('should restore the widgets in a tracker', async () => {
        const tracker = new WidgetTracker({ namespace: 'foo-widget' });
        const registry = new CommandRegistry();
        const state = new StateDB();
        const ready = new PromiseDelegate();
        const restorer = new LayoutRestorer({
          connector: state,
          first: ready.promise,
          registry
        });
        let called = false;
        const key = `${tracker.namespace}:${tracker.namespace}`;

        registry.addCommand(tracker.namespace, {
          execute: () => {
            called = true;
          }
        });
        await state.save(key, { data: null });
github jupyterlab / jupyterlab / tests / test-application / src / layoutrestorer.spec.ts View on Github external
it('should add a widget to be tracked by the restorer', async () => {
        const ready = new PromiseDelegate();
        const restorer = new LayoutRestorer({
          connector: new StateDB(),
          first: ready.promise,
          registry: new CommandRegistry()
        });
        const currentWidget = new Widget();
        const mode: DockPanel.Mode = 'single-document';
        const dehydrated: ILabShell.ILayout = {
          mainArea: { currentWidget, dock: null, mode },
          leftArea: { collapsed: true, currentWidget: null, widgets: null },
          rightArea: { collapsed: true, currentWidget: null, widgets: null }
        };
        restorer.add(currentWidget, 'test-one');
        ready.resolve(void 0);
        await restorer.restored;
        await restorer.save(dehydrated);
        const layout = await restorer.fetch();
        expect(layout.mainArea.currentWidget).to.equal(currentWidget);
        expect(layout.mainArea.mode).to.equal(mode);
      });
github jupyterlab / jupyterlab / tests / test-mainmenu / src / labmenu.spec.ts View on Github external
beforeAll(() => {
      commands = new CommandRegistry();
      commands.addCommand('run1', {
        label: 'Run 1',
        execute: () => void 0
      });
      commands.addCommand('run2', {
        label: 'Run 2',
        execute: () => void 0
      });
      commands.addCommand('run3', {
        label: 'Run 3',
        execute: () => void 0
      });
      commands.addCommand('run4', {
        label: 'Run 4',
        execute: () => void 0
      });

@lumino/commands

Lumino Commands

BSD-3-Clause
Latest version published 5 months ago

Package Health Score

83 / 100
Full package analysis

Similar packages