Fix: cms -> tables
This commit is contained in:
parent
09bd6218e0
commit
b3c36fc717
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
// eslint-disable-next-line no-var
|
// eslint-disable-next-line no-var
|
||||||
Object.assign(linter, (() => {
|
Object.assign(linter, (() => {
|
||||||
const cms = new Map();
|
const tables = new Map();
|
||||||
const helpDialog = createLinterHelpDialog(getIssues);
|
const helpDialog = createLinterHelpDialog(getIssues);
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
@ -11,16 +11,16 @@ Object.assign(linter, (() => {
|
||||||
}, {once: true});
|
}, {once: true});
|
||||||
|
|
||||||
linter.onLintingUpdated((annotationsNotSorted, annotations, cm) => {
|
linter.onLintingUpdated((annotationsNotSorted, annotations, cm) => {
|
||||||
let table = cms.get(cm);
|
let table = tables.get(cm);
|
||||||
if (!table) {
|
if (!table) {
|
||||||
table = createTable(cm);
|
table = createTable(cm);
|
||||||
cms.set(cm, table);
|
tables.set(cm, table);
|
||||||
const container = $('.lint-report-container');
|
const container = $('.lint-report-container');
|
||||||
if (typeof editor === 'object') {
|
if (typeof editor === 'object') {
|
||||||
container.append(table.element);
|
container.append(table.element);
|
||||||
} else {
|
} else {
|
||||||
const nextSibling = findNextSibling(cms, cm);
|
const nextSibling = findNextSibling(tables, cm);
|
||||||
container.insertBefore(table.element, nextSibling && cms.get(nextSibling).element);
|
container.insertBefore(table.element, nextSibling && tables.get(nextSibling).element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.updateCaption();
|
table.updateCaption();
|
||||||
|
@ -29,10 +29,10 @@ Object.assign(linter, (() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
linter.onUnhook(cm => {
|
linter.onUnhook(cm => {
|
||||||
const table = cms.get(cm);
|
const table = tables.get(cm);
|
||||||
if (table) {
|
if (table) {
|
||||||
table.element.remove();
|
table.element.remove();
|
||||||
cms.delete(cm);
|
tables.delete(cm);
|
||||||
}
|
}
|
||||||
updateCount();
|
updateCount();
|
||||||
});
|
});
|
||||||
|
@ -40,7 +40,7 @@ Object.assign(linter, (() => {
|
||||||
return {refreshReport};
|
return {refreshReport};
|
||||||
|
|
||||||
function updateCount() {
|
function updateCount() {
|
||||||
const issueCount = Array.from(cms.values())
|
const issueCount = Array.from(tables.values())
|
||||||
.reduce((sum, table) => sum + table.trs.length, 0);
|
.reduce((sum, table) => sum + table.trs.length, 0);
|
||||||
$('#lint').classList.toggle('hidden', issueCount === 0);
|
$('#lint').classList.toggle('hidden', issueCount === 0);
|
||||||
$('#issue-count').textContent = issueCount;
|
$('#issue-count').textContent = issueCount;
|
||||||
|
@ -48,7 +48,7 @@ Object.assign(linter, (() => {
|
||||||
|
|
||||||
function getIssues() {
|
function getIssues() {
|
||||||
const issues = new Set();
|
const issues = new Set();
|
||||||
for (const table of cms.values()) {
|
for (const table of tables.values()) {
|
||||||
for (const tr of table.trs) {
|
for (const tr of table.trs) {
|
||||||
issues.add(tr.getAnnotation());
|
issues.add(tr.getAnnotation());
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,10 @@ Object.assign(linter, (() => {
|
||||||
return issues;
|
return issues;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findNextSibling(cms, cm) {
|
function findNextSibling(tables, cm) {
|
||||||
let i = editors.indexOf(cm) + 1;
|
let i = editors.indexOf(cm) + 1;
|
||||||
while (i < editors.length) {
|
while (i < editors.length) {
|
||||||
if (cms.has(editors[i])) {
|
if (tables.has(editors[i])) {
|
||||||
return editors[i];
|
return editors[i];
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -67,7 +67,7 @@ Object.assign(linter, (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshReport() {
|
function refreshReport() {
|
||||||
for (const table of cms.values()) {
|
for (const table of tables.values()) {
|
||||||
table.updateCaption();
|
table.updateCaption();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user