MCPcopy Index your code
hub / github.com/simstudioai/sim / renderTable

Function renderTable

apps/sim/lib/pptx-renderer/renderer/table-renderer.ts:397–529  ·  view source on GitHub ↗
(node: TableNodeData, ctx: RenderContext)

Source from the content-addressed store, hash-verified

395 * Render a table node into an absolutely-positioned HTML element.
396 */
397export function renderTable(node: TableNodeData, ctx: RenderContext): HTMLElement {
398 const wrapper = document.createElement('div')
399 wrapper.style.position = 'absolute'
400 wrapper.style.left = `${node.position.x}px`
401 wrapper.style.top = `${node.position.y}px`
402 wrapper.style.width = `${node.size.w}px`
403 wrapper.style.height = `${node.size.h}px`
404 wrapper.style.overflow = 'hidden'
405
406 // Apply transforms
407 const transforms: string[] = []
408 if (node.rotation !== 0) {
409 transforms.push(`rotate(${node.rotation}deg)`)
410 }
411 if (node.flipH) {
412 transforms.push('scaleX(-1)')
413 }
414 if (node.flipV) {
415 transforms.push('scaleY(-1)')
416 }
417 if (transforms.length > 0) {
418 wrapper.style.transform = transforms.join(' ')
419 }
420
421 // Resolve table style
422 const tblStyle = findTableStyle(node.tableStyleId, ctx)
423 const tblPr = node.properties
424 const totalRows = node.rows.length
425 const totalCols = node.columns.length
426
427 // Create table element
428 const table = document.createElement('table')
429 table.style.borderCollapse = 'collapse'
430 table.style.width = '100%'
431 table.style.height = '100%'
432 table.style.tableLayout = 'fixed'
433
434 // Apply table background from table style (tblBg)
435 if (tblStyle) {
436 applyTableBackground(table, tblStyle, ctx)
437 }
438
439 // Column widths
440 const totalWidth = node.columns.reduce((sum, w) => sum + w, 0)
441 if (totalWidth > 0 && node.columns.length > 0) {
442 const colgroup = document.createElement('colgroup')
443 for (const colW of node.columns) {
444 const col = document.createElement('col')
445 col.style.width = `${(colW / totalWidth) * 100}%`
446 colgroup.appendChild(col)
447 }
448 table.appendChild(colgroup)
449 }
450
451 // Compute total row height so we can express each row as a proportion
452 const totalRowHeight = node.rows.reduce((sum, r) => sum + r.height, 0)
453
454 // Render rows

Callers 1

renderNodeFunction · 0.90

Calls 12

renderTextBodyFunction · 0.90
findTableStyleFunction · 0.85
applyTableBackgroundFunction · 0.85
getStyleSectionsFunction · 0.85
applyStyleFillFunction · 0.85
applyStyleBordersFunction · 0.85
applyCellPropertiesFunction · 0.85
joinMethod · 0.80
childMethod · 0.80
existsMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected