pluginfw: Warn plugins on missing plugin (#4826)

* pluginfw: Warn plugins on missing plugin

Add functionality to console.warn when a plugin is missing.  This will help admins know when people are trying to use plugins that are missing.  Resolves https://github.com/ether/etherpad-lite/issues/4730

* pluginfw: importing .etherpad can notify admins of missing plugins

Extending .etherpad imports to notify admins if a missing plugin is present

* Update ImportEtherpad.js
pull/4832/head^2
John McLear 2021-02-21 11:07:13 +00:00 committed by GitHub
parent 77b2f372ab
commit ee2b32281c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -22,6 +22,13 @@ const hooks = require('../../static/js/pluginfw/hooks');
exports.setPadRaw = (padId, r) => { exports.setPadRaw = (padId, r) => {
const records = JSON.parse(r); const records = JSON.parse(r);
const blockElems = ['div', 'br', 'p', 'pre', 'li', 'author', 'lmkr', 'insertorder'];
// get supported block Elements from plugins, we will use this later.
hooks.callAll('ccRegisterBlockElements').forEach((element) => {
blockElems.push(element);
});
Object.keys(records).forEach(async (key) => { Object.keys(records).forEach(async (key) => {
let value = records[key]; let value = records[key];
@ -53,6 +60,17 @@ exports.setPadRaw = (padId, r) => {
} else { } else {
// Not author data, probably pad data // Not author data, probably pad data
// we can split it to look to see if it's pad data // we can split it to look to see if it's pad data
// is this an attribute we support or not? If not, tell the admin
if (value.pool) {
for (const attrib of Object.keys(value.pool.numToAttrib)) {
const attribName = value.pool.numToAttrib[attrib][0];
if(blockElems.indexOf(attribName) === -1) {
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(':');
// we know it's pad data // we know it's pad data

View File

@ -315,6 +315,10 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
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') && (node.name !== 'br')) {
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);
const startLine = lines.length() - 1; const startLine = lines.length() - 1;