> ## 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.

# Editor

`@reductoai/pptx-editor` gives you a .pptx editor in one call: the ribbon, the slide rail with sections, the slide stage with shape handles and text editing, notes, comments, Find and Replace, chart Edit Data and the slide show.

## Vanilla JS

```ts theme={null}
import { mountPptxEditor } from "@reductoai/pptx-editor";
import "@reductoai/pptx-editor/style.css";

const bytes = new Uint8Array(await (await fetch("/q3-review.pptx")).arrayBuffer());
const editor = mountPptxEditor(document.getElementById("app")!, { deck: bytes, name: "Q3 review.pptx" });

await editor.model.run({ type: "addSlide" });
const saved = await editor.save(); // .pptx bytes with every edit
await editor.open(otherBytes, "Budget.pptx");
editor.destroy();
```

Give the element a height. The editor fills it.

```css theme={null}
#app {
  height: 100vh;
}
```

## React

```tsx theme={null}
import { useState } from "react";
import { PptxEditor, usePptxEditor } from "@reductoai/pptx-editor/react";
import type { PptxEditorModel } from "@reductoai/pptx-editor";
import "@reductoai/pptx-editor/style.css";

export function App({ bytes }: { bytes: Uint8Array }) {
  const [model, setModel] = useState<PptxEditorModel | null>(null);
  const canUndo = usePptxEditor(model, (m) => m?.view?.canUndo ?? false);
  return (
    <>
      <button disabled={!canUndo} onClick={() => model?.run({ type: "undo" })}>
        Undo
      </button>
      <PptxEditor deck={bytes} onReady={setModel} style={{ height: 600 }} />
    </>
  );
}
```

`usePptxEditor(model, select)` re-renders only when the picked value changes (shallow compare). Without a selector it re-renders on every edit, selection and slide change. Outside React, `watch(read, onChange)` from `@reductoai/pptx-editor` does the same.

`deck` opens again when it changes, so keep the bytes stable between renders. `onError` hears when a deck does not open, and `readOnly` follows the prop. React is an optional peer dependency.

The editor paints on canvases, so it must run on the client. In Next.js, load it with `dynamic(() => import("./App"), { ssr: false })`.

## Options

| Option | Default | Notes |
| - | - | - |
| `deck` | none | The bytes of a .pptx file to open on mount |
| `name` | none | The deck's file name, shown while it opens |
| `fontsUrl` | the npm CDN copy of `@reductoai/portable-fonts` | Your own `/fonts` folder: copy `node_modules/@reductoai/portable-fonts/files` there |
| `fonts` | the portable fonts at `fontsUrl` | A `FaceProvider` of your own for the slides (`tableFaceProvider` from `@reductoai/pptx/browser`) |
| `readOnly` | `false` | Slides, selection, Find and Copy work; every edit is dropped. Set `model.readOnly` to change it later |
| `toolbar` | `true` | The ribbon above the slides |
| `scheme` | `"light"` | `"dark"` paints the stage for a dark theme |
| `keybindings` | Microsoft PowerPoint's keys | `{ overrides, store, customizable }`: your changes to the keys, where the user's own changes live (default `localStorage`), and whether the Keyboard Shortcuts window shows |
| `userName` | the name the user last typed | The name new comments are posted under |

Faces load on demand: a deck pulls only the families it uses, and a command that asks for a new face (a font change, pasted text) fetches it and lays the deck out again.

## The handle

`mountPptxEditor` returns:

| Member | Does |
| - | - |
| `model` | The `PptxEditorModel`. `model.run(command)` runs any [command](https://docs.reducto.ai/office/pptx/ui/headless-editor.md#commands); `model.view` is the laid-out view |
| `open(bytes, name?)` | Opens another deck in place of the current one |
| `save()` | The deck as .pptx bytes once every queued edit has settled; `null` while none is open |
| `destroy()` | Unmounts the editor |

## EMF and WMF pictures

They show as placeholder boxes until the page installs a backend. Call `installBrowserMetafileBackend` and `installBrowserSvgRasterizer` from `@reductoai/pptx/browser` once, before the first deck opens. See [JS API in the browser](https://docs.reducto.ai/office/pptx/js-api/browser.md#emf-wmf-and-svg-pictures). Pass the same `fonts` provider to the editor and the backend, so metafile text finds its faces.

## Styles

`style.css` styles the editor only: every rule applies under `.reductoai` (the editor's root and its menus), and the design tokens all start with `--rd-`. Set a token on `:root` or on an ancestor of the editor to re-skin it; `@reductoai/pptx-editor/tokens.css` lists them. For a page that is all editor, also import `@reductoai/pptx-editor/page.css`: it styles `html` and `body`.
