Table row functionality from @tiptap/extension-table - provides TableRow node extension for table row elements
npx @tessl/cli install tessl/npm-tiptap--extension-table-row@3.4.0The @tiptap/extension-table-row package provides table row functionality for the Tiptap rich text editor framework. It implements the TableRow Node extension that defines how table rows behave within the editor as part of the larger @tiptap/extension-table package.
npm install @tiptap/extension-tableimport { TableRow } from "@tiptap/extension-table";For importing just the table row functionality using the subpath export:
import { TableRow, type TableRowOptions } from "@tiptap/extension-table/row";CommonJS:
const { TableRow } = require("@tiptap/extension-table");import { Editor } from "@tiptap/core";
import { TableRow } from "@tiptap/extension-table";
// Add TableRow to your editor
const editor = new Editor({
extensions: [
TableRow.configure({
HTMLAttributes: {
class: 'my-table-row'
}
})
]
});
// TableRow works automatically within table structures
// It provides the <tr> elements that contain table cells and headersThe TableRow extension is built as a Tiptap Node extension with the following key characteristics:
tableRow - defines the node name within ProseMirror schemarow - integrates with ProseMirror's table role system(tableCell | tableHeader)* - allows table cells and headers as children<tr> elements with configurable attributesMain table row node extension for creating table rows within Tiptap editors.
export const TableRow: Node<TableRowOptions, any>;Configuration:
interface TableRowOptions {
/**
* The HTML attributes for a table row node.
* @default {}
* @example { class: 'foo' }
*/
HTMLAttributes: Record<string, any>;
}Usage Example:
import { TableRow } from "@tiptap/extension-table";
// Use with default options
TableRow
// Configure with custom HTML attributes
TableRow.configure({
HTMLAttributes: {
class: 'custom-table-row',
'data-testid': 'table-row'
}
})The TableRow extension is configured with the following properties:
/**
* Node name identifier used in ProseMirror schema
*/
name: "tableRow";
/**
* Returns default options for the TableRow node
*/
addOptions(): TableRowOptions;
/**
* Content model specification - allows table cells and headers as children
*/
content: "(tableCell | tableHeader)*";
/**
* Table role identifier for ProseMirror table integration
*/
tableRole: "row";
/**
* Defines HTML parsing rules for table rows
* @returns Array containing single configuration object matching <tr> elements
*/
parseHTML(): [{ tag: "tr" }];
/**
* Defines HTML rendering output for table rows
* @param params - Rendering parameters including HTMLAttributes
* @returns HTML rendering array format ['tr', mergedAttributes, 0]
*/
renderHTML({ HTMLAttributes }: { HTMLAttributes: Record<string, any> }): ['tr', Record<string, any>, 0];Configuration options for the TableRow node extension.
interface TableRowOptions {
/**
* HTML attributes applied to the table row element
* These attributes are merged with any attributes specified during rendering
* @default {}
*/
HTMLAttributes: Record<string, any>;
}/**
* TableRow is a Tiptap Node extension with TableRowOptions configuration
* Created using Node.create<TableRowOptions>()
*/
type TableRowExtension = Node<TableRowOptions, any>;
/**
* Utility function from @tiptap/core for merging HTML attributes
* Used internally by TableRow's renderHTML method
*/
function mergeAttributes(...attrs: Record<string, any>[]): Record<string, any>;@tiptap/core for Node base class and mergeAttributes utilitymergeAttributes from @tiptap/core to combine default HTMLAttributes with runtime attributesTableCell, TableHeader, and Table extensions<tr> elements in the final HTML outputThe TableRow extension follows standard Tiptap patterns:
<tr> tags, other elements are ignored@tiptap/core is available