How to use the @jupyterlab/cells.CodeCellModel function in @jupyterlab/cells

To help you get started, we’ve selected a few @jupyterlab/cells 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 / test / src / cells / model.spec.ts View on Github external
it('should be settable', () => {
        let model = new CodeCellModel({});
        expect(model.executionCount).to.be(null);
        model.executionCount = 1;
        expect(model.executionCount).to.be(1);
      });
github jupyterlab / jupyterlab / tests / test-cells / src / model.spec.ts View on Github external
it('should accept a code cell argument', () => {
        const cell: nbformat.ICodeCell = {
          cell_type: 'code',
          execution_count: 1,
          outputs: [
            {
              output_type: 'display_data',
              data: { 'text/plain': 'foo' },
              metadata: {}
            } as nbformat.IDisplayData
          ],
          source: 'foo',
          metadata: { trusted: false }
        };
        const model = new CodeCellModel({ cell });
        expect(model).to.be.an.instanceof(CodeCellModel);
        expect(model.value.text).to.equal(cell.source);
      });
github jupyterlab / jupyterlab / tests / test-cells / src / model.spec.ts View on Github external
it('should signal when model state has changed', () => {
        const model = new CodeCellModel({});
        let called = false;
        const listener = (sender: any, args: IChangedArgs) => {
          expect(args.newValue).to.equal(1);
          called = true;
        };
        model.stateChanged.connect(listener);
        model.executionCount = 1;
        expect(called).to.equal(true);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-cells / src / model.spec.ts View on Github external
it('should be an output area model', () => {
        const model = new CodeCellModel({});
        expect(model.outputs).to.be.an.instanceof(OutputAreaModel);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-cells / src / model.spec.ts View on Github external
it('should show the execution count of the cell', () => {
        const cell: nbformat.ICodeCell = {
          cell_type: 'code',
          execution_count: 1,
          outputs: [],
          source: 'foo',
          metadata: { trusted: false }
        };
        const model = new CodeCellModel({ cell });
        expect(model.executionCount).to.equal(1);
      });
github jupyterlab / jupyterlab / tests / test-cells / src / model.spec.ts View on Github external
it('should be an output area model', () => {
        const model = new CodeCellModel({});
        expect(model.outputs).to.be.an.instanceof(OutputAreaModel);
      });
    });
github jupyterlab / jupyterlab / test / src / cells / model.spec.ts View on Github external
it('should update the trusted state of the output models', () => {
        let model = new CodeCellModel({});
        model.outputs.add(DEFAULT_OUTPUTS[0]);
        expect(model.outputs.get(0).trusted).to.be(false);
        model.trusted = true;
        expect(model.outputs.get(0).trusted).to.be(true);
      });
github jupyterlab / jupyterlab / tests / test-cells / src / model.spec.ts View on Github external
cell_type: 'code',
          execution_count: 1,
          outputs: [
            {
              output_type: 'display_data',
              data: {
                'text/plain': 'foo',
                'application/json': { bar: 1 }
              },
              metadata: {}
            } as nbformat.IDisplayData
          ],
          source: 'foo',
          metadata: { trusted: false }
        };
        const model = new CodeCellModel({ cell });
        const serialized = model.toJSON();
        expect(serialized).to.not.equal(cell);
        expect(serialized).to.deep.equal(cell);
        const output = serialized.outputs[0] as any;
        expect(output.data['application/json']['bar']).to.equal(1);
      });
    });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / console / src / widget.ts View on Github external
createCodeCell(options: CodeCellModel.IOptions): ICodeCellModel {
      if (!options.contentFactory) {
        options.contentFactory = this.codeCellContentFactory;
      }
      return new CodeCellModel(options);
    }
github jupyterlab / jupyterlab / packages / notebook / src / model.ts View on Github external
createCodeCell(options: CodeCellModel.IOptions): ICodeCellModel {
      if (options.contentFactory) {
        options.contentFactory = this.codeCellContentFactory;
      }
      if (this.modelDB) {
        if (!options.id) {
          options.id = UUID.uuid4();
        }
        options.modelDB = this.modelDB.view(options.id);
      }
      return new CodeCellModel(options);
    }