> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# @reductoai/docx-editor

The batteries-included editor. Guide: [Editor](https://docs.reducto.ai/office/docx/ui/editor.md).

## `mountDocxEditor()`

```ts theme={null}
function mountDocxEditor(
  target: string | HTMLElement,
  options?: DocxEditorOptions,
): DocxEditorHandle
```

Import from `@reductoai/docx-editor`.

## `DocxEditorOptions`

Import from `@reductoai/docx-editor`.

```ts theme={null}
type DocxEditorOptions = LanguageOptions & { components?: readonly EditorComponent<any>[]; document?: { bytes: Uint8Array; name: string; options?: OpenOptions }; fonts?: EditorModelOptions["fonts"]; fontsUrl?: string; keybindings?: KeybindingOptions; links?: LinkHandlers; proxyUrl?: string; readOnly?: boolean; rulerUnit?: RulerUnit; server?: LiveOptions; slots?: DocxEditorSlots; speculate?: boolean; spellDictionary?: SpellDictionary; suggesting?: SuggestingPolicy; toolbarItems?: ToolbarItems; transport?: EditorTransport; verticalRuler?: boolean; wasmUrl?: string; worker?: () => Worker }
```

## `DocxEditorSlots`

The regions a host can take over. Absent: the built-in; `null`: nothing; a slot:
the host's own markup in the built-in's place. The host element is `display: contents`,
so what a slot appends sits in the editor's grid as the built-in would.

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `balloon?` | `BalloonSlot` | Content of the review margin's balloons; the margin keeps their place, connector and frame. |
| `contextMenu?` | `EditorSlot \| null` | Mounted while `model.ui.contextMenu.open`; read `x`, `y` and `items` from that store. |
| `empty?` | `EditorSlot \| null` | Over the pages while no document is open. |
| `gutter?` | `EditorSlot \| null` | The comment icons while the margin is closed; place them off `model.review.gutter`. |
| `inspector?` | `EditorSlot \| null` | The panel on the right while `model.inspectorVisible`. |
| `margin?` | `EditorSlot \| null` | The review margin while `model.review.open`; place balloons off `model.review.layout`. |
| `nav?` | `EditorSlot \| null` | The navigation pane on the left while `model.nav.open`: headings and find. |
| `navClosed?` | `EditorSlot \| null` | In the pane's place while `model.nav` is closed: a rail or button that opens it. None by default. |
| `progress?` | `EditorSlot \| null` | Over the pages while a document opens; read `model.progress`. |
| `selection?` | `EditorSlot \| null` | Mounted while the document is editable: the floating bar over a selection. |
| `toolbar?` | `EditorSlot \| null` | The bar above the pages. |

## `EditorSlot`

Fills a region the editor reserves; returns the cleanup to run when the region unmounts.

Import from `@reductoai/docx-editor`.

```ts theme={null}
type EditorSlot = (host: HTMLElement, model: EditorModel) => (() => void) | void
```

## `DocxEditorHandle`

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `components` | `ComponentViews` | The live views of the `components` option. |
| `live?` | `LiveSession` | The live session, when mounted with `server`. |
| `model` | `EditorModel` | |
| `destroy()` | `() => void` | |
| `open()` | `(bytes: Uint8Array, name: string, options?: OpenOptions) => Promise<void>` | |

## `downloadDocx()`

```ts theme={null}
function downloadDocx(model: EditorModel, save?: SaveBytes): Promise<void>
```

Download the current edit state as a .docx file.

Import from `@reductoai/docx-editor`, `@reductoai/docx-editor/model`.

## `downloadPdf()`

```ts theme={null}
function downloadPdf(model: EditorModel, save?: SaveBytes): Promise<void>
```

Render the current layout and download it as a PDF.

Import from `@reductoai/docx-editor`, `@reductoai/docx-editor/model`.

## `downloadBytes()`

```ts theme={null}
function downloadBytes(bytes: Uint8Array, filename: string, type: string): void
```

Trigger a browser download for `bytes`, named `filename`.

Import from `@reductoai/docx-editor`, `@reductoai/docx-editor/model`.

## `DEFAULT_FONTS_URL`

```ts theme={null}
const DEFAULT_FONTS_URL: string = ...
```

The published `@reductoai/portable-fonts` files on the npm CDN; the default when a host serves none.

Import from `@reductoai/docx-editor`, `@reductoai/docx-editor/model`.
