MCPcopy
hub / github.com/loggerhead/json4u / addCell

Function addCell

src/lib/table/builder.ts:92–115  ·  view source on GitHub ↗

* A helper function to add a cell to the grid and update the position map. * @param row The absolute row index in the grid. * @param nd The `TableNode` cell to add.

(tableGrid: TableGrid, nd: TableNode, row: number)

Source from the content-addressed store, hash-verified

90 * @param nd The `TableNode` cell to add.
91 */
92function addCell(tableGrid: TableGrid, nd: TableNode, row: number) {
93 if (!tableGrid.grid[row]) {
94 tableGrid.grid[row] = [];
95 }
96 const col = tableGrid.grid[row].length;
97
98 addBorder(nd);
99 const cell = nd.toCell();
100 tableGrid.grid[row].push(cell);
101
102 // Add the cell position to the map.
103 if (!nd.id) {
104 return;
105 }
106 if (!tableGrid.posMap) {
107 tableGrid.posMap = new Map();
108 }
109 if (!tableGrid.posMap.get(nd.id)) {
110 tableGrid.posMap.set(nd.id, []);
111 }
112
113 const posList = tableGrid.posMap.get(nd.id)!;
114 posList.push({ row, col, type: cell.type });
115}
116
117function addBorder(nd: TableNode) {
118 nd.addClass("border-b").addClass("border-r");

Callers 1

fillGridFunction · 0.85

Calls 4

addBorderFunction · 0.85
toCellMethod · 0.80
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected