PHP 8.2.30
Preview: createTable.ts Size: 1.06 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/@tiptap/extension-table/src/utilities/createTable.ts

import { Fragment, Node as ProsemirrorNode, Schema } from '@tiptap/pm/model'

import { createCell } from './createCell.js'
import { getTableNodeTypes } from './getTableNodeTypes.js'

export function createTable(
  schema: Schema,
  rowsCount: number,
  colsCount: number,
  withHeaderRow: boolean,
  cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>,
): ProsemirrorNode {
  const types = getTableNodeTypes(schema)
  const headerCells: ProsemirrorNode[] = []
  const cells: ProsemirrorNode[] = []

  for (let index = 0; index < colsCount; index += 1) {
    const cell = createCell(types.cell, cellContent)

    if (cell) {
      cells.push(cell)
    }

    if (withHeaderRow) {
      const headerCell = createCell(types.header_cell, cellContent)

      if (headerCell) {
        headerCells.push(headerCell)
      }
    }
  }

  const rows: ProsemirrorNode[] = []

  for (let index = 0; index < rowsCount; index += 1) {
    rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells))
  }

  return types.table.createChecked(null, rows)
}

Directory Contents

Dirs: 0 × Files: 5

Name Size Perms Modified Actions
354 B lrw-r--r-- 2026-02-28 00:28:08
Edit Download
1.06 KB lrw-r--r-- 2026-02-28 00:28:18
Edit Download
833 B lrw-r--r-- 2026-02-28 00:28:24
Edit Download
505 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
167 B lrw-r--r-- 2026-02-28 00:28:36
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).