all files / packages/table/ InsertTableCommand.js

0% Statements 0/5
100% Branches 0/0
0% Functions 0/1
0% Lines 0/5
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                                                       
import { uuid } from '../../util'
import { InsertNodeCommand } from '../../ui'
 
class InsertTableCommand extends InsertNodeCommand {
  createNodeData(tx) {
 
    // row-1
    let a1 = tx.create({ id: uuid('table-cell'), type: 'table-cell', content: "A1" })
    let b1 = tx.create({ id: uuid('table-cell'), type: 'table-cell', content: "B1" })
    // row-2
    let a2 = tx.create({ id: uuid('table-cell'), type: 'table-cell', content: "A2" })
    let b2 = tx.create({ id: uuid('table-cell'), type: 'table-cell', content: "B2" })
 
    return {
      id: uuid('table'),
      type: 'table',
      // null values mark merged cells
      cells: [
        [a1.id, b1.id ],
        [a2.id, b2.id]
      ]
    }
 
  }
}
 
export default InsertTableCommand