How to use nbdime - 10 common examples

To help you get started, we’ve selected a few nbdime 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 jupyter / nbdime / packages / webapp / src / app / diff.ts View on Github external
function showDiff(data: {base: nbformat.INotebookContent, diff: IDiffEntry[]}): Promise {


  let rendermime = new RenderMimeRegistry({
    initialFactories: rendererFactories,
    sanitizer: defaultSanitizer,
    latexTypesetter: new MathJaxTypesetter({
      url: getConfigOption('mathjaxUrl'),
      config: getConfigOption('mathjaxConfig'),
    }),
  });

  let nbdModel = new NotebookDiffModel(data.base, data.diff);
  let nbdWidget = new NotebookDiffWidget(nbdModel, rendermime);

  let root = document.getElementById('nbdime-root');
  if (!root) {
    throw new Error('Missing root element "nbidme-root"');
  }
  root.innerHTML = '';
  // Hide unchanged cells by default:
  toggleShowUnchanged(!getConfigOption('hideUnchanged', true));

  let panel = new Panel();
  panel.id = 'main';
  Widget.attach(panel, root);
  panel.addWidget(nbdWidget);
  let work = nbdWidget.init();
  work.then(() => {
github jupyter / nbdime / packages / webapp / src / app / diff.ts View on Github external
function showDiff(data: {base: nbformat.INotebookContent, diff: IDiffEntry[]}): Promise {


  let rendermime = new RenderMimeRegistry({
    initialFactories: rendererFactories,
    sanitizer: defaultSanitizer,
    latexTypesetter: new MathJaxTypesetter({
      url: getConfigOption('mathjaxUrl'),
      config: getConfigOption('mathjaxConfig'),
    }),
  });

  let nbdModel = new NotebookDiffModel(data.base, data.diff);
  let nbdWidget = new NotebookDiffWidget(nbdModel, rendermime);

  let root = document.getElementById('nbdime-root');
  if (!root) {
    throw new Error('Missing root element "nbidme-root"');
  }
  root.innerHTML = '';
  // Hide unchanged cells by default:
  toggleShowUnchanged(!getConfigOption('hideUnchanged', true));

  let panel = new Panel();
  panel.id = 'main';
  Widget.attach(panel, root);
  panel.addWidget(nbdWidget);
  let work = nbdWidget.init();
  work.then(() => {
    window.onresize = () => { panel.update(); };
github jupyter / nbdime / packages / webapp / src / app / merge.ts View on Github external
function showMerge(data: {
    base: nbformat.INotebookContent,
    merge_decisions: IMergeDecision[]
    }): Promise {

  let rendermime = new RenderMimeRegistry({
    initialFactories: rendererFactories,
    sanitizer: defaultSanitizer,
  });

  let nbmModel = new NotebookMergeModel(data.base,
      data.merge_decisions);
  let nbmWidget = new NotebookMergeWidget(nbmModel, rendermime);

  let root = document.getElementById('nbdime-root');
  if (!root) {
    throw new Error('Missing root element "nbidme-root"');
  }
  root.innerHTML = '';
  // Hide unchanged cells by default:
  toggleShowUnchanged(!getConfigOption('hideUnchanged', true));

  let panel = new Panel();
  panel.id = 'main';
  Widget.attach(panel, root);
  panel.addWidget(nbmWidget);
  let work = nbmWidget.init();
github jupyter / nbdime / packages / webapp / src / app / merge.ts View on Github external
function showMerge(data: {
    base: nbformat.INotebookContent,
    merge_decisions: IMergeDecision[]
    }): Promise {

  let rendermime = new RenderMimeRegistry({
    initialFactories: rendererFactories,
    sanitizer: defaultSanitizer,
  });

  let nbmModel = new NotebookMergeModel(data.base,
      data.merge_decisions);
  let nbmWidget = new NotebookMergeWidget(nbmModel, rendermime);

  let root = document.getElementById('nbdime-root');
  if (!root) {
    throw new Error('Missing root element "nbidme-root"');
  }
  root.innerHTML = '';
  // Hide unchanged cells by default:
  toggleShowUnchanged(!getConfigOption('hideUnchanged', true));

  let panel = new Panel();
  panel.id = 'main';
  Widget.attach(panel, root);
  panel.addWidget(nbmWidget);
  let work = nbmWidget.init();
  work.then(() => {
    window.onresize = () => { panel.update(); };
github jupyter / nbdime / packages / webapp / src / app / staticdiff.ts View on Github external
function ensureRendered(callback: () => void): void {
  for (let e of EditorWidget.editors) {
    e.setOption('viewportMargin', Infinity);
  }
  window.requestAnimationFrame(() => {
    // Assume entire viewport has been rendered now
    callback();
    for (let e of EditorWidget.editors) {
      // Reset to default according to docs
      e.setOption('viewportMargin', 10);
    }
  });
}
github jupyter / nbdime / packages / webapp / src / app / staticdiff.ts View on Github external
window.requestAnimationFrame(() => {
    // Assume entire viewport has been rendered now
    callback();
    for (let e of EditorWidget.editors) {
      // Reset to default according to docs
      e.setOption('viewportMargin', 10);
    }
  });
}
github jupyter / nbdime / packages / labextension / src / widget.ts View on Github external
protected onData(data: JSONObject) {
    if (this.isDisposed) {
      return;
    }
    let base = data['base'] as nbformat.INotebookContent;
    let diff = data['diff'] as any as IDiffEntry[];
    let nbdModel = new NotebookDiffModel(base, diff);
    let nbdWidget = new NotebookDiffWidget(nbdModel, this.rendermime);

    this.scroller.addWidget(nbdWidget);
    let work = nbdWidget.init();
    work.then(() => {
      Private.markUnchangedRanges(this.scroller.node);
    })
    return work;
  }
github jupyter / nbdime / packages / labextension / src / widget.ts View on Github external
protected onData(data: JSONObject) {
    if (this.isDisposed) {
      return;
    }
    let base = data['base'] as nbformat.INotebookContent;
    let diff = data['diff'] as any as IDiffEntry[];
    let nbdModel = new NotebookDiffModel(base, diff);
    let nbdWidget = new NotebookDiffWidget(nbdModel, this.rendermime);

    this.scroller.addWidget(nbdWidget);
    let work = nbdWidget.init();
    work.then(() => {
      Private.markUnchangedRanges(this.scroller.node);
    })
    return work;
  }
github jupyter / nbdime / packages / webapp / src / app / diff.ts View on Github external
function getDiff(base: string, remote: string | undefined) {
  let baseUrl = getBaseUrl();
  requestDiff(base, remote, baseUrl, onDiffRequestCompleted, onDiffRequestFailed);
}
github jupyter / nbdime / packages / webapp / src / app / merge.ts View on Github external
function getMerge(base: string, local: string, remote: string) {
  let baseUrl = getBaseUrl();
  requestMerge(base, local, remote, baseUrl, onMergeRequestCompleted, onMergeRequestFailed);
}