Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (node.type === 'jsx' && node.children) {
// Remove open and closing jsx blocks
const children = node.children.slice(1, node.children.length - 1)
return {
object: 'block',
type: 'jsx',
nodes: flatten(children.map(toSlate)),
data: {
type: getComponentName(node.children[0].value),
props: {}
}
}
}
if (phrasing(node)) {
const parentMark = {
object: 'mark',
type: node.type
}
const nodes = node.children.map(child => {
const childMark = child.type !== 'text' && {
object: 'mark',
type: child.type
}
return {
object: 'text',
text: child.value,
marks: [parentMark, childMark].filter(Boolean)
}