Tables
Table extensions add tables to the editor, with commands to add and delete rows and columns, merge and split cells, and set header cells.
When you use them
- Data in rows and columns. Table inserts a table, three by three with a header row by default, and adds or deletes rows and columns.
- Headers. Table header adds header cells. Commands turn the current row, column, or cell into a header.
- Merged cells. Table merges the selected cells into one and splits a merged cell again.
- Cell attributes.
setCellAttribute()sets an attribute you defined on Table cell, for example a background color.
How they work
- A table is four nodes. Table holds Table rows, and each row holds Table cells and Table headers. Table cell, Table header, and Table row each require Table. Nodes and marks
- The Table kit bundles them. The Table kit holds Table, Table cell, Table header, and Table row. Tables aren't part of the StarterKit.
- Commands do the editing. Table's commands, such as
addRowAfter()andmergeCells(), change the table, andgoToNextCell()andgoToPreviousCell()move between cells. - Headers are optional. To allow no headers, change the
contentof Table row so it holds only cells.
Related
- Text blocks and Lists are the other blocks of a document.
- Extend an existing extension to add your own attributes to table cells.