mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Import: Import don't show warnings for supported elements
This commit is contained in:
parent
f24353e806
commit
f95b09e0b6
2 changed files with 31 additions and 6 deletions
|
@ -18,15 +18,14 @@
|
||||||
|
|
||||||
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 supportedElems = require('../../static/js/contentcollector').supportedElems;
|
||||||
|
|
||||||
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.
|
// get supported block Elements from plugins, we will use this later.
|
||||||
hooks.callAll('ccRegisterBlockElements').forEach((element) => {
|
hooks.callAll('ccRegisterBlockElements').forEach((element) => {
|
||||||
blockElems.push(element);
|
supportedElems.push(element);
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(records).forEach(async (key) => {
|
Object.keys(records).forEach(async (key) => {
|
||||||
|
@ -65,7 +64,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 (blockElems.indexOf(attribName) === -1) {
|
if (supportedElems.indexOf(attribName) === -1) {
|
||||||
console.warn('Plugin missing: ' +
|
console.warn('Plugin missing: ' +
|
||||||
`You might want to install a plugin to support this node name: ${attribName}`);
|
`You might want to install a plugin to support this node name: ${attribName}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,28 @@ const getAttribute = (n, a) => {
|
||||||
if (n.attribs != null) return n.attribs[a];
|
if (n.attribs != null) return n.attribs[a];
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
// supportedElems are Supported natively within Etherpad and don't require a plugin
|
||||||
|
const supportedElems = [
|
||||||
|
'author',
|
||||||
|
'b',
|
||||||
|
'bold',
|
||||||
|
'br',
|
||||||
|
'div',
|
||||||
|
'font',
|
||||||
|
'i',
|
||||||
|
'insertorder',
|
||||||
|
'italic',
|
||||||
|
'li',
|
||||||
|
'lmkr',
|
||||||
|
'ol',
|
||||||
|
'p',
|
||||||
|
'pre',
|
||||||
|
'strong',
|
||||||
|
's',
|
||||||
|
'span',
|
||||||
|
'u',
|
||||||
|
'ul',
|
||||||
|
];
|
||||||
|
|
||||||
const makeContentCollector = (collectStyles, abrowser, apool, className2Author) => {
|
const makeContentCollector = (collectStyles, abrowser, apool, className2Author) => {
|
||||||
const _blockElems = {
|
const _blockElems = {
|
||||||
|
@ -66,6 +88,7 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
|
|
||||||
hooks.callAll('ccRegisterBlockElements').forEach((element) => {
|
hooks.callAll('ccRegisterBlockElements').forEach((element) => {
|
||||||
_blockElems[element] = 1;
|
_blockElems[element] = 1;
|
||||||
|
supportedElems.push(element);
|
||||||
});
|
});
|
||||||
|
|
||||||
const isBlockElement = (n) => !!_blockElems[tagName(n) || ''];
|
const isBlockElement = (n) => !!_blockElems[tagName(n) || ''];
|
||||||
|
@ -315,9 +338,11 @@ 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')) {
|
if (!isBlock && node.name && (node.name !== 'body')) {
|
||||||
console.warn('Plugin missing: ' +
|
if (supportedElems.indexOf(node.name) === -1) {
|
||||||
|
console.warn('Plugin missing: ' +
|
||||||
`You might want to install a plugin to support this node name: ${node.name}`);
|
`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);
|
||||||
|
@ -701,3 +726,4 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
|
|
||||||
exports.sanitizeUnicode = sanitizeUnicode;
|
exports.sanitizeUnicode = sanitizeUnicode;
|
||||||
exports.makeContentCollector = makeContentCollector;
|
exports.makeContentCollector = makeContentCollector;
|
||||||
|
exports.supportedElems = supportedElems;
|
||||||
|
|
Loading…
Reference in a new issue