in src/widgets/slicedcell/widget.ts [78:122]
constructor(options: SlicedCell.IOptions) {
super(options);
this.addClass(DIFFED_SLICED_CELL_CLASS);
let codeMirrorDoc: CodeMirror.Doc = this.editor.getDoc();
// Mark up differences
for (let beforeLine of this.model.diff.beforeLines) {
this.editor.addLineClass(
beforeLine - 1,
'background',
DIFFED_CELL_BEFORE_BACKGROUND_CLASS
);
this.editor.addLineClass(
beforeLine - 1,
'wrap',
DIFFED_CELL_BEFORE_TEXT_CLASS
);
}
for (let afterLine of this.model.diff.afterLines) {
this.editor.addLineClass(
afterLine - 1,
'background',
DIFFED_CELL_AFTER_TEXT_CLASS
);
}
for (let loc of this.model.diff.changeLocations) {
codeMirrorDoc.markText(
{ line: loc.first_line - 1, ch: loc.first_column },
{ line: loc.last_line - 1, ch: loc.last_column },
{ className: DIFFED_CELL_CHANGED_TEXT_CLASS }
);
let versionClass;
if (this.model.diff.beforeLines.indexOf(loc.first_line) !== -1) {
versionClass = DIFFED_CELL_BEFORE_TEXT_CLASS;
} else if (this.model.diff.afterLines.indexOf(loc.first_line) !== -1) {
versionClass = DIFFED_CELL_AFTER_TEXT_CLASS;
}
codeMirrorDoc.markText(
{ line: loc.first_line - 1, ch: loc.first_column },
{ line: loc.last_line - 1, ch: loc.last_column },
{ className: versionClass }
);
}
}