mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +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 db = require('../db/DB');
|
||||||
const hooks = require('../../static/js/pluginfw/hooks');
|
const hooks = require('../../static/js/pluginfw/hooks');
|
||||||
|
const log4js = require('log4js');
|
||||||
const supportedElems = require('../../static/js/contentcollector').supportedElems;
|
const supportedElems = require('../../static/js/contentcollector').supportedElems;
|
||||||
|
|
||||||
|
const logger = log4js.getLogger('ImportEtherpad');
|
||||||
|
|
||||||
exports.setPadRaw = (padId, r) => {
|
exports.setPadRaw = (padId, r) => {
|
||||||
const records = JSON.parse(r);
|
const records = JSON.parse(r);
|
||||||
|
|
||||||
|
@ -28,6 +31,8 @@ exports.setPadRaw = (padId, r) => {
|
||||||
supportedElems.add(element);
|
supportedElems.add(element);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const unsupportedElements = new Set();
|
||||||
|
|
||||||
Object.keys(records).forEach(async (key) => {
|
Object.keys(records).forEach(async (key) => {
|
||||||
let value = records[key];
|
let value = records[key];
|
||||||
|
|
||||||
|
@ -64,10 +69,7 @@ exports.setPadRaw = (padId, r) => {
|
||||||
if (value.pool) {
|
if (value.pool) {
|
||||||
for (const attrib of Object.keys(value.pool.numToAttrib)) {
|
for (const attrib of Object.keys(value.pool.numToAttrib)) {
|
||||||
const attribName = value.pool.numToAttrib[attrib][0];
|
const attribName = value.pool.numToAttrib[attrib][0];
|
||||||
if (!supportedElems.has(attribName)) {
|
if (!supportedElems.has(attribName)) unsupportedElements.add(attribName);
|
||||||
console.warn('Plugin missing: ' +
|
|
||||||
`You might want to install a plugin to support this node name: ${attribName}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const oldPadId = key.split(':');
|
const oldPadId = key.split(':');
|
||||||
|
@ -92,4 +94,9 @@ exports.setPadRaw = (padId, r) => {
|
||||||
// Write the value to the server
|
// Write the value to the server
|
||||||
await db.set(newKey, value);
|
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.incrementAttrib(state, na);
|
||||||
};
|
};
|
||||||
cc.collectContent = function (node, state) {
|
cc.collectContent = function (node, state) {
|
||||||
|
let unsupportedElements = null;
|
||||||
if (!state) {
|
if (!state) {
|
||||||
state = {
|
state = {
|
||||||
flags: { /* name -> nesting counter*/
|
flags: { /* name -> nesting counter*/
|
||||||
|
@ -333,16 +334,15 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
'list': 'bullet1',
|
'list': 'bullet1',
|
||||||
*/
|
*/
|
||||||
},
|
},
|
||||||
|
unsupportedElements: new Set(),
|
||||||
};
|
};
|
||||||
|
unsupportedElements = state.unsupportedElements;
|
||||||
}
|
}
|
||||||
const localAttribs = state.localAttribs;
|
const localAttribs = state.localAttribs;
|
||||||
state.localAttribs = null;
|
state.localAttribs = null;
|
||||||
const isBlock = isBlockElement(node);
|
const isBlock = isBlockElement(node);
|
||||||
if (!isBlock && node.name && (node.name !== 'body')) {
|
if (!isBlock && node.name && (node.name !== 'body')) {
|
||||||
if (!supportedElems.has(node.name)) {
|
if (!supportedElems.has(node.name)) state.unsupportedElements.add(node.name);
|
||||||
console.warn('Plugin missing: ' +
|
|
||||||
`You might want to install a plugin to support this node name: ${node.name}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const isEmpty = _isEmpty(node, state);
|
const isEmpty = _isEmpty(node, state);
|
||||||
if (isBlock) _ensureColumnZero(state);
|
if (isBlock) _ensureColumnZero(state);
|
||||||
|
@ -621,6 +621,10 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.localAttribs = localAttribs;
|
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
|
// can pass a falsy value for end of doc
|
||||||
cc.notifyNextNode = (node) => {
|
cc.notifyNextNode = (node) => {
|
||||||
|
|
Loading…
Reference in a new issue