tiptap/docs/api/nodes/table-header.md

39 lines
1.4 KiB
Markdown
Raw Normal View History

2021-01-22 07:16:58 +08:00
# TableHeader
2021-01-25 19:04:08 +08:00
[![Version](https://img.shields.io/npm/v/@tiptap/extension-table-header.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-table-header)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-table-header.svg)](https://npmcharts.com/compare/@tiptap/extension-table-header?minimal=true)
2021-01-22 07:16:58 +08:00
2021-04-24 23:43:21 +08:00
Table headers are optional. But come on, you want them, dont you? If you dont want them, update the `content` attribute of the [`TableRow`](/api/nodes/table-row) extension, like this:
2021-02-09 00:39:50 +08:00
```js
// Table rows without table headers
TableRow.extend({
content: 'tableCell*',
})
```
This is the default, which allows table headers:
```js
// Table rows with table headers (default)
TableRow.extend({
content: '(tableCell | tableHeader)*',
})
```
2021-01-22 07:16:58 +08:00
2021-01-25 19:04:08 +08:00
## Installation
```bash
# with npm
npm install @tiptap/extension-table @tiptap/extension-table-row @tiptap/extension-table-header @tiptap/extension-table-cell
# with Yarn
yarn add @tiptap/extension-table @tiptap/extension-table-row @tiptap/extension-table-header @tiptap/extension-table-cell
```
2021-02-12 22:02:40 +08:00
This extension requires the [`Table`](/api/nodes/table), [`TableRow`](/api/nodes/table-row) and [`TableCell`](/api/nodes/table-cell) nodes.
2021-01-25 19:04:08 +08:00
## Source code
2021-04-21 21:31:11 +08:00
[packages/extension-table-header/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-table-header/)
2021-01-22 07:16:58 +08:00
2021-01-25 19:04:08 +08:00
## Usage
<tiptap-demo name="Nodes/Table"></tiptap-demo>