Table
The table extension adds support for creating and editing tables in your document. It provides a set of commands and utilities for working with table structures.
Usage
import { defineTable } from 'prosekit/extensions/table'
const extension = defineTable()
Commands
insertTable
Insert a new table.
editor.commands.insertTable({ rows: 3, cols: 3 })
exitTable
Exit the table.
editor.commands.exitTable()
selectTable
Select the table.
editor.commands.selectTable()
selectTableCell
Select the table cell.
editor.commands.selectTableCell()
selectTableColumn
Select the table column.
editor.commands.selectTableColumn()
selectTableRow
Select the table row.
editor.commands.selectTableRow()
addTableColumnBefore
Add a new column before the selected column.
editor.commands.addTableColumnBefore()
addTableColumnAfter
Add a new column after the selected column.
editor.commands.addTableColumnAfter()
addTableRowAbove
Add a new row above the selected row or specific position.
editor.commands.addTableRowAbove()
addTableRowBelow
Add a new row below the selected row or specific position.
editor.commands.addTableRowBelow()
deleteTable
Delete the selected table.
editor.commands.deleteTable()
deleteTableColumn
Delete the selected column or specific position.
editor.commands.deleteTableColumn()
deleteTableRow
Delete the selected row or specific position.
editor.commands.deleteTableRow()
deleteCellSelection
Delete the cell selection.
editor.commands.deleteCellSelection()
mergeTableCells
Merge the selected cells.
editor.commands.mergeTableCells()
splitTableCell
Split the selected cell.
editor.commands.splitTableCell()
Plugins
tableEditing
and columnResizing
These plugins are built-in plugins in prosemirror-tables.
import { defineTablePlugins } from 'prosekit/extensions/table'
const extension = defineTablePlugins()
Components
TableHandle
You can use the TableHandle
component to control the table.