How to use the @jupyterlab/notebook.NotebookActions.changeCellType function in @jupyterlab/notebook

To help you get started, we’ve selected a few @jupyterlab/notebook 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-notebook / src / actions.spec.ts View on Github external
it('should change the selected cell type(s)', () => {
        let next = widget.widgets[1];
        widget.select(next);
        NotebookActions.changeCellType(widget, 'raw');
        expect(widget.activeCell).to.be.an.instanceof(RawCell);
        next = widget.widgets[widget.activeCellIndex + 1];
        expect(next).to.be.an.instanceof(RawCell);
      });
github jupyterlab / jupyterlab / tests / test-notebook / src / actions.spec.ts View on Github external
it('should preserve the types of each cell', () => {
        NotebookActions.changeCellType(widget, 'markdown');
        NotebookActions.splitCell(widget);
        expect(widget.activeCell).to.be.an.instanceof(MarkdownCell);
        const prev = widget.widgets[0];
        expect(prev).to.be.an.instanceof(MarkdownCell);
      });
github jupyterlab / jupyterlab / tests / test-notebook / src / notebooktools.spec.ts View on Github external
it('should create a raw mimetype selector', () => {
        let optionsMap: { [key: string]: JSONValue } = {
          None: '-',
          LaTeX: 'text/latex',
          reST: 'text/restructuredtext',
          HTML: 'text/html',
          Markdown: 'text/markdown',
          Python: 'text/x-python'
        };
        optionsMap.None = '-';
        const tool = NotebookTools.createNBConvertSelector(optionsMap);
        tool.selectNode.selectedIndex = -1;
        notebookTools.addItem({ tool });
        simulate(panel0.node, 'focus');
        NotebookActions.changeCellType(panel0.content, 'raw');
        tabpanel.currentIndex = 2;
        expect(tool).to.be.an.instanceof(NotebookTools.KeySelector);
        expect(tool.key).to.equal('raw_mimetype');
        const select = tool.selectNode;
        expect(select.value).to.equal('');

        const metadata = notebookTools.activeCell!.model.metadata;
        expect(metadata.get('raw_mimetype')).to.be.undefined;
        simulate(select, 'focus');
        tool.selectNode.selectedIndex = 2;
        simulate(select, 'change');
        expect(metadata.get('raw_mimetype')).to.equal('text/restructuredtext');
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-notebook / src / actions.spec.ts View on Github external
it('should change the selected cell type(s)', () => {
        let next = widget.widgets[1];
        widget.select(next);
        NotebookActions.changeCellType(widget, 'raw');
        expect(widget.activeCell).to.be.an.instanceof(RawCell);
        next = widget.widgets[widget.activeCellIndex + 1];
        expect(next).to.be.an.instanceof(RawCell);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-notebook / src / notebooktools.spec.ts View on Github external
it('should create a raw mimetype selector', () => {
        let optionsMap: { [key: string]: JSONValue } = {
          None: '-',
          LaTeX: 'text/latex',
          reST: 'text/restructuredtext',
          HTML: 'text/html',
          Markdown: 'text/markdown',
          Python: 'text/x-python'
        };
        optionsMap.None = '-';
        const tool = NotebookTools.createNBConvertSelector(optionsMap);
        tool.selectNode.selectedIndex = -1;
        notebookTools.addItem({ tool });
        simulate(panel0.node, 'focus');
        NotebookActions.changeCellType(panel0.content, 'raw');
        tabpanel.currentIndex = 2;
        expect(tool).to.be.an.instanceof(NotebookTools.KeySelector);
        expect(tool.key).to.equal('raw_mimetype');
        const select = tool.selectNode;
        expect(select.value).to.equal('');

        const metadata = notebookTools.activeCell.model.metadata;
        expect(metadata.get('raw_mimetype')).to.be.undefined;
        simulate(select, 'focus');
        tool.selectNode.selectedIndex = 2;
        simulate(select, 'change');
        expect(metadata.get('raw_mimetype')).to.equal('text/restructuredtext');
      });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / notebook-extension / src / index.ts View on Github external
execute: args => {
      const current = getCurrent(args);

      if (current) {
        return NotebookActions.changeCellType(current.content, 'code');
      }
    },
    isEnabled
github spyder-ide / spyder-notebook / spyder_notebook / server / src / commands.ts View on Github external
    execute: () => NotebookActions.changeCellType(nbWidget.content, 'code')
  });
github jupyterlab / jupyterlab / packages / notebook-extension / src / index.ts View on Github external
execute: args => {
      const current = getCurrent(args);

      if (current) {
        return NotebookActions.changeCellType(current.notebook, 'markdown');
      }
    },
    isEnabled
github spyder-ide / spyder-notebook / spyder_notebook / server / src / commands.ts View on Github external
    execute: () => NotebookActions.changeCellType(nbWidget.content, 'markdown')
  });
github yuvipanda / simplest-notebook / packages / notebook-extension / src / index.ts View on Github external
execute: args => {
      const current = getCurrent(args);

      if (current) {
        return NotebookActions.changeCellType(current.notebook, 'code');
      }
    },
    isEnabled