@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
29 lines (28 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.splitCell = void 0;
var _utils = require("@atlaskit/editor-tables/utils");
var _pluginFactory = require("../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.
*/
var splitCell = exports.splitCell = function splitCell(state, dispatch) {
var tableState = (0, _pluginFactory.getPluginState)(state);
var _state$schema$nodes = state.schema.nodes,
tableHeader = _state$schema$nodes.tableHeader,
tableCell = _state$schema$nodes.tableCell;
if (dispatch) {
return (0, _utils.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;
};