UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

24 lines (23 loc) 894 B
import { splitCellWithType } from '@atlaskit/editor-tables/utils'; import { getPluginState } from '../plugin-factory'; /** * We need to split cell keeping the right type of cell given current table configuration. * We are using editor-tables splitCellWithType that allows you to choose what cell type should be. */ export var splitCell = function splitCell(state, dispatch) { var tableState = getPluginState(state); var _state$schema$nodes = state.schema.nodes, tableHeader = _state$schema$nodes.tableHeader, tableCell = _state$schema$nodes.tableCell; if (dispatch) { return splitCellWithType(function (_ref) { var row = _ref.row, col = _ref.col; if (row === 0 && tableState.isHeaderRowEnabled || col === 0 && tableState.isHeaderColumnEnabled) { return tableHeader; } return tableCell; })(state, dispatch); } return true; };