# @univerjs/docs

> Language fallback: requested `ru-RU`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/ru-RU/reference/packages/plugins/univerjs/docs](https://docs.univer.ai/ru-RU/reference/packages/plugins/univerjs/docs)

- Agent Markdown: [https://docs.univer.ai/ru-RU/reference/packages/plugins/univerjs/docs.md](https://docs.univer.ai/ru-RU/reference/packages/plugins/univerjs/docs.md)

- Requested language: `ru-RU`

- Content language: `en-US`

- Documentation version: `1.2.0`

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

---

Core document model and rich-text operations for Univer Docs.

```typescript
// [!code word:UniverDocsPlugin]
import { UniverDocsPlugin } from '@univerjs/docs'

univer.registerPlugin(UniverDocsPlugin, config)
```

## Document Layout Worker

Move document layout work to a Web Worker by registering the Worker plugin after `UniverDocsPlugin`:

```typescript
import { UniverDocsLayoutWorkerPlugin } from '@univerjs/docs'

univer.registerPlugin(UniverDocsLayoutWorkerPlugin, {
  workerFactory: () =>
    new Worker(new URL('./docs-layout.worker.ts', import.meta.url), {
      type: 'module',
    }),
  requestTimeoutMs: 15_000,
})
```

Initialize the Worker entry:

```typescript
import { startDocsLayoutWorker } from '@univerjs/docs'

startDocsLayoutWorker()
```

`workerFactory` is required. `requestTimeoutMs` is optional and defaults to 15 seconds.

## Entry Points

* Facade: `@univerjs/docs/facade`

The root entry exports `SetDocumentNameCommand` and `ISetDocumentNameCommandParams`. The Facade exposes the same behavior through `FDocument.setName(name)`.

## IUniverDocsConfig

```ts
export interface IUniverDocsConfig {
  hasScroll?: boolean
}
```

## Heading collapse

`UniverDocsPlugin` registers and exports `SetHeadingCollapsedCommand` (`doc.command.set-heading-collapsed`). Execute it through the Facade or `ICommandService` after creating the document:

```ts
import { SetHeadingCollapsedCommand } from '@univerjs/docs'

const changed = await univerAPI.executeCommand(SetHeadingCollapsedCommand.id, {
  unitId: documentId,
  paragraphId: headingParagraphId,
  collapsed: true,
})
```

`unitId` and the stable `paragraphId` identify the target. `collapsed: false` expands it. The command returns `false` for an unchanged state, a disabled or Traditional document, a heading hidden by an ancestor, an empty section when collapsing, or missing edit permission.

In Modern documents, `IParagraph.headingCollapsed?: boolean` persists in Univer snapshots and participates in undo/redo and collaboration. Only `true` collapses a Heading 1–5 section; Traditional layout ignores the flag. The content remains in the snapshot. This does not guarantee preservation through Office import/export. See [the interactive heading guide](https://docs.univer.ai/ru-RU/guides/docs/features/core.md#heading-collapse).
