How to use the @jupyterlab/apputils.CommandLinker function in @jupyterlab/apputils

To help you get started, we’ve selected a few @jupyterlab/apputils 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 / tests / test-apputils / src / commandlinker.spec.ts View on Github external
it('should disconnect a node from a command', () => {
        let called = false;
        const command = 'commandlinker:disconnect-node';
        const commands = new CommandRegistry();
        const linker = new CommandLinker({ commands });
        const node = document.createElement('div');
        const disposable = commands.addCommand(command, {
          execute: () => {
            called = true;
          }
        });

        document.body.appendChild(node);
        linker.connectNode(node, command, undefined);

        // Make sure connection is working.
        expect(called).to.equal(false);
        simulate(node, 'click');
        expect(called).to.equal(true);

        // Reset flag.
github jupyterlab / jupyterlab / packages / application / src / frontend.ts View on Github external
constructor(options: JupyterFrontEnd.IOptions) {
    super(options);

    // The default restored promise if one does not exist in the options.
    const restored = new Promise(resolve => {
      requestAnimationFrame(() => {
        resolve();
      });
    });

    this.commandLinker =
      options.commandLinker || new CommandLinker({ commands: this.commands });
    this.docRegistry = options.docRegistry || new DocumentRegistry();
    this.restored =
      options.restored ||
      this.started.then(() => restored).catch(() => restored);
    this.serviceManager = options.serviceManager || new ServiceManager();

    this.commands.addCommand(Private.CONTEXT_MENU_INFO, {
      label: 'Shift+Right Click for Browser Menu',
      isEnabled: () => false,
      execute: () => void 0
    });

    this.contextMenu.addItem({
      command: Private.CONTEXT_MENU_INFO,
      selector: 'body',
      rank: Infinity
github jupyterlab / jupyterlab / packages / application / src / index.ts View on Github external
this._busySignal = new Signal(this);
    this._dirtySignal = new Signal(this);

    // Construct the default workspace name.
    const defaultWorkspace = URLExt.join(
      PageConfig.getOption('baseUrl'),
      PageConfig.getOption('pageUrl')
    );

    // Set default workspace in page config.
    PageConfig.setOption('defaultWorkspace', defaultWorkspace);

    // Instantiate public resources.
    this.serviceManager = options.serviceManager || new ServiceManager();
    this.commandLinker =
      options.commandLinker || new CommandLinker({ commands: this.commands });
    this.docRegistry = options.docRegistry || new DocumentRegistry();

    // Remove extra resources (non-IInfo) from options object.
    delete options.serviceManager;
    delete options.commandLinker;
    delete options.docRegistry;

    // Populate application info.
    this._info = {
      ...JupyterLab.defaultInfo,
      ...(options as Partial),
      ...{ defaultWorkspace }
    };

    if (this._info.devMode) {
      this.shell.addClass('jp-mod-devMode');
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / application / src / frontend.ts View on Github external
constructor(options: JupyterFrontEnd.IOptions) {
    super(options);

    // The default restored promise if one does not exist in the options.
    const restored = new Promise(resolve => {
      requestAnimationFrame(() => {
        resolve();
      });
    });

    this.commandLinker =
      options.commandLinker || new CommandLinker({ commands: this.commands });
    this.docRegistry = options.docRegistry || new DocumentRegistry();
    this.restored =
      options.restored ||
      this.started.then(() => restored).catch(() => restored);
    this.serviceManager = options.serviceManager || new ServiceManager();

    this.commands.addCommand(Private.CONTEXT_MENU_INFO, {
      label: 'Shift+Right Click for Browser Menu',
      isEnabled: () => false,
      execute: () => void 0
    });

    this.contextMenu.addItem({
      command: Private.CONTEXT_MENU_INFO,
      selector: 'body',
      rank: Infinity
github jupyterlab / jupyterlab / tests / test-apputils / src / commandlinker.spec.ts View on Github external
it('should connect a node to a command', () => {
        let called = false;
        const command = 'commandlinker:connect-node';
        const commands = new CommandRegistry();
        const linker = new CommandLinker({ commands });
        let node: HTMLElement;
        let vnode: VirtualNode;
        const disposable = commands.addCommand(command, {
          execute: () => {
            called = true;
          }
        });

        vnode = h.div({
          dataset: linker.populateVNodeDataset(command, undefined)
        });
        node = VirtualDOM.realize(vnode);
        document.body.appendChild(node);

        expect(called).to.equal(false);
        simulate(node, 'click');
github jupyterlab / jupyterlab-data-explorer / tests / test-apputils / src / commandlinker.spec.ts View on Github external
it('should test whether a command linker has been disposed', () => {
        const linker = new CommandLinker({ commands: new CommandRegistry() });
        expect(linker.isDisposed).to.equal(false);
        linker.dispose();
        expect(linker.isDisposed).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / commandlinker.spec.ts View on Github external
it('should connect a node to a command', () => {
        let called = false;
        const command = 'commandlinker:connect-node';
        const commands = new CommandRegistry();
        const linker = new CommandLinker({ commands });
        const node = document.createElement('div');
        const disposable = commands.addCommand(command, {
          execute: () => {
            called = true;
          }
        });

        document.body.appendChild(node);
        linker.connectNode(node, command, undefined);

        expect(called).to.equal(false);
        simulate(node, 'click');
        expect(called).to.equal(true);

        document.body.removeChild(node);
        linker.dispose();
github jupyterlab / jupyterlab / tests / test-apputils / src / commandlinker.spec.ts View on Github external
it('should test whether a command linker has been disposed', () => {
        const linker = new CommandLinker({ commands: new CommandRegistry() });
        expect(linker.isDisposed).to.equal(false);
        linker.dispose();
        expect(linker.isDisposed).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / commandlinker.spec.ts View on Github external
it('should create a command linker', () => {
        const linker = new CommandLinker({ commands: new CommandRegistry() });
        expect(linker).to.be.an.instanceof(CommandLinker);
        linker.dispose();
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-apputils / src / commandlinker.spec.ts View on Github external
it('should create a command linker', () => {
        const linker = new CommandLinker({ commands: new CommandRegistry() });
        expect(linker).to.be.an.instanceof(CommandLinker);
        linker.dispose();
      });
    });