> ## 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/pptx-editor

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

## `mountPptxEditor()`

```ts theme={null}
function mountPptxEditor(
  target: HTMLElement,
  options?: PptxEditorOptions,
): PptxEditorHandle
```

Import from `@reductoai/pptx-editor`.

## `PptxEditorOptions`

Import from `@reductoai/pptx-editor`.

| Name | Type | Description |
| - | - | - |
| `deck?` | `Uint8Array` | Opened as soon as the editor mounts: the bytes of a .pptx file. |
| `fonts?` | `FaceProvider` | The faces slides lay out and paint with; `fontsUrl` is then ignored for slides. |
| `fontsUrl?` | `string` | Where the `@reductoai/portable-fonts` files are served from. Default: the npm CDN. |
| `keybindings?` | `KeybindingOptions` | Changes to PowerPoint's keys, and whether the user may make them. |
| `name?` | `string` | The deck's file name, shown while it opens. |
| `proxyUrl?` | `string` | Sends license checks and usage events through your backend instead of straight to Reducto: the URL where `licenseProxy` from `@reductoai/pptx/license-proxy` is mounted. Required: a licensed editor will not run in a browser without it. |
| `readOnly?` | `boolean` | A viewer's deck: slides, selection, Find and Copy work; every edit is dropped. |
| `scheme?` | `"light" \| "dark"` | How slides paint in the dark theme. Default "light". |
| `statusBar?` | `boolean` | The bar under the slide: slide count, panes, Slide Show. Default on. |
| `toolbar?` | `boolean` | The ribbon above the slides. Default on. |
| `userName?` | `string` | The name new comments are posted under. |

## `PptxEditorHandle`

Import from `@reductoai/pptx-editor`.

| Name | Type | Description |
| - | - | - |
| `model` | `PptxEditorModel` | |
| `destroy()` | `() => void` | |
| `open()` | `(deck: Uint8Array, name?: string) => Promise<void>` | Opens a .pptx file's bytes in place of the current deck. |
| `save()` | `() => Promise<Uint8Array<ArrayBufferLike> \| null>` | The deck as .pptx bytes once every queued edit has settled; null while none is open. |

## `PptxEditorModel`

Import from `@reductoai/pptx-editor`.

### PptxEditorModel properties

| Name | Type | Description |
| - | - | - |
| `author` | `CommentAuthor \| null` | Who new comments and replies are by; a host that knows the user sets it. |
| `cropping` | `string \| null` | The picture in crop mode: its crop handles replace the frame's. |
| `customizableKeys` | `boolean` | read-only The Keyboard Shortcuts window is offered. |
| `display` | `{ gridlines: boolean; guides: boolean; ruler: boolean }` | View > Ruler, Gridlines and Guides; like PowerPoint's, they belong to the window, not the deck. |
| `editor` | `PptxEditor \| null` | |
| `error` | `string` | |
| `format` | `TextFormat \| undefined` | |
| `historyTurns` | `number` | Counts undo and redo, so an open data window reloads what they put back. |
| `keys` | `PptxKeymap` | read-only Every key's command; rebind with `keys.bind` or the `keybindings` option. |
| `peers` | `PeerMark[]` | Other writers on this view, from `setPresence`. |
| `progress` | `ProgressView \| null` | Set while a deck opens; a deck already on screen keeps the block small. |
| `readOnly` | `boolean` | A viewer's deck: slides, selection, Find and Copy work; every edit is dropped. |
| `show` | `SlideShow \| null` | The slide show running in this editor, if any. |
| `smartGuides` | `boolean` | Grid and Guides > Display smart guides when shapes are aligned; off, a drag snaps to guides and the grid only. |
| `ui` | `PptxKeyUi` | read-only |
| `version` | `number` | Counts every view published: each edit, selection and slide change. |
| `view` | `EditorView \| null` | |
| `zoom` | `number` | The zoom on screen, Fit's included; the stage sets it. |
| `zoomMode` | `ZoomMode` | Fit, or the percentage the user picked. |
| `pending` | `number` | read-only Commands still queued; a pointer move skips its update while any wait. |

### `PptxEditorModel.addGuide()`

```ts theme={null}
addGuide(orientation: "Horizontal" | "Vertical"): void
```

A guide through the slide's centre, and the guides shown.

### `PptxEditorModel.changePicture()`

```ts theme={null}
changePicture(): Promise<void>
```

