UNPKG

@react-page-plugins/slate-table

Version:
52 lines 1.3 kB
import cloneDeep from 'lodash/cloneDeep'; export var emptyCell = { type: 'table-cell', children: [{ type: 'paragraph', children: [{ text: '' }] }], }; export var emptyRow = { type: 'table-row', children: [], }; export var emptyTable = { type: 'table', children: [], }; export var getRow = function (table, rindex) { return table.children[rindex]; }; export var addCell = function (row, cnt) { if (cnt === void 0) { cnt = 1; } for (var x = 0; x < cnt; x++) { row.children.push(cloneDeep(emptyCell)); } return row; }; export var addRow = function (table, cnt) { if (cnt === void 0) { cnt = 1; } for (var x = 0; x < cnt; x++) { table.children.push(cloneDeep(emptyRow)); } return table; }; export var newCell = function () { return cloneDeep(emptyCell); }; export var newRow = function (colWidth) { var newrow = cloneDeep(emptyRow); return addCell(newrow, colWidth); }; export var cloneTable = function () { return cloneDeep(emptyTable); }; export default { emptyCell: emptyCell, emptyRow: emptyRow, emptyTable: emptyTable, getRow: getRow, addCell: addCell, addRow: addRow, newCell: newCell, newRow: newRow, cloneTable: cloneTable, }; //# sourceMappingURL=table-builder.js.map