prosekit/extensions/table
Classes
Section titled “Classes”TableView
Section titled “TableView”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”-
new TableView(node:EditorNode,defaultCellMinWidth:number):TableView
Properties
Section titled “Properties”-
defaultCellMinWidth:number
-
The outer DOM node that represents the document node.
-
The DOM node that should hold the node's content. Only meaningful if the node view also defines a
domproperty and if its node type is not a leaf node type. When this is present, ProseMirror will take care of rendering the node's children into it. When it is not present, the node view itself is responsible for rendering (or deciding not to render) its child nodes.
Methods
Section titled “Methods”-
update(node:EditorNode):boolean -
When given, this will be called when the view is updating itself. It will be given a node, an array of active decorations around the node (which are automatically drawn, and the node view may ignore if it isn't interested in them), and a decoration source that represents any decorations that apply to the content of the node (which again may be ignored). It should return true if it was able to update to that node, and false otherwise. If the node view has a
contentDOMproperty (or nodomproperty), updating its child nodes will be handled by ProseMirror.
-
ignoreMutation(record:ViewMutationRecord):boolean -
Called when a mutation happens within the view. Return false if the editor should re-read the selection or re-parse the range around the mutation, true if it can safely be ignored.
Interfaces
Section titled “Interfaces”InsertTableOptions
Section titled “InsertTableOptions”Properties
Section titled “Properties”-
row:number -
The number of rows in the table.
-
col:number -
The number of columns in the table.
-
header?:boolean -
Whether the table has a header row.
Default
Section titled “Default”false
SelectTableCellOptions
Section titled “SelectTableCellOptions”Properties
Section titled “Properties”-
pos?:number -
A hit position of the table cell to select from. By default, the selection anchor will be used.
SelectTableColumnOptions
Section titled “SelectTableColumnOptions”Properties
Section titled “Properties”-
anchor?:number -
A hit position of the table cell to select from. By default, the selection anchor will be used.
-
head?:number -
A hit position of the table cell to select to. By default, the selection head will be used.
SelectTableRowOptions
Section titled “SelectTableRowOptions”Properties
Section titled “Properties”-
anchor?:number -
A hit position of the table cell to select from. By default, the selection anchor will be used.
-
head?:number -
A hit position of the table cell to select to. By default, the selection head will be used.
SelectTableOptions
Section titled “SelectTableOptions”Properties
Section titled “Properties”-
pos?:number -
A hit position of the table to select from. By default, the selection anchor will be used.
MoveTableRowOptions
Section titled “MoveTableRowOptions”Options for moveTableRow
Properties
Section titled “Properties”-
from:number -
The source row index to move from.
-
to:number -
The destination row index to move to.
-
select?:boolean -
Whether to select the moved row after the operation.
Default
Section titled “Default”true
-
pos?:number -
Optional position to resolve table from. If not provided, uses the current selection.
MoveTableColumnOptions
Section titled “MoveTableColumnOptions”Options for moveTableColumn
Properties
Section titled “Properties”-
from:number -
The source column index to move from.
-
to:number -
The destination column index to move to.
-
select?:boolean -
Whether to select the moved column after the operation.
Default
Section titled “Default”true
-
pos?:number -
Optional position to resolve table from. If not provided, uses the current selection.
Type Aliases
Section titled “Type Aliases”ColumnResizingOptions
Section titled “ColumnResizingOptions”type ColumnResizingOptions = { handleWidth?: number; cellMinWidth?: number; defaultCellMinWidth?: number; lastColumnResizable?: boolean; View?: ((node: EditorNode, cellMinWidth: number, view: EditorView) => NodeView) | null; }
Properties
Section titled “Properties”-
handleWidth?:number
-
cellMinWidth?:number -
Minimum width of a cell /column. The column cannot be resized smaller than this.
-
defaultCellMinWidth?:number -
The default minWidth of a cell / column when it doesn't have an explicit width (i.e.: it has not been resized manually)
-
lastColumnResizable?:boolean
-
View?: ((node:EditorNode,cellMinWidth:number,view:EditorView) =>NodeView) |null -
A custom node view for the rendering table nodes. By default, the plugin uses the TableView class. You can explicitly set this to
nullto not use a custom node view.
TableEditingOptions
Section titled “TableEditingOptions”type TableEditingOptions = { allowTableNodeSelection?: boolean; }
Properties
Section titled “Properties”-
allowTableNodeSelection?:boolean -
Whether to allow table node selection.
By default, any node selection wrapping a table will be converted into a CellSelection wrapping all cells in the table. You can pass
trueto allow the selection to remain a NodeSelection.Default
Section titled “Default”false
Variables
Section titled “Variables”exitTable
Section titled “exitTable”-
When the selection is in a table node, create a default block after the table table, and move the cursor there.
Functions
Section titled “Functions”defineTableCommands()
Section titled “defineTableCommands()”-
function defineTableCommands():TableCommandsExtension -
Adds commands for working with
tablenodes.
insertTable()
Section titled “insertTable()”-
function insertTable(options:InsertTableOptions):Command -
Insert a table node with the given number of rows and columns, and optionally a header row.
selectTableCell()
Section titled “selectTableCell()”-
function selectTableCell(options?:SelectTableCellOptions):Command
selectTableColumn()
Section titled “selectTableColumn()”-
function selectTableColumn(options?:SelectTableColumnOptions):Command
selectTableRow()
Section titled “selectTableRow()”-
function selectTableRow(options?:SelectTableRowOptions):Command
selectTable()
Section titled “selectTable()”-
function selectTable(options?:SelectTableOptions):Command
defineTableEditingPlugin()
Section titled “defineTableEditingPlugin()”-
function defineTableEditingPlugin(options?:TableEditingOptions):PlainExtension
defineColumnResizingPlugin()
Section titled “defineColumnResizingPlugin()”-
function defineColumnResizingPlugin(options?:ColumnResizingOptions):PlainExtension
defineTablePlugins()
Section titled “defineTablePlugins()”-
function defineTablePlugins():PlainExtension
defineTableHeaderCellSpec()
Section titled “defineTableHeaderCellSpec()”-
function defineTableHeaderCellSpec():TableHeaderCellSpecExtension
isCellSelection()
Section titled “isCellSelection()”-
function isCellSelection(value:unknown):value is CellSelection -
Checks if the given object is a
CellSelectioninstance.
defineTable()
Section titled “defineTable()”-
function defineTable():TableExtension
addTableColumnBefore()
Section titled “addTableColumnBefore()”-
function addTableColumnBefore(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Command to add a column before the column with the selection.
addTableColumnAfter()
Section titled “addTableColumnAfter()”-
function addTableColumnAfter(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Command to add a column after the column with the selection.
deleteTableColumn()
Section titled “deleteTableColumn()”-
function deleteTableColumn(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Command function that removes the selected columns from a table.
addTableRowAbove()
Section titled “addTableRowAbove()”-
function addTableRowAbove(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Add a table row before the selection.
addTableRowBelow()
Section titled “addTableRowBelow()”-
function addTableRowBelow(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Add a table row after the selection.
deleteTableRow()
Section titled “deleteTableRow()”-
function deleteTableRow(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Remove the selected rows from a table.
mergeTableCells()
Section titled “mergeTableCells()”-
function mergeTableCells(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Merge the selected cells into a single cell. Only available when the selected cells' outline forms a rectangle.
splitTableCell()
Section titled “splitTableCell()”-
function splitTableCell(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Split a selected cell, whose rowpan or colspan is greater than one, into smaller cells. Use the first cell type for the new cells.
deleteTable()
Section titled “deleteTable()”-
function deleteTable(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Deletes the table around the selection, if any.
deleteCellSelection()
Section titled “deleteCellSelection()”-
function deleteCellSelection(state:EditorState,dispatch?: (tr:Transaction) =>void):boolean -
Deletes the content of the selected cells, if they are not empty.
moveTableRow()
Section titled “moveTableRow()”-
function moveTableRow(options:MoveTableRowOptions):Command -
Move a table row from index
fromto indexto.
moveTableColumn()
Section titled “moveTableColumn()”-
function moveTableColumn(options:MoveTableColumnOptions):Command -
Move a table column from index
fromto indexto.
findTable()
Section titled “findTable()”-
function findTable($pos:ResolvedPos):FindNodeResult|null -
Find the closest table node for a given position.