# Document

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

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/document](https://docs.univer.ai/zh-CN/reference/facade/document)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/document.md](https://docs.univer.ai/zh-CN/reference/facade/document.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/document.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/document.mdx)

---

| Packages | `@univerjs/docs`, `@univerjs/docs-ui`, `@univerjs/docs-drawing`, `@univerjs/docs-thread-comment` |
| -------- | ------------------------------------------------------------------------------------------------ |

The facade classes for Univer Docs documents and paragraphs.

> These classes should not be instantiated directly. When using the Facade API, use `univerAPI.createDocument(data)` to create a document and get its facade wrapper. When working with the underlying `univer` instance directly, use `univer.createUnit(UniverInstanceType.UNIVER_DOC, data)`.

## Overview

### @univerjs/docs

| Class                | Method                                                            | Description                                                 |
| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------- |
| `univerAPI`          | [`createDocument`](#createdocument)                               | Create a document and return its facade wrapper.            |
| `univerAPI`          | [`getActiveDocument`](#getactivedocument)                         | Get the currently focused document.                         |
| `univerAPI`          | [`getDocument`](#getdocument)                                     | Get a document facade wrapper by document id.               |
| `FDocument`          | [`getDocumentDataModel`](#getdocumentdatamodel)                   | Get the document data model.                                |
| `FDocument`          | [`getBody`](#getbody)                                             | Get the main body or a header/footer body by segment id.    |
| `FDocument`          | [`dispose`](#dispose)                                             | Dispose the facade wrapper.                                 |
| `FDocument`          | [`getId`](#getid)                                                 | Get the document id.                                        |
| `FDocument`          | `getPermission`, `getEntityPermission`                            | Access command-backed unit and object permissions.          |
| `FDocument`          | [`getName`](#getname)                                             | Get the document name.                                      |
| `FDocument`          | [`setName`](#setname)                                             | Update the document name.                                   |
| `FDocument`          | `getDocumentFlavor`                                               | Get the document flavor.                                    |
| `FDocument`          | `isTraditional`                                                   | Check whether the document uses traditional pagination.     |
| `FDocument`          | [`isModern`](#ismodern)                                           | Check whether the document uses the modern document flavor. |
| `FDocument`          | [`save`](#save)                                                   | Save and return the document snapshot data.                 |
| `FDocument`          | [`undo`](#undo)                                                   | Undo the last operation in the focused document.            |
| `FDocument`          | [`redo`](#redo)                                                   | Redo the last undone operation in the focused document.     |
| `FDocument`          | [`ensurePageHeader`](#ensurepageheader)                           | Ensure that a page header segment exists.                   |
| `FDocument`          | [`ensurePageFooter`](#ensurepagefooter)                           | Ensure that a page footer segment exists.                   |
| `FDocument`          | `getHeaderFooterOptions`, `setHeaderFooterOptions`                | Read or update document-level header and footer settings.   |
| `FDocument`          | [`insertText`](#inserttext)                                       | Insert plain text at a body offset.                         |
| `FDocument`          | `getTextRange`                                                    | Create a fixed text-range facade.                           |
| `FDocument`          | `getSections`, `getSection`, `getSectionAt`                       | Resolve traditional document sections.                      |
| `FDocument`          | `insertSectionBreak`, `insertColumnBreak`, `insertHorizontalRule` | Insert structural document elements.                        |
| `FDocument`          | [`getParagraphs`](#getparagraphs)                                 | Get all paragraph wrappers for a body segment.              |
| `FDocument`          | [`getParagraph`](#getparagraph)                                   | Get a paragraph wrapper by paragraph id.                    |
| `FDocument`          | [`findParagraphByText`](#findparagraphbytext)                     | Find the first paragraph containing text.                   |
| `FDocument`          | [`findParagraphs`](#findparagraphs)                               | Find paragraphs by text, paragraph id, or segment id.       |
| `FDocument`          | [`insertParagraph`](#insertparagraph)                             | Insert a plain-text paragraph at an index.                  |
| `FDocument`          | [`appendParagraph`](#appendparagraph)                             | Append a plain-text paragraph to the body.                  |
| `FDocument`          | [`deleteRange`](#deleterange)                                     | Delete a text range from the body.                          |
| `FDocumentParagraph` | [`getSegmentId`](#getsegmentid)                                   | Get the paragraph segment id.                               |
| `FDocumentParagraph` | `getId`                                                           | Get the stable paragraph id.                                |
| `FDocumentParagraph` | `getPermission`                                                   | Access the paragraph's effective edit permission.           |
| `FDocumentParagraph` | [`getInfo`](#getinfo)                                             | Get resolved paragraph metadata.                            |
| `FDocumentParagraph` | [`getRange`](#getrange)                                           | Get the paragraph text range.                               |
| `FDocumentParagraph` | `getTextRange`, `findText`, `findAllText`                         | Create or find fixed text ranges in the paragraph.          |
| `FDocumentParagraph` | [`getText`](#gettext)                                             | Get the paragraph plain text.                               |
| `FDocumentParagraph` | [`setText`](#settext)                                             | Replace the paragraph plain text.                           |
| `FDocumentParagraph` | [`appendText`](#appendtext)                                       | Append plain text before the paragraph break.               |
| `FDocumentParagraph` | [`setStyle`](#setstyle)                                           | Apply paragraph or text style.                              |
| `FDocumentParagraph` | [`isListItem`](#islistitem)                                       | Check whether the paragraph has list metadata.              |
| `FDocumentParagraph` | [`isTask`](#istask)                                               | Check whether the paragraph is a checklist item.            |
| `FDocumentParagraph` | [`setTaskChecked`](#settaskchecked)                               | Set checklist state for a task paragraph.                   |
| `FDocumentParagraph` | [`remove`](#remove)                                               | Remove the paragraph.                                       |

### @univerjs/docs-thread-comment

| Class                | Methods                                                  | Description                                               |
| -------------------- | -------------------------------------------------------- | --------------------------------------------------------- |
| `FDocumentTextRange` | `createCommentAsync`, `getComments`, `listCommentsAsync` | Create and query comments anchored to a fixed text range. |

### @univerjs/docs-ui

| Class       | Method                          | Description                                     |
| ----------- | ------------------------------- | ----------------------------------------------- |
| `FDocument` | [`setSelection`](#setselection) | Set the rendered selection range in a document. |

### @univerjs/docs-drawing

| Class            | Method                                                                           | Description                                 |
| ---------------- | -------------------------------------------------------------------------------- | ------------------------------------------- |
| `FDocument`      | [`insertImage`](#insertimage)                                                    | Insert an image into the document.          |
| `FDocument`      | [`getImage`](#getimage)                                                          | Get an image by drawing id.                 |
| `FDocument`      | [`getImages`](#getimages)                                                        | Get all document images in drawing order.   |
| `FDocumentImage` | `getId`, `getSource`, `getSize`, `getAngle`                                      | Read image identity, source, and transform. |
| `FDocumentImage` | `setSize`, `setRotate`, `setPositionH`, `setPositionV`                           | Update image geometry.                      |
| `FDocumentImage` | `setWrappingStyle`, `setForward`, `setBackward`, `setFront`, `setBack`, `remove` | Update layout or remove the image.          |

## Permissions

Unit permissions expose Edit, Copy, Export, and Comment points. Paragraph and section permissions use the object's stable ID and apply the document-level permission as a ceiling.

```typescript
import { UnitAction } from '@univerjs/protocol'

const document = univerAPI.getActiveDocument()
if (!document) throw new Error('No active document')

await document.getPermission().setPoint(UnitAction.Copy, false)
await document.getParagraphs()[0]?.getPermission().setReadOnly()

console.log(document.getPermission().canEdit())
```

Use `getEntityPermission(segmentId, entityType, entityId)` for a stable document object that does not have its own Facade wrapper.

## Text-range comments

```typescript
import '@univerjs/docs-thread-comment/facade'

const range = univerAPI.getActiveDocument()?.getTextRange(0, 12)
await range?.createCommentAsync('Verify this introduction.', { id: 'review-intro' })

const comments = await range?.listCommentsAsync()
```

`getComments()` reads locally loaded overlapping threads. `listCommentsAsync()` first synchronizes known threads through the configured datasource.

## Structure and text ranges

Traditional documents expose stable section facades. Modern documents use column groups instead; `getSections()` returns an empty array for them.

```typescript
// FDocument
getDocumentFlavor(): DocumentFlavor
isTraditional(): boolean
getHeaderFooterOptions(): IHeaderFooterProps
setHeaderFooterOptions(options: IHeaderFooterProps): boolean
getTextRange(startOffset: number, endOffset: number, segmentId?: string): FDocumentTextRange
getSections(): FDocumentSection[]
getSection(index: number): FDocumentSection | null
getSectionAt(offset: number): FDocumentSection | null
insertSectionBreak(offset: number, options?: IFDocumentInsertSectionBreakOptions): FDocumentSection | null
insertColumnBreak(offset: number): boolean
insertHorizontalRule(offset: number, border?: IParagraphBorder, segmentId?: string): FDocumentParagraph | null

// FDocumentParagraph
getId(): string
getTextRange(): FDocumentTextRange
findText(text: string, options?: IFDocumentFindTextOptions): FDocumentTextRange | null
findAllText(text: string, options?: Omit<IFDocumentFindTextOptions, 'occurrence'>): FDocumentTextRange[]

// FDocumentTextRange
getRange(): IFDocumentTextRange
getText(): string
getExplicitTextStyleRuns(): IFDocumentTextStyleRun[]
getCommonExplicitTextStyle(): ITextStyle
describe(): IFDocumentTextRangeDescription
setTextStyle(style: ITextStyle): boolean
setText(text: string): boolean
```

`FDocumentSection` supports column layout, section types, page setup, section-specific headers and footers, and removal:

```typescript
getId(): string
getIndex(): number
getConfig(): ISectionBreak
getRange(): IFDocumentTextRange
getColumns(): ISectionColumnProperties[]
describe(): IFDocumentSectionDescription
setColumns(columnCount: number, options?: IFDocumentSectionColumnOptions): boolean
setColumnProperties(columns: ISectionColumnProperties[], separator?: ColumnSeparatorType): boolean
setSectionType(sectionType: SectionType): boolean
getPageSetup(): FDocumentSectionPageSetup
getEffectivePageSetup(): IEffectiveSectionPageSetup
setPageSetup(pageSetup: FDocumentSectionPageSetup): boolean
ensureHeader(variant?: SectionHeaderFooterVariant): string
ensureFooter(variant?: SectionHeaderFooterVariant): string
getHeaderId(variant?: SectionHeaderFooterVariant): string | null
getFooterId(variant?: SectionHeaderFooterVariant): string | null
isHeaderLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean
isFooterLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean
setHeaderLinkedToPrevious(linked: boolean, variant?: SectionHeaderFooterVariant): boolean
setFooterLinkedToPrevious(linked: boolean, variant?: SectionHeaderFooterVariant): boolean
setHeaderFooterOptions(options: IHeaderFooterProps): boolean
remove(): boolean
```

```ts
const document = univerAPI.getActiveDocument()
const chapter = document?.findParagraphByText('Chapter 2')

if (document?.isTraditional() && chapter) {
  document.insertSectionBreak(chapter.getInfo().startOffset, {
    nextSectionType: univerAPI.Enum.SectionType.NEXT_PAGE,
  })
}
```

## APIs

### Document Access

### `createDocument`

Creates a document and returns its facade wrapper.

**Signature**

```typescript
createDocument(data: Partial<IDocumentData>): FDocument
```

**Parameters**

* `data` `Partial<IDocumentData>` — Initial document data. Pass `{}` to create an empty document.

**Returns**

* `FDocument` — The created document facade wrapper.

Source: 

`@univerjs/docs`

### `getActiveDocument`

**Signature**

```typescript
getActiveDocument(): FDocument | null
```

**Examples**

```ts
const fDocument = univerAPI.getActiveDocument()
```

Source: 

`@univerjs/docs`

### `getDocument`

**Signature**

```typescript
getDocument(id: string): FDocument | null
```

**Examples**

```ts
const fDocument = univerAPI.getDocument('document-01')
```

Source: 

`@univerjs/docs`

### Document Data

### `getDocumentDataModel`

**Signature**

```typescript
getDocumentDataModel(segmentId?: string): DocumentDataModel
```

`segmentId` defaults to the main body. Pass a header/footer segment id to access that segment's model.

Source: 

`@univerjs/docs`

### `getBody`

**Signature**

```typescript
getBody(segmentId?: string): IDocumentBody
```

`segmentId` defaults to the main body. Pass a header/footer segment id to access that segment's body.

Source: 

`@univerjs/docs`

### `save`

**Signature**

```typescript
save(): IDocumentData
```

Saves the current document, including content and resources, as `IDocumentData`.

**Examples**

```ts
const fDocument = univerAPI.getActiveDocument()
const snapshot = fDocument?.save()
```

Source: 

`@univerjs/docs`

### Identity & Lifecycle

### `id`

**Signature**

```typescript
id: string
```

Source: 

`@univerjs/docs`

### `dispose`

**Signature**

```typescript
dispose(): void
```

Source: 

`@univerjs/docs`

### `getId`

**Signature**

```typescript
getId(): string
```

Source: 

`@univerjs/docs`

### `getName`

**Signature**

```typescript
getName(): string
```

Source: 

`@univerjs/docs`

### `setName`

```typescript
setName(name: string): this
```

Source: 

`@univerjs/docs`

### `isModern`

**Signature**

```typescript
isModern(): boolean
```

Returns `true` when the document snapshot uses `DocumentFlavor.MODERN`.

Source: 

`@univerjs/docs`

### Editing

### `undo`

**Signature**

```typescript
undo(): boolean
```

Source: 

`@univerjs/docs`

### `redo`

**Signature**

```typescript
redo(): boolean
```

Source: 

`@univerjs/docs`

### `insertText`

**Signature**

```typescript
insertText(index: number, text: string, segmentId?: string): boolean
```

Inserts plain text at a zero-based body offset. `segmentId` defaults to the main body.

**Examples**

```ts
const fDocument = univerAPI.getActiveDocument()
fDocument?.insertText(0, 'Hello Univer')
```

Source: 

`@univerjs/docs`

### `deleteRange`

**Signature**

```typescript
deleteRange(range: IFDocumentTextRange): boolean
```

Deletes text from the main body or from the specified header/footer segment.

**Examples**

```ts
const fDocument = univerAPI.getActiveDocument()
fDocument?.deleteRange({ startOffset: 0, endOffset: 5 })
```

Source: 

`@univerjs/docs`

### Header & Footer

### `ensurePageHeader`

**Signature**

```typescript
ensurePageHeader(pageIndex?: number): string
```

Ensures the page header segment exists and returns its segment id. `pageIndex` defaults to `0`.

Source: 

`@univerjs/docs`

### `ensurePageFooter`

**Signature**

```typescript
ensurePageFooter(pageIndex?: number): string
```

Ensures the page footer segment exists and returns its segment id. `pageIndex` defaults to `0`.

Source: 

`@univerjs/docs`

### Paragraphs

### `getParagraphs`

**Signature**

```typescript
getParagraphs(segmentId?: string): FDocumentParagraph[]
```

Source: 

`@univerjs/docs`

### `getParagraph`

**Signature**

```typescript
getParagraph(paragraphId: string, segmentId?: string): FDocumentParagraph | null
```

Source: 

`@univerjs/docs`

### `findParagraphByText`

**Signature**

```typescript
findParagraphByText(text: string, segmentId?: string): FDocumentParagraph | null
```

Source: 

`@univerjs/docs`

### `findParagraphs`

**Signature**

```typescript
findParagraphs(query: string | IFDocumentParagraphQuery): FDocumentParagraph[]
```

`query` can be a text string or an object containing `text`, `paragraphId`, and `segmentId`.

Source: 

`@univerjs/docs`

### `insertParagraph`

**Signature**

```typescript
insertParagraph(index: number, text?: string, segmentId?: string): FDocumentParagraph
```

**Examples**

```ts
const fDocument = univerAPI.getActiveDocument()
const paragraph = fDocument?.insertParagraph(0, 'Document title')
paragraph?.appendText(' suffix')
```

Source: 

`@univerjs/docs`

### `appendParagraph`

**Signature**

```typescript
appendParagraph(text?: string, segmentId?: string): FDocumentParagraph
```

Source: 

`@univerjs/docs`

### Paragraph Wrapper

### `getSegmentId`

**Signature**

```typescript
getSegmentId(): string
```

Source: 

`@univerjs/docs`

### `getInfo`

**Signature**

```typescript
getInfo(): IFDocumentParagraphInfo
```

Source: 

`@univerjs/docs`

### `getRange`

**Signature**

```typescript
getRange(): IFDocumentTextRange
```

Source: 

`@univerjs/docs`

### `getText`

**Signature**

```typescript
getText(): string
```

Source: 

`@univerjs/docs`

### `setText`

**Signature**

```typescript
setText(text: string): boolean
```

Source: 

`@univerjs/docs`

### `appendText`

**Signature**

```typescript
appendText(text: string): boolean
```

Appends plain text before this paragraph's trailing paragraph break.

Source: 

`@univerjs/docs`

### `setStyle`

**Signature**

```typescript
setStyle(style: IParagraphStyle): boolean
```

Source: 

`@univerjs/docs`

### `isListItem`

**Signature**

```typescript
isListItem(): boolean
```

Source: 

`@univerjs/docs`

### `isTask`

**Signature**

```typescript
isTask(): boolean
```

Source: 

`@univerjs/docs`

### `setTaskChecked`

**Signature**

```typescript
setTaskChecked(checked: boolean): boolean
```

Returns `false` if the paragraph is not a task/checklist item.

Source: 

`@univerjs/docs`

### `remove`

**Signature**

```typescript
remove(): boolean
```

Source: 

`@univerjs/docs`

### Document Images

Plugin mode requires `import '@univerjs/docs-drawing/facade'`.

### `insertImage`

**Signature**

```typescript
insertImage(options: IFDocumentInsertImageOptions): Promise<FDocumentImage | null>
```

`source` and `imageSourceType` are required. Size, rotation, position, wrapping style, and insertion range are optional.

```ts
const document = univerAPI.getActiveDocument()
const image = await document?.insertImage({
  source: 'https://example.com/image.png',
  imageSourceType: univerAPI.Enum.ImageSourceType.URL,
  width: 320,
  wrappingStyle: univerAPI.Enum.DocsImageWrappingStyle.INLINE,
})

image?.setRotate(15)
```

Source: 

`@univerjs/docs-drawing`

### `getImage`

**Signature**

```typescript
getImage(imageId: string): FDocumentImage | null
```

Source: 

`@univerjs/docs-drawing`

### `getImages`

**Signature**

```typescript
getImages(): FDocumentImage[]
```

Source: 

`@univerjs/docs-drawing`

### UI

### `setSelection`

**Signature**

```typescript
setSelection(startOffset: number, endOffset: number): void
```

Sets the rendered selection to a text range. This method is added by `@univerjs/docs-ui/facade`.

**Examples**

```ts
const fDocument = univerAPI.getActiveDocument()
fDocument?.setSelection(10, 20)
```

Source: 

`@univerjs/docs-ui`

| Packages | `@univerjs-pro/docs-table`, `@univerjs-pro/docs-list`, `@univerjs-pro/docs-callout`, `@univerjs-pro/docs-code`, `@univerjs-pro/docs-column`, `@univerjs-pro/docs-formula`, `@univerjs-pro/docs-latex`, `@univerjs-pro/docs-quote` |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

Facade APIs added to `FDocument` by Web SDK packages for Univer Docs.

> Import the corresponding package facade, such as `@univerjs-pro/docs-table/facade`, before using that package's APIs in plugin mode.

## Rich content overview

### Tables

| Class                | Methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `FDocument`          | `getTables`, `getTable`, `getTableAt`, `getTableAtSelection`, `findTableByText`, `findTables`, `insertTable`, `insertTableFromData`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `FDocumentTable`     | `getId`, `getSegmentId`, `getInfo`, `describe`, `getRowCount`, `getColumnCount`, `getCell`, `getCellText`, `getMetadata`, `getSource`, `getRange`, `getTableRange`, `getCellRange`, `getCellContentRange`, `getCellInsertOffset`, `getRowRange`, `getRowsRange`, `getColumnRange`, `getColumnsRange`, `selectTable`, `selectRow`, `selectRows`, `selectColumn`, `selectColumns`, `selectCell`, `selectRange`, `insertRowBefore`, `insertRowAfter`, `insertRowsBefore`, `insertRowsAfter`, `appendRow`, `insertColumnBefore`, `insertColumnAfter`, `insertColumnsBefore`, `insertColumnsAfter`, `appendColumn`, `deleteRow`, `deleteRows`, `deleteColumn`, `deleteColumns`, `deleteTable`, `moveTableBy`, `moveTableToOffset`, `moveRow`, `moveRows`, `moveColumn`, `moveColumns`, `mergeCells`, `unmergeCells`, `setCellText`, `setCellBackground`, `setBorder`, `setTableBackground`, `setTableBorder`, `setTableStyle`, `setRowHeight`, `setColumnWidth`, `distributeRows`, `distributeColumns`, `getHeaderRowCount`, `setHeaderRowCount`, `pinHeaderRows`, `hasTitleRow`, `insertTitleRow`, `setColumnType`, `sortByColumn` |
| `FDocumentTableCell` | `getTable`, `getRowIndex`, `getColumnIndex`, `getText`, `getContentRange`, `getInsertOffset`, `setText`, `setBackgroundColor`, `setBorder`, `mergeTo`, `unmerge`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

### Lists

| Class               | Methods                                                                                                                                                                                                                |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FDocument`         | `getLists`, `getList`, `getListItems`, `getListItem`, `getListItemAt`, `findListItemByText`, `findListItems`, `describeListItems`, `insertList`                                                                        |
| `FDocumentList`     | `getId`, `getSegmentId`, `getItems`, `describe`, `hasOrderedItems`, `hasUnorderedItems`, `isMixed`, `setGlyphType`, `setGlyphSymbol`, `setPrefixSuffix`, `setStartNumber`, `promote`, `demote`                         |
| `FDocumentListItem` | `getParagraphStartIndex`, `getSegmentId`, `describe`, `getText`, `isOrdered`, `isUnordered`, `select`, `setGlyphType`, `setGlyphSymbol`, `setPrefixSuffix`, `setStartNumber`, `continueNumbering`, `promote`, `demote` |

### Blocks And Inline Elements

| Package                      | FDocument methods                                                                                                               | Element methods                                                                                                                                                                                                                                                                                                       |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `@univerjs-pro/docs-callout` | `getCallouts`, `getCallout`, `getCalloutAt`, `findCalloutByText`, `findCallouts`, `insertCallout`                               | `getId`, `getRange`, `getText`, `getConfig`, `getStyle`, `describe`, `updateConfig`, `setBackgroundColor`, `setBorder`, `setTextColor`, `resetTextColor`, `setIcon`, `setIconVisible`, `unwrap`, `remove`                                                                                                             |
| `@univerjs-pro/docs-code`    | `getCodes`, `getCode`, `getCodeAt`, `findCodeByText`, `findCodes`, `insertCode`                                                 | `getId`, `getRange`, `getText`, `describe`, `getConfig`, `updateConfig`, `unwrap`, `remove`                                                                                                                                                                                                                           |
| `@univerjs-pro/docs-column`  | `getColumnGroups`, `getColumnGroup`, `getColumnGroupAt`, `findColumnGroupByText`, `findColumnGroups`, `insertColumnGroup`       | `FDocumentColumnGroup`: `getId`, `getConfig`, `getRange`, `getColumnCount`, `getColumns`, `getColumn`, `getWidthRatios`, `describe`, `setWidthRatios`, `addColumn`, `deleteColumn`, `remove`; `FDocumentColumn`: `getId`, `getColumnGroupId`, `getIndex`, `getRange`, `getContentRange`, `getInsertOffset`, `getText` |
| `@univerjs-pro/docs-formula` | `getFormulas`, `getFormula`, `getFormulaAt`, `saveFormulaDisplayTextSnapshot`, `insertFormula`                                  | `FDocumentFormula`: `getId`, `getRange`, `getFormula`, `getConfig`, `getResult`, `describe`, `update`, `setNumberFormat`, `remove`, `replaceWithText`, `convertToText`; `FDocumentParagraph`: `insertFormula`, `appendFormula`; `FDocumentTextRange`: `replaceWithFormula`                                            |
| `@univerjs-pro/docs-latex`   | `getLatexFormulas`, `getLatexFormula`, `getLatexFormulaAt`, `findLatexFormulaByText`, `findLatexFormulas`, `insertLatexFormula` | `FDocumentLatex`: `getId`, `getRange`, `getLatex`, `getConfig`, `describe`, `update`; `FDocumentParagraph`: `appendLatex`, `prependLatex`; `FDocumentTextRange`: `replaceWithLatex`, `insertLatexBefore`, `insertLatexAfter`                                                                                          |
| `@univerjs-pro/docs-quote`   | `getQuotes`, `getQuote`, `getQuoteAt`, `findQuoteByText`, `findQuotes`, `insertQuote`                                           | `getId`, `getRange`, `getText`, `getStyle`, `describe`, `setStyle`, `setLineColor`, `setTextColor`, `unwrap`, `remove`                                                                                                                                                                                                |

## Rich content signatures

### Table Entry Points

```typescript
getTables(segmentId?: string): FDocumentTable[]
getTable(tableId: string, segmentId?: string): FDocumentTable | null
getTableAt(index: number, segmentId?: string): FDocumentTable | null
getTableAtSelection(): FDocumentTable | null
findTableByText(text: string, segmentId?: string): FDocumentTable | null
findTables(query: string | IDocsTableFindQuery, segmentId?: string): FDocumentTable[]
insertTable(rows: number, columns: number, options?: IDocsTableInsertOptions): FDocumentTable | null
insertTableFromData(data: string[][], options?: IDocsTableInsertOptions): FDocumentTable | null
```

### List Entry Points

```typescript
getLists(segmentId?: string): FDocumentList[]
getList(listId: string, segmentId?: string): FDocumentList | null
getListItems(segmentId?: string): FDocumentListItem[]
getListItem(paragraphStartIndex: number, segmentId?: string): FDocumentListItem | null
getListItemAt(offset: number, segmentId?: string): FDocumentListItem | null
findListItemByText(text: string, segmentId?: string): FDocumentListItem | null
findListItems(query: string | IDocsListFindQuery, segmentId?: string): FDocumentListItem[]
describeListItems(segmentId?: string): IDocsListItemInfo[]
insertList(paragraphOrOptions?: FDocumentParagraph | IDocsListInsertFacadeOptions, options?: IDocsListInsertParagraphFacadeOptions): FDocumentList | null
```

### Table Wrapper APIs

```typescript
// FDocumentTable
getId(): string
getSegmentId(): string
getInfo(): IDocsTableInfo
describe(): IDocsTableDescription
getRowCount(): number
getColumnCount(): number
getCell(row: number, column: number): FDocumentTableCell | null
getCellText(row: number, column: number): string
getMetadata(): IDocsTableMetadata | undefined
getSource(): ITable | undefined
getRange(): IDocsTableOffsetRange | null
getTableRange(): IDocsTableCellRange
getCellRange(row: number, column: number): IDocsTableCellRange
getCellContentRange(row: number, column: number): IDocsTableCellContentRange | null
getCellInsertOffset(row: number, column: number): number | null
getRowRange(row: number): IDocsTableCellRange
getRowsRange(startRow: number, count?: number): IDocsTableCellRange
getColumnRange(column: number): IDocsTableCellRange
getColumnsRange(startColumn: number, count?: number): IDocsTableCellRange
selectTable(): boolean
selectRow(row: number): boolean
selectRows(startRow: number, count?: number): boolean
selectColumn(column: number): boolean
selectColumns(startColumn: number, count?: number): boolean
selectCell(row: number, column: number): boolean
selectRange(range: IDocsTableCellRange, kind: Exclude<DocsTableSelectionKind, DocsTableSelectionKind.None | DocsTableSelectionKind.Text>): boolean
insertRowBefore(row: number): boolean
insertRowAfter(row: number): boolean
insertRowsBefore(row: number, count: number): boolean
insertRowsAfter(row: number, count: number): boolean
appendRow(): boolean
insertColumnBefore(column: number): boolean
insertColumnAfter(column: number): boolean
insertColumnsBefore(column: number, count: number): boolean
insertColumnsAfter(column: number, count: number): boolean
appendColumn(): boolean
deleteRow(row: number): boolean
deleteRows(startRow: number, count?: number): boolean
deleteColumn(column: number): boolean
deleteColumns(startColumn: number, count?: number): boolean
deleteTable(): boolean
moveTableBy(deltaX: number, deltaY: number): boolean
moveTableToOffset(offset: number): boolean
moveRow(row: number, targetRow: number, position: DocsTableRowInsertPosition): boolean
moveRows(startRow: number, count: number, targetRow: number, position: DocsTableRowInsertPosition): boolean
moveColumn(column: number, targetColumn: number, position: DocsTableColumnInsertPosition): boolean
moveColumns(startColumn: number, count: number, targetColumn: number, position: DocsTableColumnInsertPosition): boolean
mergeCells(range: IDocsTableCellRange): boolean
unmergeCells(range: IDocsTableCellRange): boolean
setCellText(row: number, column: number, text: string): boolean
setCellBackground(range: IDocsTableCellRange, color: string): boolean
setBorder(range: IDocsTableCellRange, options: IDocsTableBorderOptions): boolean
setTableBackground(color: string): boolean
setTableBorder(border: IDocsTableBorderOptions): boolean
setTableStyle(style: IDocsTableStyle): boolean
setRowHeight(row: number, height: number): boolean
setColumnWidth(column: number, width: number): boolean
distributeRows(startRow?: number, count?: number): boolean
distributeColumns(startColumn?: number, count?: number): boolean
getHeaderRowCount(): number
setHeaderRowCount(count: number): boolean
pinHeaderRows(count: number): boolean
hasTitleRow(): boolean
insertTitleRow(): boolean
setColumnType(column: number, config: IDocsTableColumnTypeConfig): boolean
sortByColumn(column: number, direction: DocsTableSortDirection): boolean

// FDocumentTableCell
getTable(): FDocumentTable
getRowIndex(): number
getColumnIndex(): number
getText(): string
getContentRange(): IDocsTableCellContentRange | null
getInsertOffset(): number | null
setText(text: string): boolean
setBackgroundColor(color: string): boolean
setBorder(border: IDocsTableBorderOptions): boolean
mergeTo(rowSpan: number, columnSpan: number): boolean
unmerge(): boolean
```

### List Wrapper APIs

```typescript
// FDocumentList
getId(): string
getSegmentId(): string
getItems(): FDocumentListItem[]
describe(): IDocsListInfo
hasOrderedItems(): boolean
hasUnorderedItems(): boolean
isMixed(): boolean
setGlyphType(glyphType: ListGlyphType): boolean
setGlyphSymbol(symbol: string): boolean
setPrefixSuffix(prefix: string, suffix: string): boolean
setStartNumber(startNumber: number): boolean
promote(): boolean
demote(): boolean

// FDocumentListItem
getParagraphStartIndex(): number
getSegmentId(): string
describe(): IDocsListItemInfo | null
getText(): string
isOrdered(): boolean
isUnordered(): boolean
select(mode?: DocsListSelectionMode): boolean
setGlyphType(glyphType: ListGlyphType, options?: IDocsListOperationOptions): boolean
setGlyphSymbol(symbol: string, options?: IDocsListOperationOptions): boolean
setPrefixSuffix(prefix: string, suffix: string, options?: IDocsListOperationOptions): boolean
setStartNumber(startNumber: number, options?: IDocsListStartNumberOptions): boolean
continueNumbering(): boolean
promote(options?: IDocsListOperationOptions): boolean
demote(options?: IDocsListOperationOptions): boolean
```

### Block Entry Points

```typescript
insertCallout(paragraphOrOptions?: FDocumentParagraph | IDocsCalloutInsertFacadeOptions, options?: IDocsCalloutInsertParagraphFacadeOptions): FDocumentCallout | null
insertCode(paragraphOrOptions?: FDocumentParagraph | IDocsCodeInsertFacadeOptions, options?: IDocsCodeInsertParagraphFacadeOptions): FDocumentCode | null
insertColumnGroup(columnCount: number, options?: IDocsColumnInsertFacadeOptions): FDocumentColumnGroup | null
insertLatexFormula(options: IDocsLatexInsertFacadeOptions): FDocumentLatex | null
insertQuote(paragraphOrOptions?: FDocumentParagraph | IDocsQuoteInsertFacadeOptions, options?: IDocsQuoteInsertParagraphFacadeOptions): FDocumentQuote | null
```

### Callout and quote styles

```typescript
// FDocumentCallout
getStyle(): IDocsCalloutStyle
setBackgroundColor(backgroundColor: string): boolean
setBorder(border: Partial<IDocsCalloutBorderStyle>): boolean
setTextColor(value: string): boolean
resetTextColor(): boolean
setIcon(icon: string): boolean
setIconVisible(showIcon: boolean): boolean

// FDocumentQuote
getStyle(): IDocsQuoteStyle
setStyle(style: Partial<IDocsQuoteStyle>): boolean
setLineColor(lineColor: string): boolean
setTextColor(textColor: string): boolean
```

```ts
const callout = fDocument?.findCalloutByText('Important')
callout?.setBackgroundColor('#FFF4E5')
callout?.setBorder({ color: '#E6A23C', width: 2 })
callout?.setTextColor('#5C3B00')

const quote = fDocument?.findQuoteByText('Decision')
quote?.setStyle({ lineColor: '#5B5FC7', textColor: '#242424' })
```

LaTeX can also be inserted from stable paragraph and text-range handles:

```typescript
// FDocumentParagraph
appendLatex(latex: string, options?: IDocsLatexCreateFacadeOptions): FDocumentLatex | null
prependLatex(latex: string, options?: IDocsLatexCreateFacadeOptions): FDocumentLatex | null

// FDocumentTextRange
replaceWithLatex(latex: string, options?: IDocsLatexCreateFacadeOptions): FDocumentLatex | null
insertLatexBefore(latex: string, options?: IDocsLatexCreateFacadeOptions): FDocumentLatex | null
insertLatexAfter(latex: string, options?: IDocsLatexCreateFacadeOptions): FDocumentLatex | null
```

### Inline Data Formulas

Import `@univerjs-pro/docs-formula/facade` to add formula methods to documents, paragraphs, and text ranges.

```typescript
// FDocument
getFormulas(): FDocumentFormula[]
getFormula(rangeId: string): FDocumentFormula | null
getFormulaAt(offset: number): FDocumentFormula | null
saveFormulaDisplayTextSnapshot(): IDocumentData
insertFormula(options: IDocFormulaInsertFacadeOptions): FDocumentFormula | null

// FDocumentParagraph
insertFormula(offset: number, formula: string, options?: IDocFormulaCreateFacadeOptions): FDocumentFormula | null
appendFormula(formula: string, options?: IDocFormulaCreateFacadeOptions): FDocumentFormula | null

// FDocumentTextRange
replaceWithFormula(formula: string, options?: IDocFormulaCreateFacadeOptions): FDocumentFormula | null

// FDocumentFormula
getId(): string
getRange(): IDocFormulaRange | null
getFormula(): string
getConfig(): IDocFormulaConfig | null
getResult(): IDocFormulaResult | null
describe(): IDocFormulaInfo | null
update(options: IDocFormulaUpdateFacadeOptions): boolean
setNumberFormat(numberFormat?: { pattern: string }): boolean
remove(): boolean
replaceWithText(text: string): boolean
convertToText(): boolean
```

```ts
const document = univerAPI.getActiveDocument()
const paragraph = document?.appendParagraph('Revenue: ')
const formula = paragraph?.appendFormula('=1000/4', {
  numberFormat: { pattern: '$#,##0.00' },
})

console.log(formula?.getResult()?.text)
```

### Enums

```typescript
// univerAPI.Enum from @univerjs-pro/docs-table/facade
DocsTableInsertTablePosition: typeof DocsTableInsertTablePosition
DocsTableColumnType: typeof DocsTableColumnType
DocsTableSelectionKind: typeof DocsTableSelectionKind
DocsTableRowInsertPosition: typeof DocsTableRowInsertPosition
DocsTableColumnInsertPosition: typeof DocsTableColumnInsertPosition
DocsTableBorderPreset: typeof DocsTableBorderPreset
DocsTableSortDirection: typeof DocsTableSortDirection
DashStyleType: typeof DashStyleType

// univerAPI.Enum from @univerjs-pro/docs-list/facade
PresetListType: typeof PresetListType
DocsListSelectionMode: typeof DocsListSelectionMode
ListGlyphType: typeof ListGlyphType

// univerAPI.Enum from @univerjs-pro/docs-column/facade
DocsColumnPositionEnum: typeof DocsColumnPositionEnum
```

## Rich content examples

```ts
const fDocument = univerAPI.getActiveDocument()

const table = fDocument?.insertTableFromData([
  ['Name', 'Score'],
  ['Ada', '100'],
])

table?.setCellText(1, 1, '98')
```

Source: `@univerjs-pro/docs-table`, `@univerjs-pro/docs-list`, `@univerjs-pro/docs-callout`,
`@univerjs-pro/docs-code`, `@univerjs-pro/docs-column`, `@univerjs-pro/docs-formula`, `@univerjs-pro/docs-latex`,
`@univerjs-pro/docs-quote`

## Footnotes and endnotes

Import `@univerjs-pro/docs-reference/facade` and register `UniverDocsReferencePlugin` to use these methods on a traditional paginated document. Insertion returns a stable note ID, or `null` when the position, content, document mode, or permission does not allow the operation.

| Methods                                                                                 | Purpose                                                                 |
| --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `insertFootnote(offset, content?)`, `insertEndnote(offset, content?)`                   | Insert a reference at a UTF-16 main-body offset and create note content |
| `getFootnotes()`, `getEndnotes()`                                                       | Read detached note data in reference order                              |
| `deleteFootnote(noteId)`, `deleteEndnote(noteId)`                                       | Delete a note and its reference                                         |
| `getFootnoteSettings(sectionId?)`, `getEndnoteSettings(sectionId?)`                     | Read explicit numbering and placement settings                          |
| `setFootnoteSettings(settings, sectionId?)`, `setEndnoteSettings(settings, sectionId?)` | Replace settings, or reset them with `null`                             |

See [Footnotes and endnotes](https://docs.univer.ai/zh-CN/guides/docs/features/footnotes.md) for setup and examples. Displayed numbering may change after layout; use the stable note ID with `getParagraphs(noteId)` or `getTextRange()` when addressing note content.
