当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript notebook.NotebookPanel类代码示例

本文整理汇总了TypeScript中@jupyterlab/notebook.NotebookPanel的典型用法代码示例。如果您正苦于以下问题:TypeScript NotebookPanel类的具体用法?TypeScript NotebookPanel怎么用?TypeScript NotebookPanel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NotebookPanel类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

  describe('ToolbarItems', () => {
    let context: Context<INotebookModel>;
    let panel: NotebookPanel;

    beforeEach(async () => {
      context = await createNotebookContext();
      await context.initialize(true);
      panel = createNotebookPanel(context);
      context.model.fromJSON(DEFAULT_CONTENT);
    });

    afterEach(async () => {
      await context.session.shutdown();
      context.dispose();
      panel.dispose();
    });

    describe('#createSaveButton()', () => {
      it('should save when clicked', done => {
        let button = ToolbarItems.createSaveButton(panel);
        Widget.attach(button, document.body);
        context.fileChanged.connect(() => {
          button.dispose();
          done();
        });
        button.node.click();
      });

      it("should have the `'jp-SaveIcon'` class", () => {
        let button = ToolbarItems.createSaveButton(panel);
        expect(button.hasClass('jp-SaveIcon')).to.be(true);
      });
    });

    describe('#createInsertButton()', () => {
      it('should insert below when clicked', () => {
        let button = ToolbarItems.createInsertButton(panel);
        Widget.attach(button, document.body);
        button.node.click();
        expect(panel.content.activeCellIndex).to.be(1);
        expect(panel.content.activeCell).to.be.a(CodeCell);
        button.dispose();
      });

      it("should have the `'jp-AddIcon'` class", () => {
        let button = ToolbarItems.createInsertButton(panel);
        expect(button.hasClass('jp-AddIcon')).to.be(true);
      });
    });

    describe('#createCutButton()', () => {
      it('should cut when clicked', () => {
        let button = ToolbarItems.createCutButton(panel);
        let count = panel.content.widgets.length;
        Widget.attach(button, document.body);
        button.node.click();
        expect(panel.content.widgets.length).to.be(count - 1);
        expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
        button.dispose();
      });

      it("should have the `'jp-CutIcon'` class", () => {
        let button = ToolbarItems.createCutButton(panel);
        expect(button.hasClass('jp-CutIcon')).to.be(true);
      });
    });

    describe('#createCopyButton()', () => {
      it('should copy when clicked', () => {
        let button = ToolbarItems.createCopyButton(panel);
        let count = panel.content.widgets.length;
        Widget.attach(button, document.body);
        button.node.click();
        expect(panel.content.widgets.length).to.be(count);
        expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
        button.dispose();
      });

      it("should have the `'jp-CopyIcon'` class", () => {
        let button = ToolbarItems.createCopyButton(panel);
        expect(button.hasClass('jp-CopyIcon')).to.be(true);
      });
    });

    describe('#createPasteButton()', () => {
      it('should paste when clicked', async () => {
        let button = ToolbarItems.createPasteButton(panel);
        let count = panel.content.widgets.length;
        Widget.attach(button, document.body);
        NotebookActions.copy(panel.content);
        button.node.click();
        await sleep();
        expect(panel.content.widgets.length).to.be(count + 1);
        button.dispose();
      });

      it("should have the `'jp-PasteIcon'` class", () => {
        let button = ToolbarItems.createPasteButton(panel);
        expect(button.hasClass('jp-PasteIcon')).to.be(true);
      });
//.........这里部分代码省略.........
开发者ID:dalejung,项目名称:jupyterlab,代码行数:101,代码来源:default-toolbar.spec.ts

示例2: describe

  describe('ToolbarItems', () => {

    let panel: NotebookPanel;
    const contentFactory = createNotebookPanelFactory();

    beforeEach(() => {
      panel = new NotebookPanel({ rendermime, contentFactory,
                                  mimeTypeService });
      context.model.fromJSON(DEFAULT_CONTENT);
      panel.context = context;
    });

    afterEach(() => {
      panel.dispose();
    });

    describe('#createSaveButton()', () => {

      it('should save when clicked', (done) => {
        let button = ToolbarItems.createSaveButton(panel);
        Widget.attach(button, document.body);
        context.fileChanged.connect(() => {
          button.dispose();
          done();
        });
        button.node.click();
      });

      it('should have the `\'jp-SaveIcon\'` class', () => {
        let button = ToolbarItems.createSaveButton(panel);
        expect(button.hasClass('jp-SaveIcon')).to.be(true);
      });

    });

    describe('#createInsertButton()', () => {

      it('should insert below when clicked', () => {
        let button = ToolbarItems.createInsertButton(panel);
        Widget.attach(button, document.body);
        button.node.click();
        expect(panel.notebook.activeCellIndex).to.be(1);
        expect(panel.notebook.activeCell).to.be.a(CodeCell);
        button.dispose();
      });

      it('should have the `\'jp-AddIcon\'` class', () => {
        let button = ToolbarItems.createInsertButton(panel);
        expect(button.hasClass('jp-AddIcon')).to.be(true);
      });

    });

    describe('#createCutButton()', () => {

      it('should cut when clicked', () => {
        let button = ToolbarItems.createCutButton(panel);
        let count = panel.notebook.widgets.length;
        Widget.attach(button, document.body);
        button.node.click();
        expect(panel.notebook.widgets.length).to.be(count - 1);
        expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
        button.dispose();
      });

      it('should have the `\'jp-CutIcon\'` class', () => {
        let button = ToolbarItems.createCutButton(panel);
        expect(button.hasClass('jp-CutIcon')).to.be(true);
      });

    });

    describe('#createCopyButton()', () => {

      it('should copy when clicked', () => {
        let button = ToolbarItems.createCopyButton(panel);
        let count = panel.notebook.widgets.length;
        Widget.attach(button, document.body);
        button.node.click();
        expect(panel.notebook.widgets.length).to.be(count);
        expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
        button.dispose();
      });

      it('should have the `\'jp-CopyIcon\'` class', () => {
        let button = ToolbarItems.createCopyButton(panel);
        expect(button.hasClass('jp-CopyIcon')).to.be(true);
      });

    });

    describe('#createPasteButton()', () => {

      it('should paste when clicked', (done) => {
        let button = ToolbarItems.createPasteButton(panel);
        let count = panel.notebook.widgets.length;
        Widget.attach(button, document.body);
        NotebookActions.copy(panel.notebook);
        button.node.click();
        requestAnimationFrame(() => {
//.........这里部分代码省略.........
开发者ID:eskirk,项目名称:jupyterlab,代码行数:101,代码来源:default-toolbar.spec.ts

示例3:

 .then(() => { current.dispose(); });
开发者ID:SimonBiggs,项目名称:jupyterlab,代码行数:1,代码来源:index.ts

示例4: afterEach

 afterEach(async () => {
   await context.session.shutdown();
   context.dispose();
   panel.dispose();
 });
开发者ID:dalejung,项目名称:jupyterlab,代码行数:5,代码来源:default-toolbar.spec.ts

示例5: afterEach

 afterEach(() => {
   panel.dispose();
 });
开发者ID:eskirk,项目名称:jupyterlab,代码行数:3,代码来源:default-toolbar.spec.ts

示例6:

 return current.context.session.shutdown().then(() => {
   current.dispose();
 });
开发者ID:dalejung,项目名称:jupyterlab,代码行数:3,代码来源:index.ts


注:本文中的@jupyterlab/notebook.NotebookPanel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。