all files / packages/inline-wrapper/ InlineWrapperComponent.js

84.62% Statements 11/13
50% Branches 2/4
100% Functions 2/2
84.62% Lines 11/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35            22×       22× 22×   22× 22× 22× 22× 22× 22× 22×                   22×          
import { InlineNodeComponent } from '../../ui'
 
class InlineWrapperComponent extends InlineNodeComponent {
 
  getClassNames() {
    // ATTENTION: ATM it is necessary to add .sc-inline-node
    return 'sc-inline-wrapper sc-inline-node'
  }
 
  renderContent($$) {
    let node = this.props.node
    let doc = node.getDocument()
 
    let wrappedNode = doc.get(node.wrappedNode)
    let el;
    Eif (wrappedNode) {
      let componentRegistry = this.context.componentRegistry
      let ComponentClass = componentRegistry.get(wrappedNode.type)
      Eif (ComponentClass) {
        el = $$(ComponentClass, {
          disabled: this.props.disabled,
          node: wrappedNode,
        })
      } else {
        console.error('No component registered for node type' + wrappedNode.type)
      }
    } else {
      console.error('Could not find wrapped node: ' + node.wrappedNode)
    }
    return el
  }
}
 
export default InlineWrapperComponent