MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / insertColumn

Function insertColumn

packages/app-core/src/lib/markdown-table.ts:319–330  ·  view source on GitHub ↗
(
  table: MarkdownTable,
  index: number,
  align: ColumnAlign = 'none'
)

Source from the content-addressed store, hash-verified

317
318/** Insert an empty column at `index` (clamped) with the given alignment. */
319export function insertColumn(
320 table: MarkdownTable,
321 index: number,
322 align: ColumnAlign = 'none'
323): MarkdownTable {
324 const next = clone(table)
325 const at = Math.max(0, Math.min(index, columnCount(next)))
326 next.headers.splice(at, 0, '')
327 next.aligns.splice(at, 0, align)
328 for (const row of next.rows) row.splice(at, 0, '')
329 return next
330}
331
332export function deleteColumn(table: MarkdownTable, index: number): MarkdownTable {
333 if (index < 0 || index >= columnCount(table)) return table

Callers 3

openTableContextMenuFunction · 0.90
toDOMMethod · 0.90

Calls 2

cloneFunction · 0.85
columnCountFunction · 0.85

Tested by

no test coverage detected