當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。