Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const transform = (node, index, siblings, parent) => {
let nodes;
if (node.type === 'root') {
// Create definition getter for link and image references
getDefinition = mdastDefinitions(node);
// Ensure top level text nodes are wrapped in paragraphs
modifyChildren(wrapText)(node);
}
if (isEmpty(node.children)) {
nodes = node.children;
} else {
// If a node returns a falsey value, exclude it. Some nodes do not
// translate from MDAST to Slate, such as definitions for link/image
// references or footnotes.
//
// Consider using unist-util-remove instead for this.
nodes = node.children.reduce((acc, childNode, idx, sibs) => {
const transformed = transform(childNode, idx, sibs, node);
if (transformed) {
acc.push(transformed);
function getTransform(node) {
const getDefinition = mdastDefinitions(node);
return transform.call(null, getDefinition, node);
}