Add: matain the order of lint report for section editor
This commit is contained in:
parent
d57c327955
commit
30fb084d4d
|
@ -3,16 +3,33 @@
|
||||||
|
|
||||||
var linterReport = (() => { // eslint-disable-line no-var
|
var linterReport = (() => { // eslint-disable-line no-var
|
||||||
const cms = new Map();
|
const cms = new Map();
|
||||||
|
|
||||||
linter.onChange((annotationsNotSorted, annotations, cm) => {
|
linter.onChange((annotationsNotSorted, annotations, cm) => {
|
||||||
if (!cms.has(cm)) {
|
let table = cms.get(cm);
|
||||||
cms.set(cm, createTable(cm));
|
if (!table) {
|
||||||
|
table = createTable(cm);
|
||||||
|
cms.set(cm, table);
|
||||||
|
const container = $('.lint-report-container');
|
||||||
|
if (typeof editor !== 'object') {
|
||||||
|
container.append(table.element);
|
||||||
|
} else {
|
||||||
|
const nextSibling = findNextSibling(cms, cm);
|
||||||
|
container.insertBefore(table.element, nextSibling && cms.get(nextSibling).element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const table = cms.get(cm);
|
|
||||||
table.update();
|
table.update();
|
||||||
table.updateAnnotations(annotations);
|
table.updateAnnotations(annotations);
|
||||||
|
|
||||||
$('#lint').classList.toggle('hidden', Array.from(cms.values()).every(t => t.isEmpty()));
|
$('#lint').classList.toggle('hidden', Array.from(cms.values()).every(t => t.isEmpty()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
linter.onUnhook(cm => {
|
||||||
|
const table = cms.get(cm);
|
||||||
|
if (table) {
|
||||||
|
table.element.remove();
|
||||||
|
cms.delete(cm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// document.addEventListener('DOMContentLoaded', () => {
|
// document.addEventListener('DOMContentLoaded', () => {
|
||||||
// $('#lint-help').addEventListener('click', showLintHelp);
|
// $('#lint-help').addEventListener('click', showLintHelp);
|
||||||
// $('#lint').addEventListener('click', gotoLintIssue);
|
// $('#lint').addEventListener('click', gotoLintIssue);
|
||||||
|
@ -20,17 +37,25 @@ var linterReport = (() => { // eslint-disable-line no-var
|
||||||
// }, {once: true});
|
// }, {once: true});
|
||||||
return {refresh};
|
return {refresh};
|
||||||
|
|
||||||
|
function findNextSibling(cms, cm) {
|
||||||
|
let i = editors.indexOf(cm) + 1;
|
||||||
|
while (i < editors.length) {
|
||||||
|
if (cms.has(editors[i])) {
|
||||||
|
return editors[i];
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function refresh() {}
|
function refresh() {}
|
||||||
|
|
||||||
function createTable(cm) {
|
function createTable(cm) {
|
||||||
const container = $('.lint-report-container');
|
|
||||||
const caption = $create('caption');
|
const caption = $create('caption');
|
||||||
const tbody = $create('tbody');
|
const tbody = $create('tbody');
|
||||||
const table = $create('table', [caption, tbody]);
|
const table = $create('table', [caption, tbody]);
|
||||||
const trs = [];
|
const trs = [];
|
||||||
let empty = true;
|
let empty = true;
|
||||||
container.append(table);
|
return {updateAnnotations, update, isEmpty, element: table};
|
||||||
return {updateAnnotations, update, isEmpty};
|
|
||||||
|
|
||||||
function isEmpty() {
|
function isEmpty() {
|
||||||
return empty;
|
return empty;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user