Change Picture: the file picker, then the selected picture shows that file.

### `PptxEditorModel.external()`

```ts theme={null}
external<T>(run: () => Promise<T>): Promise<T>
```

Runs an edit made around the editor (a script, an agent) on `editor.presentation` in the
command queue, as one undo step; the settled view lands in `view`.

### `PptxEditorModel.insertMedia()`

```ts theme={null}
insertMedia(file: File, at?: { x: number; y: number }): Promise<void>
```

A video or sound file on the current slide, centred on `at` (hmm) or on the slide.

### `PptxEditorModel.insertPicture()`

```ts theme={null}
insertPicture(file: File, at?: { x: number; y: number }): Promise<void>
```

A picture file on the current slide, centred on `at` (hmm) or on the slide.

### `PptxEditorModel.laidOut()`

```ts theme={null}
laidOut(): Promise<EditorView | null>
```

The view once every slide is laid out: for a PDF export or anything else that reads the whole deck.

### `PptxEditorModel.merge()`

```ts theme={null}
merge(run: () => Iterable<string>): Promise<EditorView | null>
```

Lands another writer's change (`run` writes it and names the parts it wrote) in the command
queue, keeping the user's selection.

### `PptxEditorModel.open()`

```ts theme={null}
open(bytes: Uint8Array, name?: string): Promise<void>
```

### `PptxEditorModel.pickPicture()`

```ts theme={null}
pickPicture(): Promise<void>
```

Insert > Picture: the file picker, then the picture centred on the slide.

### `PptxEditorModel.pickPictureBytes()`

```ts theme={null}
pickPictureBytes(): Promise<Uint8Array<ArrayBufferLike> | undefined>
```

The file picker, then the picked image's bytes as PowerPoint keeps them; undefined when cancelled or unreadable.

### `PptxEditorModel.present()`

```ts theme={null}
present(options: ShowOptions): SlideShow | null
```

Starts a slide show; one already running ends first.

### `PptxEditorModel.run()`

```ts theme={null}
run(command: PptxCommand): Promise<EditorView | null>
```

### `PptxEditorModel.save()`

```ts theme={null}
save(): Promise<Uint8Array<ArrayBufferLike> | null>
```

### `PptxEditorModel.setAuthorName()`

```ts theme={null}
setAuthorName(name: string): void
```

The name the user typed for their comments, kept for the next visit.

### `PptxEditorModel.setDisplay()`

```ts theme={null}
setDisplay(mark: "ruler" | "gridlines" | "guides", on: boolean): void
```

Turning Guides on in a deck with none adds PowerPoint's two centre guides.

### `PptxEditorModel.setPresence()`

```ts theme={null}
setPresence(presence: { location: PptxPresence; peer: PeerInfo }[]): void
```

Other writers' places; their marks follow every view this model publishes.

### `PptxEditorModel.settled()`

```ts theme={null}
settled(): Promise<unknown>
```

Waits for every queued command; tests and scripts call it before reading `view`.

### `PptxEditorModel.setZoom()`

```ts theme={null}
setZoom(zoom: ZoomMode): void
```

## `PptxEditorHooks`

Import from `@reductoai/pptx-editor`.

| Name | Type | Description |
| - | - | - |
| `afterCommand?` | `() => Promise<boolean>` | |
| `beforeCommand?` | `() => void` | Called around each command; true asks for a full relayout (new faces arrived). |
| `open` | `(bytes: Uint8Array, onProgress?: LayoutProgress) => Promise<PptxEditor>` | |

## `pptxHooks()`

```ts theme={null}
function pptxHooks(fonts: FaceProvider, options?: PptxHookOptions): PptxEditorHooks
```

Import from `@reductoai/pptx-editor`.

## `PaintCache`

Import from `@reductoai/pptx-editor`.

### PaintCache properties

| Name | Type | Description |
| - | - | - |
| `images` | `DecodedImages` | read-only |

### `PaintCache.prepare()`

```ts theme={null}
prepare(ir: LayoutDocument, pages: LayoutPage[]): Promise<void>
```

Registers the faces and decodes the pictures the given pages use; a page seen before costs nothing.

## `watch()`

```ts theme={null}
function watch<T>(read: () => T, onChange: (value: T) => void): () => void
```

Calls `onChange` after any field `read` reads changes; returns the stop.

Import from `@reductoai/pptx-editor`.
