@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
29 lines (27 loc) • 572 B
JavaScript
export function addItems(builtInItems, config, customSpecs = {}) {
if (!config) {
return {};
}
/**
* Add built-in Node / Mark specs
*/
const items = builtInItems.reduce((items, {
name,
spec
}) => {
if (config.indexOf(name) !== -1) {
items[name] = customSpecs[name] || spec;
}
return items;
}, {});
/**
* Add Custom Node / Mark specs
*/
return Object.keys(customSpecs).reduce((items, name) => {
if (items[name]) {
return items;
}
items[name] = customSpecs[name];
return items;
}, items);
}