mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
import: Reduce log spam from unsupported elements
This commit is contained in:
parent
09c349e2a1
commit
91e99c84ca
2 changed files with 19 additions and 8 deletions
|
@ -18,8 +18,11 @@
|
|||
|
||||
const db = require('../db/DB');
|
||||
const hooks = require('../../static/js/pluginfw/hooks');
|
||||
const log4js = require('log4js');
|
||||
const supportedElems = require('../../static/js/contentcollector').supportedElems;
|
||||
|
||||
const logger = log4js.getLogger('ImportEtherpad');
|
||||
|
||||
exports.setPadRaw = (padId, r) => {
|
||||
const records = JSON.parse(r);
|
||||
|
||||
|
@ -28,6 +31,8 @@ exports.setPadRaw = (padId, r) => {
|
|||
supportedElems.add(element);
|
||||
});
|
||||
|
||||
const unsupportedElements = new Set();
|
||||
|
||||
Object.keys(records).forEach(async (key) => {
|
||||
let value = records[key];
|
||||
|
||||
|
@ -64,10 +69,7 @@ exports.setPadRaw = (padId, r) => {
|
|||
if (value.pool) {
|
||||
for (const attrib of Object.keys(value.pool.numToAttrib)) {
|
||||
const attribName = value.pool.numToAttrib[attrib][0];
|
||||
if (!supportedElems.has(attribName)) {
|
||||
console.warn('Plugin missing: ' +
|
||||
`You might want to install a plugin to support this node name: ${attribName}`);
|
||||
}
|
||||
if (!supportedElems.has(attribName)) unsupportedElements.add(attribName);
|
||||
}
|
||||
}
|
||||
const oldPadId = key.split(':');
|
||||
|
@ -92,4 +94,9 @@ exports.setPadRaw = (padId, r) => {
|
|||
// Write the value to the server
|
||||
await db.set(newKey, value);
|
||||
});
|
||||
|
||||
if (unsupportedElements.size) {
|
||||
logger.warn('Ignoring unsupported elements (you might want to install a plugin): ' +
|
||||
`${[...unsupportedElements].join(', ')}`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -318,6 +318,7 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
|||
cc.incrementAttrib(state, na);
|
||||
};
|
||||
cc.collectContent = function (node, state) {
|
||||
let unsupportedElements = null;
|
||||
if (!state) {
|
||||
state = {
|
||||
flags: { /* name -> nesting counter*/
|
||||
|
@ -333,16 +334,15 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
|||
'list': 'bullet1',
|
||||
*/
|
||||
},
|
||||
unsupportedElements: new Set(),
|
||||
};
|
||||
unsupportedElements = state.unsupportedElements;
|
||||
}
|
||||
const localAttribs = state.localAttribs;
|
||||
state.localAttribs = null;
|
||||
const isBlock = isBlockElement(node);
|
||||
if (!isBlock && node.name && (node.name !== 'body')) {
|
||||
if (!supportedElems.has(node.name)) {
|
||||
console.warn('Plugin missing: ' +
|
||||
`You might want to install a plugin to support this node name: ${node.name}`);
|
||||
}
|
||||
if (!supportedElems.has(node.name)) state.unsupportedElements.add(node.name);
|
||||
}
|
||||
const isEmpty = _isEmpty(node, state);
|
||||
if (isBlock) _ensureColumnZero(state);
|
||||
|
@ -621,6 +621,10 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
|||
}
|
||||
}
|
||||
state.localAttribs = localAttribs;
|
||||
if (unsupportedElements && unsupportedElements.size) {
|
||||
console.warn('Ignoring unsupported elements (you might want to install a plugin): ' +
|
||||
`${[...unsupportedElements].join(', ')}`);
|
||||
}
|
||||
};
|
||||
// can pass a falsy value for end of doc
|
||||
cc.notifyNextNode = (node) => {
|
||||
|
|
Loading…
Reference in a new issue