monocart-code-viewer
v1.1.4
Published
Monocart Code Viewer
Downloads
168,489
Readme
monocart-code-viewer
Feature
- Base on CodeMirror
- Coverage View
Install
npm i monocart-code-viewer
Usage
import { createCodeViewer } from 'monocart-code-viewer';
let codeViewer;
const report = {
content: "your source content",
coverage: {
uncoveredLines: {
'0': 'comment',
'1': 'blank',
'8': 'partial',
'9': 'uncovered'
},
uncoveredPieces: {
'8': [
{
'start': 27,
'end': 34
}
]
},
decorations: {
'14': [
{
'column': 4,
'value': 'E',
'attrs': {
'title': 'else path uncovered'
}
}
]
},
executionCounts: {
'20': [
{
'column': 22,
'count': 10,
'value': '10',
'end': 916
}
]
}
}
};
if (codeViewer) {
codeViewer.update(report);
} else {
codeViewer = createCodeViewer($el, report);
codeViewer.on('cursor', (loc) => {
// console.log('cursor', loc);
});
// codeViewer.setSelection(start, end, options);
// codeViewer.setCursor(pos, options);
}