MCPcopy Create free account
hub / github.com/editablejs/editable / setCell

Function setCell

packages/models/src/interfaces/grid.ts:693–730  ·  view source on GitHub ↗
(cell: GridCell, col: number)

Source from the content-addressed store, hash-verified

691 const nextRow = rows[index]
692
693 const setCell = (cell: GridCell, col: number) => {
694 // 合并的行之间插入,设置单元格span
695 if (prevRow && nextRow) {
696 const prevCells = prevRow.children
697 const nextCells = nextRow.children
698 const { span: pSpan, rowspan: pRowspan } = prevCells[col]
699 const { span: nSpan } = nextCells[col]
700 if (nSpan && ((pSpan && GridCell.equal(pSpan, nSpan)) || pRowspan > 1)) {
701 cell.span = nSpan
702 const [spanRow, spanCol] = nSpan
703 const spanCell = rows[spanRow].children[spanCol]
704 Transforms.setNodes<GridCell>(
705 editor,
706 { rowspan: spanCell.rowspan + 1 },
707 {
708 at: path.concat([spanRow, spanCol]),
709 },
710 )
711 }
712 }
713 // 插入的行后面还有合并的行,则更新其被合并列的span属性row + 1
714 for (let r = index; r < rows.length; r++) {
715 const cell = rows[r].children[col]
716 if (cell.span) {
717 const [spanRow, spanCol] = cell.span
718 if (index <= spanRow) {
719 Transforms.setNodes<GridCell>(
720 editor,
721 { span: [spanRow + 1, spanCol] },
722 {
723 at: path.concat([r, col]),
724 },
725 )
726 }
727 }
728 }
729 return cell
730 }
731
732 const rowHeight = height ?? 5
733 const newRow = GridRow.create(

Callers 1

grid.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…