Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(() => {
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;
}