UNPKG

@atlaskit/renderer

Version:
40 lines 1.31 kB
const isLayoutNode = node => node.type.name === 'layoutSection'; const isExpandNode = node => node.type.name === 'expand'; const hasBreakOutMark = node => node.marks.some(m => m.type.name === 'breakout'); export const insideBreakoutLayout = path => path.some(item => isLayoutNode(item) && hasBreakOutMark(item)); export const insideBreakoutExpand = path => path.some(item => isExpandNode(item) && hasBreakOutMark(item)); export const insideBlockNode = (path, schema) => { const { nodes: { expand, nestedExpand, layoutColumn } } = schema; const blockNodeNames = [expand, nestedExpand, layoutColumn].filter(node => Boolean(node)).map(node => node.name); return path && path.some(n => n.type && blockNodeNames.indexOf(n.type.name) > -1); }; export const insideMultiBodiedExtension = (path, schema) => { const { nodes: { multiBodiedExtension } } = schema; return path.some(n => n.type === multiBodiedExtension); }; export const insideTable = (path, schema) => { const { nodes: { table } } = schema; return path.some(n => n.type === table); }; export const getNestedUnderNodes = (path, nodeTypeNames) => { for (const node of path) { if (nodeTypeNames.includes(node.type.name)) { return node.type.name; } } return undefined; };