Skip to main content
The Table extension allows you to create tables with advanced features like cell merging, column resizing, and header rows. It requires the TableRow, TableCell, and TableHeader extensions to function.

Installation

Usage

Configuration

HTMLAttributes

Custom HTML attributes to add to the table element.
Record<string, any>
default:"{}"
Custom HTML attributes that should be added to the rendered HTML tag.

resizable

Enables column resizing for tables.
boolean
default:"false"
When enabled, users can resize table columns by dragging column borders.

renderWrapper

Controls whether the table should be wrapped in a div.
boolean
default:"false"
Wraps the table in a div with class “tableWrapper” when rendered.

handleWidth

The width of the resize handle.
number
default:"5"
Width in pixels of the column resize handle.

cellMinWidth

The minimum width of a cell.
number
default:"25"
Minimum width in pixels that a table cell can be resized to.

lastColumnResizable

Enables resizing of the last column.
boolean
default:"true"
When false, the last column cannot be resized.

allowTableNodeSelection

Allow table node selection.
boolean
default:"false"
When enabled, users can select the entire table as a node.

Commands

insertTable

Inserts a new table with the specified dimensions.

addColumnBefore

Adds a column before the current column.

addColumnAfter

Adds a column after the current column.

deleteColumn

Deletes the current column.

addRowBefore

Adds a row before the current row.

addRowAfter

Adds a row after the current row.

deleteRow

Deletes the current row.

deleteTable

Deletes the entire table.

mergeCells

Merges the currently selected cells.

splitCell

Splits the currently selected cell.

toggleHeaderColumn

Toggles the header status of the current column.

toggleHeaderRow

Toggles the header status of the current row.

toggleHeaderCell

Toggles the header status of the current cell.

mergeOrSplit

Merges selected cells or splits the current cell.

setCellAttribute

Sets an attribute on the current cell.

goToNextCell

Moves the selection to the next cell.

goToPreviousCell

Moves the selection to the previous cell.

fixTables

Attempts to fix the table structure if necessary.

setCellSelection

Sets a cell selection inside the current table.

Keyboard Shortcuts

  • Tab: Move to the next cell (creates a new row if at the end)
  • Shift-Tab: Move to the previous cell
  • Backspace: Delete table when all cells are selected
  • Mod-Backspace: Delete table when all cells are selected
  • Delete: Delete table when all cells are selected
  • Mod-Delete: Delete table when all cells are selected

Examples

Basic Table

Resizable Table

Manipulating Tables

The Table extension requires these companion extensions:
  • TableRow - Defines table rows (tr elements)
  • TableCell - Defines regular table cells (td elements)
  • TableHeader - Defines header cells (th elements)
All four extensions must be registered together for tables to work properly.

Source Code

View the source code on GitHub: packages/extension-table/src/table/table.ts