# @univerjs/docs-toc

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/docs-toc](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/docs-toc)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/docs-toc.md](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/docs-toc.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.2`

- Source: [packages/plugins/univerjs/docs-toc.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/packages/plugins/univerjs/docs-toc.mdx)

---

Table-of-contents commands for Univer Docs. Register this model plugin after the Docs core plugins; add [`@univerjs/docs-toc-ui`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/docs-toc-ui.md) for the editor controls.

```ts
import { UniverDocsTocPlugin } from '@univerjs/docs-toc'

univer.registerPlugin(UniverDocsTocPlugin)
```

## Commands

Call commands through `univerAPI.executeCommand()` after opening a document and placing a text selection.

| Export                         | Parameters                                                                                                   |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------ |
| `InsertTableOfContentsCommand` | Optional `unitId`, `levels`, `showPageNumbers`, `rightAlignPageNumbers`, `tabLeader`, `format`, and `title`. |
| `UpdateTableOfContentsCommand` | Optional `unitId`, `rangeId`, and `mode: 'pageNumbersOnly' \| 'entireTable'`.                                |
| `DeleteTableOfContentsCommand` | Optional `unitId` and `rangeId`.                                                                             |

The root also exports their parameter types, `TableOfContentsFormat`, `TableOfContentsTabLeader`, and `findTableOfContentsAtOffset`.

The updater evaluates outline-level TOC instructions (`\o`). Other Word switches remain in FIELD metadata but are not all evaluated. The inserted TOC is document content; the outline navigation panel is a separate feature.

This package has no stylesheet, locales, or Facade entry. See the [table-of-contents guide](https://docs.univer.ai/zh-CN/guides/docs/features/table-of-contents.md).
