How to use the @jupyterlab/rendermime.OutputModel function in @jupyterlab/rendermime

To help you get started, we’ve selected a few @jupyterlab/rendermime 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-rendermime / src / outputmodel.spec.ts View on Github external
it('should create a new output model', () => {
        const value = DEFAULT_EXECUTE;
        let model = new OutputModel({ value });
        expect(model).to.be.an.instanceof(OutputModel);
        model = new OutputModel({ value, trusted: true });
        expect(model).to.be.an.instanceof(OutputModel);
      });
    });
github jupyterlab / jupyterlab / tests / test-rendermime / src / outputmodel.spec.ts View on Github external
it('should yield the raw value', () => {
        const model = new OutputModel({ value: DEFAULT_EXECUTE });
        expect(model.toJSON()).to.deep.equal(DEFAULT_EXECUTE);
      });
    });
github jupyterlab / jupyterlab / tests / test-rendermime / src / outputmodel.spec.ts View on Github external
it('should be the output type', () => {
        let model = new OutputModel({ value: DEFAULT_EXECUTE });
        expect(model.type).to.equal(DEFAULT_EXECUTE.output_type);
        model = new OutputModel({ value: DEFAULT_STREAM });
        expect(model.type).to.equal(DEFAULT_STREAM.output_type);
      });
    });
github jupyterlab / jupyterlab / tests / test-rendermime / src / outputmodel.spec.ts View on Github external
it('should be the output type', () => {
        let model = new OutputModel({ value: DEFAULT_EXECUTE });
        expect(model.type).to.equal(DEFAULT_EXECUTE.output_type);
        model = new OutputModel({ value: DEFAULT_STREAM });
        expect(model.type).to.equal(DEFAULT_STREAM.output_type);
      });
    });
github jupyterlab / jupyterlab / tests / test-rendermime / src / outputmodel.spec.ts View on Github external
it('should be the execution count of an execution result', () => {
        const model = new OutputModel({ value: DEFAULT_EXECUTE });
        expect(model.executionCount).to.equal(1);
      });
github jupyter / nbdime / packages / nbdime / src / diff / widget / output.ts View on Github external
static isTrustSignificant(model: OutputDiffModel, rendermime: IRenderMimeRegistry): boolean {
    if (model.trusted) {
      return false;
    }
    let toTest: nbformat.IOutput[] = [];
    if (model.base) {
      toTest.push(model.base);
    }
    if (model.remote && model.remote !== model.base) {
      toTest.push(model.remote);
    }
    for (let o of toTest) {
      let untrustedModel = new OutputModel({value: o, trusted: false});
      let modelMimeTypes = Object.keys(untrustedModel.data);
      let rendererMimeTypes = toArray(rendermime.mimeTypes);
      let candidates = intersection(modelMimeTypes, rendererMimeTypes);
      for (let mimeType of candidates) {
        let factory = rendermime.getFactory(mimeType);
        if (factory && (!factory.safe || sanitizable.indexOf(mimeType) !== -1)) {
          return true;
        }
      }
    }
    return false;
  }
}
github jupyterlab / jupyterlab / packages / outputarea / src / model.ts View on Github external
createOutputModel(options: IOutputModel.IOptions): IOutputModel {
      return new OutputModel(options);
    }
  }
github jupyter / nbdime / packages / nbdime / src / diff / widget / output.ts View on Github external
protected createRenderer(output: nbformat.IOutput, trusted: boolean, mimetype: string): IRenderMime.IRenderer {
    let model = new OutputModel({value: output, trusted});
    let widget = this.rendermime.createRenderer(mimetype);
    widget.renderModel(model);
    widget.addClass(RENDERED_OUTPUT_CLASS);
    let bundle = OutputModel.getData(output);
    if (isBase64(bundle[mimetype] as string)) {
      widget.addClass(DATA_IS_BASE64_CLASS);
    }
    return widget;
  }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / outputarea / src / model.ts View on Github external
createOutputModel(options: IOutputModel.IOptions): IOutputModel {
      return new OutputModel(options);
    }
  }