all files / packages/table/ TableCellComponent.js

63.64% Statements 7/11
50% Branches 2/4
50% Functions 1/2
63.64% Lines 7/11
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 36 37                                                           
import { Component, TextPropertyEditor } from '../../ui'
 
class TableCellComponent extends Component {
  render($$) {
    let node = this.props.node
    let el = $$('td').addClass('sc-table-cell')
    el.append(
      $$(TextPropertyEditor, {
        path: node.getTextPath(),
        disabled: this.props.disabled
      }).ref('editor')
    )
    Iif (node.rowspan > 0) {
      el.attr('rowspan', node.rowspan)
    }
    Iif (node.colspan > 0) {
      el.attr('colspan', node.colspan)
    }
    return el
  }
 
  grabFocus() {
    let node = this.props.node
    this.context.editorSession.setSelection({
      type: 'property',
      path: node.getPath(),
      startOffset: node.getLength(),
      surfaceId: this.refs.editor.id
    })
  }
}
 
TableCellComponent.prototype._isTableCellComponent = true
 
 
export default TableCellComponent