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

Function buildTableGrid

src/lib/table/builder.ts:13–33  ·  view source on GitHub ↗
(tree: Tree)

Source from the content-addressed store, hash-verified

11 * @returns A `tableGrid` object representing the virtual table.
12 */
13export function buildTableGrid(tree: Tree) {
14 const tableGrid = newTableGrid();
15
16 if (!tree.valid()) {
17 return tableGrid;
18 }
19
20 /* The table represented by root needs to meet the following requirements:
21 * 1. Cells in the same column should maintain the same width.
22 * 2. Cells in the same row should maintain the same span.
23 */
24 const root = createNode({ row: 0, level: 0 }, tree, tree.root());
25
26 for (let i = 0; i < root.span; i++) {
27 fillGrid(tableGrid, root, i);
28 }
29
30 tableGrid.width = root.width;
31 tableGrid.height = root.span * globalStyle.rowHeight;
32 return tableGrid;
33}
34
35/**
36 * Fills the `grid` and `posMap` of a `tableGrid` by traversing a given `TableNode` row.

Callers 3

createTableFunction · 0.90
checkTextFunction · 0.90
checkStyleFunction · 0.90

Calls 5

newTableGridFunction · 0.90
createNodeFunction · 0.90
fillGridFunction · 0.85
validMethod · 0.80
rootMethod · 0.80

Tested by 2

checkTextFunction · 0.72
checkStyleFunction · 0.72